Discord bot having not getting message contents when received from a guild

41 views Asked by At

I have a normal discord bot (not a self-bot) in C# using the Discord.NET library. When the bot gets a message, it writes it out in the console:

public static async Task MessageReceivedAsync(SocketMessage message)
    {
        if (message.Author.Id != 1206939510382919700)
        {
            Console.WriteLine(
                $"({DateTime.Now}) {message.Author.Username} ({message.Author.Id}) @ {message.Channel}: {message.Content} ");
            var channel = message.Channel;
            SendReply(channel, message);
        }
    }

And calls a different function that replies to the user:

   public static async Task SendReply(ISocketMessageChannel channel, SocketMessage message) 
    {
        await channel.SendMessageAsync($"Message recieved from {message.Author.Username} in {message.Channel}. Message Content {message.Content}");

    }

Quite simple, but this works well only when the bot is messaged via DM. When the message is in a server that the bot is a part of, it get the message, but the message itself contains everything but the contents, meaning that I can get what channel it was posted in and by who, but not what. the reply should look like this:

Message received from //me in @ //my DM. Message Content: hhh but it looks like this Message received from //me in General. Message Content: I have the Message Content Intent enabled in the Discord Dev Portal. Anyone know what I'm doing wrong?

EDIT: I have the Gateway intent set up. I have a DiscordSocketConfig with the GatewayIntent.MessageContent in the code and I have the Message Content Intent enabled. I even created a new bot and it does the same. The bot can read the content of its own message, however I assume this is intentional and does not require the privileged intent.

0

There are 0 answers