Reputation: 137
I want to develop a discord bot. After trying the bot on my Raspberry Pi, I cannot read messages of the bot on the guilds. On the Raspberry Pi the program is working without any problems. Obviously I turned the pi off before starting the bot. I already tried kicking and reconnecting the bot on the servers, but that didn`t work. Private messages to the bot are running smoothly. The messages are blank, so the event is called, but nothing is printed to the command line.
import discord
from discord.ext import commands
bot = commands.Bot()
@bot.event
async def on_message(message):
print(message.content)
bot.run("TOKEN")
The content of the message variable is (I have changed the ids and some other variables):
<Message id=953328581969116272 channel=<TextChannel id=956654537448771667 name='general' position=0 nsfw=False news=False category_id=953322537446663665> type=<MessageType.default: 0> author=<Member id=689200156665367842 name='my_name' discriminator='0000' bot=False nick=None guild=<Guild id=953322535556471664 name='Test' shard_id=0 chunked=False member_count=2>> flags=<MessageFlags value=0>>
I`ve found an open github problem, but because discord.py is not continued I have to ask it here. (The link: https://github.com/Rapptz/discord.py/issues/6820)
Upvotes: 1
Views: 1428
Reputation: 1606
From October 25, 2021, accessing message content now requires enabling a new privilege intent.
Head to your developer portal and do this.
Applications ↦ Settings ↦ Bot ↦ Privileged Gateway Intents
Upvotes: 1
Reputation: 231
Switching back to API version 9 has solved the issue for me.
I've encountered the same issue and found the solution in the official Pycord Discord. They have switched to the Discord API version 10 where message content has become a privileged intent in accordance with the new upcoming Discord changes (Message Content: Privileged Intent for Verified Bots).
In short, if your bot is in more than 75 servers you will need to verify it in order to access privileged intents.
Here's Pycord's detailed post for reference
Dated 20/03/2022
Hello @v2.0 Testers, Along with https://github.com/Pycord-Development/pycord/pull/1012, pycord has switched to API version 10. This version introduces a new privileged intent: message content. Bots that use the master branch of pycord need to turn this intent on in order to receive message contents and invoke prefixed commands. However if you don't want to switch to v10, you can change the API version back to 9 (https://github.com/Pycord-Development/pycord/pull/1032)
Turn the intent on:
bot = commands.Bot(..., intents=discord.Intents(message_content=True))
Switch back to API version 9:
discord.http.API_VERSION = 9 bot = commands.Bot(...)
See https://support-dev.discord.com/hc/en-us/articles/4404772028055 for more information about the intent.
This is the link to their Discord server. I would have not found the solution without being part of it. https://discord.gg/sb5zZYnz
Upvotes: 3
Reputation: 321
Discord.py is back to development again, you should use it. You can ask these question in the discord.py Discord server and get quick response other than asking it at here!
Have fun coding!
Upvotes: 0