如何阻止我的机器人滥发discord.py

2024-10-01 19:19:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在做一个设置命令。一切正常,但命令会垃圾邮件而不是发送一次

@kara.command()
async def setup(ctx):
        guild = ctx.guild
        await ctx.message.delete()
        await guild.create_role(name=silenced, permissions = discord.Permissions(send_messages=False), reason=f"Invoked by {ctx.author}")
        role = discord.utils.get(guild.roles, name = "Silenced")
        for chan in guild.channels:
            await chan.set_permissions(silenced, send_messages=False)
            setup=discord.Embed(title="Kara's setup", color=c.teal(), url=rick_roll, description="If the setup goes wrong make sure I have the correct permissions!")
            setup.add_field(name="Silenced Role", value="Setting up my own muted role...")
            msg = await ctx.send(embed=setup)
            
            setup2=discord.Embed(title="Kara's setup", color=c.teal(), url=rick_roll, description="If the setup goes wrong make sure I have the correct permissions!")
            setup2.add_field(name="Silenced Role", value="Setting up my own muted role...")
            setup2.add_field(name="Coming Soon...", value="Currently this is all to the setup soo... yea")
            msg = await ctx.send(embed=setup)
            await asyncio.sleep(3.4)
            await msg.edit(embed=setup2)

它只是垃圾邮件的设置,我已尝试将发送移动到外部的for,但它没有工作任何帮助


Tags: thenamesendaddpermissionsfieldvaluesetup
1条回答
网友
1楼 · 发布于 2024-10-01 19:19:05

您应该在await msg.edit(embed=setup2)下添加一个break

编辑:另一个原因可能是on_message事件未命中await bot.process_commands(message)。请注意,这应该与async def on_message(msg):的缩进匹配。只需确保在活动结束时添加

相关问题 更多 >

    热门问题