如何使用用户ID踢,禁和禁用户

时间:2020-03-20 17:06:47

标签: discord.py

我刚刚学习了如何使用python编写不和谐的机器人。

禁令命令

@bot.command()
async def ban(ctx, member: Member = None, *, reason):
    await member.ban(reason=reason)

踢命令

@bot.command()
async def kick(ctx, member: Member = None, *, reason):
    await member.kick(reason=reason)

取消命令

@bot.command()
async def unban(ctx, *, member):
    banned_users = await ctx.guild.bans()
    member_name, member_discriminator = member.split('#')
    for ban_entry in banned_users:
        user = ban_entry.user

        if (user.name, user.discriminator) == (member_name, member_discriminator):
            await ctx.guild.unban(user)

但是我该如何使用用户ID踢,禁和禁某人?

1 个答案:

答案 0 :(得分:0)

如果成员在服务器上,则可以按ID正常禁止/踢 如果成员不在服务器上,则必须使用await client.fetch_user(ID).ban