Skip to content

How can I send this message? #6387

Answered by bandwiches
gegne asked this question in Q&A
Feb 4, 2021 · 2 comments · 3 replies
Discussion options

You must be logged in to vote

Client.get_channel requires an id parameter which is not the same as the string label of the channel itself. So you would actually be passing the Discord ID of the channel, rather than a string name of the channel.

So, this will not work:

channel = client.get_channel("channel1")

This actually leads into your error. In your specific case channel = client.get_channel("channel1") is the same as channel = None because the call failed to look up a channel and thus defaults to None. Next step is that you try channel.send('hello') and get the error because channel = None at the time of calling send().

Hopefully this wasn't too confusing!

Edit: if you pass an actual Discord Channel ID to client…

Replies: 2 comments 3 replies

Comment options

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

Answer selected by Rapptz
Comment options

You must be logged in to vote
2 replies
@15696
Comment options

@bandwiches
Comment options

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