How can I send this message? #6387
-
Here is my code:
I replaced some sensitive information for this discussion, but I do have the 'token' field filled in. I have two questions: First, will this work if i put a string in the parentheses?
Or does it need to be some sort of ID? Second, he main problem is I get this warning when I try to send the 'hello' message to a specific channel:
Can someone please educate me on what could cause that and how I can fix it? Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Client.get_channel requires an So, this will not work:
This actually leads into your error. In your specific case Hopefully this wasn't too confusing! Edit: if you pass an actual |
Beta Was this translation helpful? Give feedback.
-
Don't use |
Beta Was this translation helpful? Give feedback.
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 theDiscord ID
of the channel, rather than a string name of the channel.So, this will not work:
This actually leads into your error. In your specific case
channel = client.get_channel("channel1")
is the same aschannel = None
because the call failed to look up a channel and thus defaults toNone
. Next step is that you trychannel.send('hello')
and get the error becausechannel = None
at the time of callingsend()
.Hopefully this wasn't too confusing!
Edit: if you pass an actual
Discord Channel ID
toclient…