在禁止Discord房间的成员时,我想向reason
命令添加可选的+kick
消息。我的尝试代码如下。
命令和示例用法:
+kick <username> <reason>
+kick @Pine#1337 Spamming Messages in Wrong Channel.
代码:
@bot.command(pass_context=True)
async def kick(ctx, user: discord.Member, *, arg, reason):
author = ctx.message.author
data = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
embed = discord.Embed(name="MEMBER_KICKED", description="------------------------------------------------------", color=0x00ff00)
embed.set_author(name="MEMBER_KICKED:\nMember Kicked Successfully")
embed.add_field(name="Kicked by: ", value="{}".format(author.mention), inline=False)
embed.add_field(name="Kicked: ", value="<@{}>".format(user.id), inline=False)
embed.add_field(name="Reason: ", value="{}\n------------------------------------------------------".format(arg), inline=False)
embed.set_footer(text="Requested by {} \a {}".format(author, data), icon_url=author.avatar_url)
await bot.say(embed=embed)
channel = discord.utils.get(user.server.channels, name="logs")
embed = discord.Embed(name="MEMBER_KICKED", description="------------------------------------------------------", color=0xff0000)
embed.set_author(name="MEMBER_KICKED:\nMember Kicked")
embed.add_field(name="Kicked by: ", value="{}".format(author.mention), inline=False)
embed.add_field(name="Kicked: ", value="<@{}>".format(user.id), inline=False)
embed.add_field(name="Reason: ", value="{}\n------------------------------------------------------".format(arg), inline=False)
embed.set_footer(text="Kicked at {}".format(data))
await bot.send_message(channel, embed=embed)
if user.bot == False:
embed = discord.Embed(name="KICKED", description="------------------------------------------------------", color=0xff0000)
embed.set_author(name="KICKED:\nYou've been Kicked")
embed.add_field(name="Kicked by: ", value="{}".format(author.mention), inline=False)
embed.add_field(name="Kicked in: ", value="{}".format(user.server), inline=False)
embed.add_field(name="Reason: ", value="{}\n------------------------------------------------------".format(arg), inline=False)
embed.set_footer(text="Kicked at {}".format(data))
await bot.send_message(user, embed=embed)
if user.bot == True:
pass
reason = arg
await bot.kick(user, reason=reason)
错误:
TypeError:kick()缺少1个必需的1个仅关键字参数'reason'
答案 0 :(得分:0)
只需删除 public int ValidateData()
{
foreach (Control cont in GB_PatientInfo.Controls)
{
if (cont is TextBox)
{
if (string.IsNullOrWhiteSpace(cont.Text.Trim()))
{
MessageBox.Show("enter data " + cont.Tag, "Message", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
cont.BackColor = Color.Red;
cont.Focus();
return -1;
}
}
}
return 1;
}
参数
您踢踢的原因陷入reason
arg
答案 1 :(得分:0)
在冻结了异步分支功能之后,Discord引入了禁令/踢的原因。它们仅存在于discord.py-rewrite分支上。那里有一个关键字参数:
@bot.command()
async def kick(ctx, user: discord.Member, *, reason):
await user.kick(reason=reason)