不和谐.py可调用前缀出错:接受0个位置参数,但给出了2个

2024-05-18 06:53:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我用的是不和谐.py图书馆和我正在尝试做一个可调用的前缀。 但是,每当发布消息时,我都会遇到此错误。 prefix_callable函数应该返回两个可能的前缀,但它会抛出一个错误。你知道吗

TypeError: prefix_callable() takes 0 positional arguments but 2 were given

也许这是一个愚蠢的错误,但我对Python还不熟悉,不能理解这个错误。谢谢您!你知道吗

代码如下:

import discord
from discord.ext import commands
import asyncio
import json
import bot_modules
from bot_modules import misc
import Utilities
from Utilities import manageDataStores
botconfigf = open("./Utilities/botconfig.json", "r")
botconfig = json.load(botconfigf)

def prefix_callable(bot, message):
    return "!", "@()"

client = commands.Bot(command_prefix = prefix_callable, case_insensitive = True)

@commands.command
async def info (ctx):
    await ctx.send("ayy")

@client.event
async def on_ready():
    print("ADAB is online!")

client.run("---")

Tags: fromimportclientmodulesjsonprefixdefbot