I upgraded my Discord bot from discord.py version 1.7.3 to 2.3.2 and now the role assignment feature stopped working. I tried fixing it by adding discord.Intents.all() and enabling intents.message_content = True but nothing changed. I’m pretty new to this stuff and can’t figure out what went wrong.
Here’s my current code:
import discord
from discord.ext import commands
from decouple import config
intents = discord.Intents.default()
intents.members = True
client = commands.Bot("?", intents=intents)
class RoleManager(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_raw_reaction_add(self, data):
msg_id = data.message_id
server_id = data.guild_id
reaction = data.emoji
server = self.client.get_guild(server_id)
user = server.get_member(data.user_id)
if msg_id == YOUR_MESSAGE_ID:
target_role = None
if str(reaction) == "🔥":
target_role = server.get_role(ROLE_ID_HERE)
elif str(reaction) == "⚡":
target_role = server.get_role(ROLE_ID_HERE)
elif str(reaction) == "🌟":
target_role = server.get_role(ROLE_ID_HERE)
if target_role is not None:
await user.add_roles(target_role)
elif msg_id == ANOTHER_MESSAGE_ID:
selected_role = None
if str(reaction) == "🎯":
selected_role = server.get_role(ROLE_ID_HERE)
elif str(reaction) == "🚀":
selected_role = server.get_role(ROLE_ID_HERE)
elif str(reaction) == "🎪":
selected_role = server.get_role(ROLE_ID_HERE)
if selected_role is not None:
await user.add_roles(selected_role)
client.add_cog(RoleManager(client))
TOKEN = config("TOKEN")
client.run(TOKEN)
I expected that setting all intents would fix any permission issues from the version upgrade but the bot still doesn’t assign roles when people react to messages. What am I missing here?