Send message in channel via a function #8609
-
I am trying to send a message to a specific channel through a function with parameters. The connection to the channel does't seem to work inside the function but it works in a client.on block. I was just wonderign if I am missing something ?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
For the same reason as I outlined before: Looking at your code, that is further confirmed by it running before the client is even logged in and ready Execute that only in a scope that happens after the client is logged in (which is why your comments state that the send does in fact work in those contexts) |
Beta Was this translation helpful? Give feedback.
For the same reason as I outlined before:
The channel you are trying to get is not cached at the point this code runs.
Looking at your code, that is further confirmed by it running before the client is even logged in and ready
Which means it runs before it has gotten any information about the guilds (servers) it is in
Which in turn means it runs before there is any channel cached to begin with
Execute that only in a scope that happens after the client is logged in (which is why your comments state that the send does in fact work in those contexts)