After upgrading my Discord bot from Version 1.7.3 to the new Version 2.3.2, I encountered functionality issues with the bot. My attempts to fix it included switching the intents to discord.Intents.all() and setting intents.message_content to True, but the problem remains. As I'm still learning about Discord bot development, I find it quite challenging to pinpoint the root cause of this malfunction.
Here's my modified code:
import discord from discord.ext import commands from decouple import config
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix=‘!’, intents=intents)class RoleHandler(commands.Cog):
def init(self, bot):
self.bot = bot@commands.Cog.listener() async def on_reaction_add(self, reaction, user): message_id = reaction.message.id guild = reaction.message.guild if user.bot: return member = guild.get_member(user.id) if message_id == SOME_MESSAGE_ID: role = None if str(reaction.emoji) == '👥': role = guild.get_role(ROLE_ID) elif str(reaction.emoji) == '📢': role = guild.get_role(ROLE_ID) elif str(reaction.emoji) == '📖': role = guild.get_role(ROLE_ID) if role: await member.add_roles(role) elif message_id == OTHER_MESSAGE_ID: role = None if str(reaction.emoji) == '🎮': role = guild.get_role(ROLE_ID) elif str(reaction.emoji) == '💻': role = guild.get_role(ROLE_ID) elif str(reaction.emoji) == '🎨': role = guild.get_role(ROLE_ID) if role: await member.add_roles(role)
bot.add_cog(RoleHandler(bot))
TOKEN = config(‘TOKEN’)
bot.run(TOKEN)
Despite modifying the code to include intents = discord.Intents.all() and intents.message_content = True, the bot continues to malfunction, which is quite frustrating.