weow
weow

Reputation: 1

discord.net send DM, create channel, unknown channel

I use my bot to help my users register themselves for events. They -register UserId to register, and they get a DM reply with typical reaction driven menus to set parameters and provide information. Unfortunately, whenever the connection is interrupted, all channels are dropped, and the reaction driven menus seem unresponsive to the user. The reactions aren't reaching the event handler because the channel is not re-established upon reconnect. This appears in the console:

Unknown Channel (MESSAGE_REACTION_ADD Channel=387147545769541632).

more info here: [https://github.com/discord-net/Discord.Net/issues/1040][1]

In order to re-establish DM channels, I plan to use a timer to periodically ping all currently registered users. For persistence, all variables about the channel and user are stored in a google sheet that is populated when users initially register.

Remember, this is tricky because no Context exists, and there are no existing known channels. Here is what i've tried so far:

var sent = await Discord.UserExtensions.SendMessageAsync("User#4708", "ping");

Error: cannot convert from 'string' to 'Discord.IUser'

Same error if you try to declare a new variable of type Discord.IUser and set it equal to the string value of the name.

So I tried to avoid 'string' and get either the channel or user directly ('channelID' and 'user' are both ulong)

var c = _client.GetChannel(channelID) as IMessageChannel;
var d = _client.GetDMChannelAsync(channelID)
var u = _client.GetUser(user)

c, d and u all result in 'null' and you get an object reference not set error if you try to use any version of the .SendMessageAsync method.

How come I can't send a DM to a user even though I know everything about them?

Upvotes: 0

Views: 1156

Answers (0)

Related Questions