随着我的机器人变得越来越大,我正在尝试实现齿轮,但是我遇到了一个问题。我已经设置并准备好我的整个代码,但由于某种奇怪的原因,我不断收到此错误:
Traceback (most recent call last):
File "C:\Users\Lauras\Desktop\Akagi Bot\main.py", line 107, in <module>
bot.add_cog("cogs.fun")
File "C:\Users\Lauras\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\bot.py", line 477, in add_cog
raise TypeError('cogs must derive from Cog')
TypeError: cogs must derive from Cog
我在 main.py 上的代码如下所示:
import discord
import asyncio
import typing
import random
import json
import oauth
from discord.ext import commands
bot = commands.Bot(command_prefix='~')
@bot.event
async def on_ready():
await bot.change_presence(activity=discord.Activity(name='with Kaga :3',type=0))
print (discord.__version__)
print(f"{bot.user.name} - {bot.user.id}")
print ('Akagi is ready to serve the Commander :3 !')
bot.add_cog("cogs.fun")
bot.run(oauth.bot_token)
“有趣”的齿轮如下:
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix='~')
class FunCog:
def __init__(self, bot):
self.bot = bot
@commands.command()
async def hug(self, ctx):
await ctx.send('has been hugged by', file=discord.File('iloveyou.gif'))
pass
def setup(bot: commands.Bot):
bot.add_cog(FunCog(bot))
可能是什么问题呢?我也在使用 discord.py 重写。谢谢 !
一只斗牛犬
至尊宝的传说
相关分类