代码之家  ›  专栏  ›  技术社区  ›  Денис Піддубний

在将我的discord服务器更改为Community server后,我自己的机器人无法工作

  •  0
  • Денис Піддубний  · 技术社区  · 2 年前

    因此,当我激活社区服务器时,我的命令,如on_member_joun()或on_member_remove()停止工作,但当我返回到朋友服务器时,它可以工作。接下来的问题是,我需要改变什么才能让我的机器人正常工作

    简单地说,这个命令不会打印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()
    
    1 回复  |  直到 2 年前
        1
  •  1
  •   AwesomeBFM    2 年前

    在我看来,这就像是一个特权网关意图的问题。确保您的机器人已启用服务器成员意向。您可以在此处阅读更多关于discord.py和Privileged Gateway Intents的信息: https://discordpy.readthedocs.io/en/stable/intents.html