Search code examples
pythondiscorddiscord.py

After changing my discord server to Community Server my own bot doesn't work


So when I activated the community server, my commands like on_member_joun() or on_member_remove() stopped working, but when I turned back to the friend server, it worked. The question is next: Do I need to change anything in my bot to make it work?

Simply this command doesn't print hi.

@commands.Cog.listener()
    async def on_member_join(self, member):
        print('hi') 

        self.cursor.execute("SELECT user_id FROM `users` WHERE `user_id` = %s", (member.id,))
        result = self.cursor.fetchone()
        if result is None:
            
            self.cursor.execute("INSERT INTO `users` (`user_id`, `cash`, `lvl`) VALUES (%s, %s, %s)", (member.id, 0, 0))
            print(f"User {member.name} added to the database.")
            connection.commit()

Solution

  • This seems to me like an issue of Privileged Gateway Intents. Make sure your bot has the Server Members Intent enabled. You can read more about discord.py and Privileged Gateway Intents here: https://discordpy.readthedocs.io/en/stable/intents.html