我正在discord.py中制作一个discord机器人,该机器人可以踢出发送特定字符串的任何成员,但是却收到错误消息“ discord.errors.ClientException:命令踢已被注册。”
LogManager.Configuration.LoggingRules
我得到了这个可爱的回溯,而不是踢成员:
bot = commands.Bot(command_prefix=',')
@client.event
async def on_message(message):
if message.author == client.user:
return
if "kick me"in message.content:
@bot.command(name="kick", pass_context=True)
@has_permissions(kick_members=True)
async def _kick(ctx, member: Member):
await bot.kick(member)
答案 0 :(得分:0)
无论何时发送消息!kick me
,您都将重新注册该命令。该命令应位于脚本或齿轮的顶层,而不是在每次调用事件时都重新创建。
bot = commands.Bot(command_prefix=',')
@bot.event
async def on_message(message)
...
await bot.process_commands(mesage)
@bot.command(name="kick", pass_context=True)
@has_permissions(kick_members=True)
async def _kick(ctx, member: Member):
await bot.kick(member)