机器人在装载齿轮时崩溃。弹出的错误消息如下:
traceback (most recent call last):
File "C:\Users\[REDACTED]\AppData\Local\Programs\Python\Python36\lib\site-packages\
discord\ext\commands\bot.py", line 621, in load_extension
lib = importlib.import_module(name)
File "C:\Users\[REDACTED]\AppData\Local\Programs\Python\Python36\lib\importlib\__in
it__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'cogsTest'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "bot.py", line 15, in <module>
client.load_extension(f'cogs{filename[:-3]}')
File "C:\Users\[REDACTED]\AppData\Local\Programs\Python\Python36\lib\site-packages\
discord\ext\commands\bot.py", line 623, in load_extension
raise errors.ExtensionNotFound(name, e) from e
discord.ext.commands.errors.ExtensionNotFound: Extension 'cogsTest' could not be
loaded.
该漫游器主要代码的Part 是:
import discord
from discord.ext import commands
import os
client = commands.Bot(command_prefix = '!')
@client.event
async def on_ready():
await client.change_presence(status=discord.Status.online, activity=discord.Game('on standby'))
print('Bot is online.')
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
client.load_extension(f'cogs{filename[:-3]}')
齿轮是基本的,仅用于测试齿轮是否已正确读取。齿轮的代码为:
import discord
from discord.ext import commands
class Test(commands.Cog):
def __innit__(self, client):
self.client = client
@commands.command()
async def check(self, ctx):
await ctx.send('TESTING!')
def setup(client):
client.add_cog(Test(client))