get the name of a channel using discord.py

前端 未结 2 922
醉话见心
醉话见心 2021-01-13 07:00

how do I get the name of a channel so that this bot will work on any server its put on with no changes to code necessary? ( in the code where I put \"what do I put here\" is

2条回答
  •  伪装坚强ぢ
    2021-01-13 07:18

    Now in rewrite there's a method called discord.utils.get where you can actually getting discord objects with specific parameters

    In your case with a channel name:

    import discord
    channel = discord.utils.get(guild.text_channels, name="Name of channel")
    

    Should be None if discord couldn't find a textchannel with that name

提交回复
热议问题