【问题标题】:Discord Bot cannot Kick/Ban membersDiscord Bot 不能踢/禁止成员
【发布时间】:2020-12-05 04:43:32
【问题描述】:

我制作的 discord bot 中的 kick 命令不起作用。我使用“-kick @user”命令来做到这一点。但它什么也没做。没有错误,什么都没有。

import discord 
from discord.ext import commands

client = commands.Bot(command_prefix='-')

@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'User {member} has been kicked')
client.run('Token')

【问题讨论】:

    标签: discord.py


    【解决方案1】:

    因为memberNone,您必须启用intents.members 才能工作:

    intents = discord.Intents.default()
    intents.members = True
    
    client = commands.Bot(command_prefix='-', intents=intents)
    

    还要确保在 developer portal 中启用它们

    docs

    【讨论】:

    • 我已将所有管理员权限授予 BOT 和我自己。还有其他解决方案吗?
    • 没有错误。就是行不通。我添加的所有其他功能都完美无缺。
    • 好吧,我复制了你的代码,它对我来说很好用,你有on_message 事件吗?
    • 是的,我有。
    • 最后有await client.process_commands(message)吗?
    猜你喜欢
    • 2022-01-04
    • 1970-01-01
    • 2021-04-20
    • 1970-01-01
    • 2021-08-11
    • 2021-07-19
    • 2021-02-15
    • 2020-08-19
    • 2021-09-20
    相关资源
    最近更新 更多