【发布时间】:2020-06-03 20:17:30
【问题描述】:
我有一个正常的命令,但我得到这个错误:Command "leave" is not found。这是我的代码:
我之前用过reaction-script,所以我知道不是这样的。
@bot.command
async def leave(ctx):
user1 = await bot.fetch_user(ctx.message.author.id)
message = await ctx.send(f"Are you sure that you want to leave {ctx.message.guild}, {ctx.message.author.mention}? React within 30 seconds to verify")
for emoji in ('✅'):
await message.add_reaction(emoji)
try:
def check(rctn, user):
return user.id == ctx.author.id and str(rctn) == '✅'
rctn, user = await bot.wait_for("reaction_add", check=check, timeout=30)
member = ctx.message.author
await member.kick()
user = bot.get_user(ctx.message.author.id)
link = await ctx.channel.create_invite(unique=True, max_uses=1)
await user.send(f'You left {ctx.message.guild}! But you can rejoin via {link}')
except asyncio.TimeoutError:
await ctx.send(f"**Error:** Not reacted in time")
有人看到错误吗?我似乎找不到它,我认为它应该可以工作。
【问题讨论】:
-
它是
bot.command()(缺少圆括号)。同时提供完整的错误日志。
标签: python-3.x discord discord.py discord.py-rewrite