Python 3.x 正在尝试在discord.py中运行多个齿轮。只有一个功能

Python 3.x 正在尝试在discord.py中运行多个齿轮。只有一个功能,python-3.x,bots,discord.py-rewrite,Python 3.x,Bots,Discord.py Rewrite,我在制造一个不和谐的机器人。我正在尝试制作两个齿轮:一个乒乓齿轮和一个神奇的8球齿轮。 乒乓球很好用,但当我指挥8球时,我得到以下错误: 忽略命令None中的异常: discord.ext.commands.errors.CommandNotFound:未找到命令“eightball” 以下是与问题相关的代码部分: 基地机器人: @rat.command() async def load(ctx, extension): rat.load_extension(f'Cogs.{ex

我在制造一个不和谐的机器人。我正在尝试制作两个齿轮:一个乒乓齿轮和一个神奇的8球齿轮。 乒乓球很好用,但当我指挥8球时,我得到以下错误:

忽略命令None中的异常: discord.ext.commands.errors.CommandNotFound:未找到命令“eightball”

以下是与问题相关的代码部分:

基地机器人:

@rat.command()
async def load(ctx, extension):
        rat.load_extension(f'Cogs.{extension}')

@rat.command()
async def unload(ctx, extension):
        rat.unload_extension(f'Cogs.{extension}')

for filename in os.listdir('./Cogs'):
        if filename.endswith('.py'):
                rat.load_extension(f'Cogs.{filename[:-3]}')
乒乓球中心:

import os

import discord
from discord.ext import commands

class Pong(commands.Cog):
    def __init__(self, rat):
        self.rat = rat


@commands.command()
async def ping(self, ctx):
    await ctx.send('Pong!')

def setup(rat):
    rat.add_cog(Pong(rat))
失败的8球重心:

import os
import random
import discord
from discord.ext import commands



class Fortune(commands.Cog):
    def __init__(self, rat):
        self.rat = rat


@commands.command(aliases=['8B', '8ball', '8Ball'])
async def eightball(self, ctx, *, question):
        responses = ['It is decidedly so.',
                     'Without a doubt.',
                     'Yes, definitely.',
                     'As I see it, yes.',
                     'Most likely.',
                     'Signs point to yes.',
                     'Reply hazy, try again.',
                     'Ask again, later.',
                     'Better not tell you now.',
                     'Cannot predict now.',
                     'Concentrate and ask again.',
                     'Do not count on it.',
                     'My reply is no.',
                     'My sources say no.',
                     'Outlook not so good.',
                     'I doubt it.']
        await ctx.send(f'Question: {question}\nAnswer: {random.choice(responses)}')

def setup(rat):
    rat.add_cog(Fortune(rat))

您的eightball函数应缩进到Fortune类中:

import os
import random
import discord
from discord.ext import commands



class Fortune(commands.Cog):
    def __init__(self, rat):
        self.rat = rat


    @commands.command(aliases=['8B', '8ball', '8Ball'])
    async def eightball(self, ctx, *, question):
            responses = ['It is decidedly so.',
                         'Without a doubt.',
                         'Yes, definitely.',
                         'As I see it, yes.',
                         'Most likely.',
                         'Signs point to yes.',
                         'Reply hazy, try again.',
                         'Ask again, later.',
                         'Better not tell you now.',
                         'Cannot predict now.',
                         'Concentrate and ask again.',
                         'Do not count on it.',
                         'My reply is no.',
                         'My sources say no.',
                         'Outlook not so good.',
                         'I doubt it.']
            await ctx.send(f'Question: {question}\nAnswer: {random.choice(responses)}')

def setup(rat):
    rat.add_cog(Fortune(rat))


你是我的英雄!!非常感谢。