【问题标题】:in discord.py How can i make my bot that the commands only can be use in specific channel or specific server?在 discord.py 我怎样才能让我的机器人命令只能在特定通道或特定服务器中使用?
【发布时间】:2022-07-16 03:45:24
【问题描述】:

所以,任何人都可以邀请我的个人机器人到他们的服务器。所以,我希望该命令可以在特定频道或特定服务器上使用 @bot.event 而不是客户端。

【问题讨论】:

    标签: javascript python discord


    【解决方案1】:

    如果你使用await bot.process_commands(message),你可以试试这个

    @bot.event
    async def on_message(message):
        if message.channel.id == yourchannelid:
            await bot.process_commands(message)
        
        if message.guild.id = yourguildid:
            await bot.process_commands(message)
    
    

    您可以在 on_message 中添加检查,这样机器人就不会回复自己

    【讨论】:

      猜你喜欢
      • 2018-10-23
      • 1970-01-01
      • 2020-11-17
      • 2022-11-11
      • 2019-10-17
      • 2011-08-09
      • 1970-01-01
      • 2021-04-06
      • 2012-12-24
      相关资源
      最近更新 更多