I would like to offer my users a reminder function. The users register for this function via slashcommand, and the user's Discord ID, among other things, is then entered in the database. A reminder is sent to these users via DM once a day at a certain time. And at this point I have a problem.
With
SocketUser user = _client.GetUser(subscriber.discord_id);
Unfortunately I get a null value for the SocketUser.
If I understood correctly, this is because the user is not in the cache, which is why I
_client.Rest.GetUserAsync(subscriber.discord_id
can use. Here I actually get a RestUser object with the correct data for the associated DC ID. However, then i get here
var dmChannel = await subscriber.CreateDMChannelAsync();
the error
System.NullReferenceException: 'Object reference not set to an instance of an object.'
Unfortunately I just don't understand why. Is it not possible to send private messages using a DC ID if the user has not previously interacted with the bot on the DC server? Since I'm currently testing the function on my DC ID and am on the same DC server as the bot, I'm ruling out the problem
how you have it there is correct