(discord.py)为什么我的kick命令不起作用?

时间:2020-10-19 13:00:47

标签: python discord discord.py

@model MojeIdentita.Models.ModShopView
@using MojeIdentita.Helpers
@{
    string lang = (string)ViewContext.RouteData.Values["lang"] ?? "cz";
    ViewData["Title"] = Html.GetLangResourceHtml(lang, "menuShop", true);

}

<h1 class="text-left" role="heading" aria-level="1">@Html.GetLangResourceHtml(lang, "menuShop", true)</h1>
<div class="">
    <div>
        @Html.Raw(Model.Description.FirstOrDefault().Part1)
    </div>


    @using (Html.BeginForm())
    {
        @foreach (var Polozky in Model.EshopItems)
        {

            <div class="row">
                <div class="col-md-3 col-sm-6 col-xs-12 city"><p>@Polozky.NazevZbozi</p></div>
                <div class="col-md-3 col-sm-6 col-xs-12"><p>@Polozky.Vat</p></div>
                <div class="col-md-3 col-sm-6 col-xs-12"><p>@Polozky.Cena</p></div>
                <div class="col-md-3 col-sm-6 col-xs-12"><p><input type="text" id="inputpocet" name="@Polozky.IdZbozi" /></p></div>
            </div>

        }
        <input type="submit" value="@Html.GetLangResourceHtml(lang, "txtObjednat", true)" class="order" />
    }

    </div>


我有我的@client.command @commands.has_permissions(kick_members=True) async def kick(ctx, member: discord.Member, *, reason = None): await member.kick(reason=reason) await ctx.send(f'{member} Has been kicked') 事件,

on_command_error

然后我收到不一致的错误消息

discord.py 1.5版

2 个答案:

答案 0 :(得分:0)

@commands.has_permissions(kick_members=True)
@client.command()
async def kick(ctx, user: discord.Member, *, reason="No reason provided"):
        await user.kick(reason=reason)
        kick = discord.Embed(title=f":boot: Kicked {user.name}!", description=f"Reason: {reason}\nBy: {ctx.author.mention}")
        await ctx.message.delete()
        await ctx.channel.send(embed=kick)
        await user.send(embed=kick)

这行吗?

答案 1 :(得分:0)

@client.command()
@commands.has_permissions(kick_members=True)
async def kick(ctx, member: typing.Optional[discord.Member], arg = None):
    if arg == None:
        await ctx.send("Kicked " + member.mention + ".")
    else:
        await ctx.send("Kicked " + member.mention + " for " + arg + ".")
    await ctx.guild.kick(member)

这应该有效。