【发布时间】:2021-02-13 12:33:55
【问题描述】:
我目前正在尝试构建一个 discord.py 静音命令,该命令发送一个嵌入询问用户是否确定要静音,然后在添加反应时执行静音并编辑嵌入。我在尝试这样做时遇到了一些错误。
@bot.command()
@commands.has_permissions(manage_guild=True)
async def mute(ctx, message, member: discord.Member = None):
guild = ctx.guild
user = member
if member == None:
await ctx.send(f'**{ctx.message.author},** please mention somebody to mute.')
return
if member == ctx.message.author:
await ctx.send(f'**{ctx.message.author},** you cannot mute yourself, silly.')
return
for role in guild.roles:
if role.name == "Muted":
if role in user.roles:
await ctx.send("**{}** is already muted.".format(user))
return
embedcheck=discord.Embed(title="Mute", colour=0xFFD166, description=f'Are you sure you want to mute **{user}?**')
embeddone=discord.Embed(title="Muted", colour=0x06D6A0,description=f'The mute has been done. **{user}** cannot talk in any channels anymore.')
embedfail=discord.Embed(title="Not Muted",colour=0xEF476F,description=f'The mute did not carry out as I did not receive a reaction in time.')
msg = await ctx.send(embed=embedcheck)
await message.add_reaction('✅','❌')
try:
def check(rctn, user):
return user.id == ctx.author.id and str(rctn) == '✅'
reaction, user = await bot.wait_for('reaction_add', timeout=60.0, check=check)
except asyncio.TimeoutError:
await msg.edit(embed=embedfail)
else:
for role in guild.roles:
if role.name == "Muted":
await member.add_roles(role)
await msg.edit(embed=embeddone)
当我运行命令时,我总是得到相同的输出,“...请提及某人静音,”即使我提到了某人。当我不提及任何人时,我会收到错误
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: message is a required argument that is missing.
【问题讨论】:
标签: python command discord discord.py discord.py-rewrite