我是Python新手,刚刚发现一个无法解决的错误:
TypeError: 'Group' object is not callable
@commands.group(pass_context=True, no_pm=True) async def online(self, ctx): //Some stuff @commands.group(pass_context=True, no_pm=True) async def searching(self, ctx): await self.online(ctx)
我要做的是用一个旧名称重命名并废弃一个函数,然后用新名称('online'>'search')引入它。
你可以用 invoke 方法 Group
invoke
Group
from discord.ext import commands bot = commands.Bot(command_prefix='!') @bot.group(pass_context=True) async def online(ctx): await bot.send_message(ctx.message.channel, "Group invoked") @bot.command(pass_context=True) async def invoker(ctx): await online.invoke(ctx) bot.run("Token")