Python Discord Bot-限制命令仅用于1次聊天



所以我有这个命令,我只想在1次聊天中使用。我该如何限制它在名为"普通"的聊天之外的其他聊天中工作。我得到了其他需要在所有聊天中工作的命令,所以我不能只是限制机器人的排列。

您可以编写自己的check:

from discord.ext import commands
bot = commands.Bot("!")
def in_channel(*channels):
def predicate(ctx):
return ctx.channel.id in channels
return commands.check(predicate)
@in_channel(channel_id)
@bot.command()
async def command_name(ctx, ...):
...
bot.run("token")

最新更新