'printing bot messages discord.py
Are there any changes in discord.py ? Since yesterday my bots doesnt work.
They were supposed to mention someone when another bot writes someting
async def on_message(message):
if message.author.id == 123456789: #any bot ID
if message.content.startswith(
"Alright"): #message
await message.channel.send("<@123213213321231> look")
print("Done")
I tried to print messages from specific channel to see if there are any changes in bots messages but i cant even print them..
async def on_message(message):
if message.channel.id == 123456789:
print(message.content)
Carlbot for example - it prints my messages but carlbot messages are blank space...
abc
!lock
!unlock
?remindme 1min blahblah
I didnt change anything it was working for over a month and suddenly it doesnt and i have no idea why.
Solution 1:[1]
Do you have intents enabled?
(from d.py server!)
What are intents?
As of 2020-10-28, discord requires users declare what sort of information (i.e. events) they will require for their bot to operate. This is done in the form of intents. You can read more about intents here: https://discordpy.readthedocs.io/en/latest/intents.html
By default some intents such as members and presences are disabled as they are what is referred to as privileged. Meaning you'll need to take some extra steps to support them. Read up on privileged intents here: https://discordpy.readthedocs.io/en/latest/intents.html#privileged-intents
If you use on_member_* events in your code, without changes your bot will not function anymore!
Steps on how to enable them:
1 - in code
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix=...., intents=intents)
2 - on discord developer portal applications > yourApplication > bot > scroll down then check these https://imgur.com/a/oE7LrIa (only ones you need!)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ammarsys |
