【问题标题】:Ban command on message discord.py禁止消息 discord.py 上的命令
【发布时间】:2021-05-11 20:57:05
【问题描述】:
import discord
from discord.ext import commands

client = commands.Bot(command_prefix='sk?')

token = ""

@client.event
async def on_message():
    if 'WORD' in message.content:
        await member.ban(reason = WORD)

client.run(token)

我收到错误“接受 0 个位置参数,但给出了 1 个”,我不知道我的代码有什么问题。

我尝试在if 'WORD' in message.content:上方添加on_message(member):member = message.author()

我不知道该做什么或我做错了什么。

它还说对于所有非常烦人的消息。

【问题讨论】:

  • message.content中的message从何而来?

标签: python discord.py


【解决方案1】:

on_message 接受消息参数,member 也应该是 message.author

@client.event
async def on_message(message):
    if "WORD" in message.content:
        await message.author.ban(reason="WORD")

    # Remember to add `process_commands`
    await client.process_commands(message)

您还应该在事件结束时添加process_commands,以便命令正常工作

【讨论】:

    猜你喜欢
    • 2018-11-07
    • 1970-01-01
    • 2020-05-26
    • 1970-01-01
    • 2021-04-06
    • 2021-09-26
    • 1970-01-01
    • 2019-10-17
    • 2021-03-01
    相关资源
    最近更新 更多