您必须放置
awaitbot.process_commands(message)在
if语句范围之外,
process_command无论消息是否以“ /
lockdown”开头,都应运行。
@bot.eventasync def on_message(message): if message.content.startswith('/lockdown'): ... await bot.process_commands(message)顺便说一下,
@commands.has_role(...)不适用于
on_message。尽管没有任何错误(因为已经进行了检查),
has_role但实际上并没有按您期望的那样工作。
@has_role装饰器的替代方法是:
@bot.eventasync def on_message(message): if message.channel.is_private or discord.utils.get(message.author.roles, name="Admin") is None: return False if message.content.startswith('/lockdown'): ... await bot.process_commands(message)


