0

So basically I want to do a report command for my discord bot, because I know I'm not perfect and others may discover a problem with it that I may don't

[Command("report")]
        public async Task Report([Remainder]string report = null)
        {
            ulong id = 206884438972301312;
            DiscordSocketClient client = new DiscordSocketClient();
            await client.GetUser(id: id).SendMessageAsync(report);
        }

But when I run the command it doesn't work and says that the object is not set to an instance

result.ErrorReason = "Object reference not set to an instance of an object."

MBence
  • 21
  • 1
  • You cannot instantiate a new client an use it to retrieve data via the API. That client is not connected to the gateway (not logged in) and so will not be able to retrieve anything. Get user is returning null and so SendMessageAsync fails. I hate when they just close everything as null ref duplicate..... instead of creating a new client, use `Context.Client` – Anu6is Feb 04 '20 at 19:29
  • Thank you I was really struggling with this one – MBence Feb 06 '20 at 18:47

0 Answers0