Skip to content

Cant connect to Channel #2698

Answered by gehongyan
tokle002 asked this question in Q&A
Jun 9, 2023 · 2 comments · 4 replies
Discussion options

You must be logged in to vote

@tokle002

https://discordnet.dev/guides/getting_started/first-bot.html#creating-a-discord-client

We may now invoke the client's StartAsync method, which will start connection/reconnection logic. It is important to note that this method will return as soon as connection logic has been started! Any methods that rely on the client's state should go in an event handler. This means that you should not directly be interacting with the client before it is fully ready.

Try getting the channel inside the handlers subscribed to Ready event.

_client.Ready += () =>
{
    var channel = _client.GetChannel(1116600689100083240) as SocketTextChannel;
    return Task.CompletedTask;
};

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@Anheledir
Comment options

@tokle002
Comment options

@Anheledir
Comment options

@IOKG04
Comment options

Answer selected by tokle002
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
5 participants