因此,我尝试在Discord.Py Rewrite中使用Cogs,得到了以下错误消息:
"C:UsersPCDesktopCodeProject 01index.py", line 410, in <module> File "C:UsersPCDesktopCodeProject 01index.py", line 407, in <module> client.load_extention(cog) AttributeError: 'Bot' object has no attribute 'load_extention' [Finished in 1.6s with exit code 1] [shell_cmd: python -u "C:UsersPCDesktopCodeProject 01index.py"] [dir: C:UsersPCDesktopCodeProject 01] [path: C:Program Files (x86)Common FilesOracleJavajavapath;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:Program Filesdotnet;C:Program Filesnodejs;C:Program FilesGitcmd;C:UsersPCAppDataLocalProgramsPythonPython38Scripts;C:UsersPCAppDataLocalProgramsPythonPython38;C:ffmpegbin;C:UsersPCDesktopherokubin;C:UsersPCAppDataLocalatombin;C:UsersPCDesktopMicrosoft VS Codebin]
我的cog(admin.py(:
import discord from discord.ext import commands
class Admin(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command(aliases=["announce"])
async def say1(self, ctx, *, text):
ctx.send(text)
return print("Cog Loaded")
def setup(client):
client.add_cog(Admin(client))
我的主代码(index.py(:
for cog in os.listdir("./cogs"):
if cog.endswith(".py"):
try:
cog = f"cogs.{cog.replace('.py', '')}"
client.load_extention(cog)
except Exception as e:
print(f"{cog} Can not be loaded")
raise e
有人能帮忙吗?我也需要使用Cogs。(我的Python版本是3.8.5,我的Discord。Python版本是最新的(
我认为你打错了什么,应该是扩展而不是扩展
for cog in os.listdir("./cogs"):
if cog.endswith(".py"):
try:
cog = f"cogs.{cog.replace('.py', '')}"
client.load_extension(cog)
except Exception as e:
print(f"{cog} Can not be loaded")
raise e