可调用前缀中的Discord.py错误:接受0个位置参数,但给出了2个

时间:2018-09-09 15:53:14

标签: python arguments typeerror discord.py

我正在使用discord.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("---")

1 个答案:

答案 0 :(得分:1)

好像我没有使用重写,这停止了重写中的错误。

只需使用重写来避免这种情况。