【问题标题】:discord.py: Is there anything that could be making it where kick/ban commands don't work?discord.py:有什么东西可以使它在踢/禁止命令不起作用的地方吗?
【发布时间】:2021-04-24 04:34:04
【问题描述】:

我正在尝试编写 Discord 机器人,并且我想添加命令,以便具有踢/禁止权限的人可以使用踢/禁止命令。我添加了许多不同形式的踢和禁止命令,但它们都不能正常工作。我绝对肯定踢/禁止命令是正确的。我开始觉得我的其余代码有问题,导致踢/禁止命令不起作用。

这是我目前拥有的:

from discord.ext import commands
import os
from dotenv import load_dotenv
import logging


# Enables logging
logger = logging.getLogger('discord')
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler)


# Assigns the Discord client to a variable called client
client = commands.Bot(command_prefix='$')


# Loads .env
load_dotenv()


# Prints a message stating that the bot is loggen in
@client.event
async def on_ready():
    print('Logged in as {0.user}'.format(client))

# Prints the help message when a user says $help
@client.event
async def on_message(message):
    if message.content.startswith('$help'):
        await message.channel.send('''**Hydra Help**
*This message contains a list of commands and what they do.*

__help__: Prints this message.''')


# Starts the bot
client.run(os.getenv('TOKEN'))

到目前为止,我的代码是否有任何问题可能导致踢/禁止命令不起作用?

【问题讨论】:

标签: python discord bots discord.py


【解决方案1】:

你必须这样做:

踢:

await ???(For example member or ctx.author).kick(reason=???)

禁止:

await ???(For example member or ctx.author).ban(reason=???)

【讨论】:

    猜你喜欢
    • 2021-01-15
    • 2018-10-14
    • 2020-11-18
    • 2020-10-15
    • 2021-09-16
    • 2010-11-07
    • 2021-07-27
    • 2019-07-23
    • 2020-10-20
    相关资源
    最近更新 更多