Skip to content
Discussion options

You must be logged in to vote

discord.utils.get gets the object or None if it's not found. So channel is either a discord.abc.GuildChannel (which can either be discord.TextChannel, discord.CategoryChannel, discord.StoreChannel, or discord.VoiceChannel) or None.

However you're comparing it to a string which will always be False. To fix your code do the following:

def checkforchannel(channelname_to_check):
    channel = discord.utils.get(client.get_all_channels(), name=channelname_to_check)
    return channel is not None

Note however as I hinted on above that get_all_channels goes through all channels in every guild your bot is on. It's probably a good idea to restrict the search to something that either belongs to a sp…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@5pread
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants