【问题标题】:Limit commands to one channel discord.py将命令限制为一个通道 discord.py
【发布时间】:2020-07-07 16:55:43
【问题描述】:

如何将命令限制为一个通道?这就是我所拥有的。当我使用该命令时,它说该命令已正确调用,但它没有发送消息。

@commands.group(name = "pic", invoke_without_command=True, ignore_extra=False)
    async def picture(self, ctx, *args):
        if ctx.channel == ("bot-test"):
            await ctx.send("pic")

【问题讨论】:

    标签: discord.py


    【解决方案1】:

    您需要比较频道的name 属性,而不是Channel 对象本身:

    @commands.group(name = "pic", invoke_without_command=True, ignore_extra=False)
    async def picture(self, ctx, *args):
        if ctx.channel.name == ("bot-test"):
            await ctx.send("pic")
    

    【讨论】:

      猜你喜欢
      • 2020-06-15
      • 2018-12-02
      • 2021-09-01
      • 2021-11-13
      • 1970-01-01
      • 1970-01-01
      • 2021-04-16
      • 2012-08-08
      相关资源
      最近更新 更多