Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
368 views
in Technique[技术] by (71.8m points)

python - Discord.py Cogs : Extension is not defined

Hi in my code for a Python Discord bot i started to try some Cogs. But somehow when I run the code i get the Error that Extension is not defined but in the Toturial i watched he never defined Extension.

extensions = ['cogs.postgres']
if __name__ == "__main__":
    for extensions in extensions:
        try:
            bot.load_extension(extension)
        except Exception as e:
            print(f'Error loading {extension}', file=sys.stderr)
            traceback.print_exc()

The Exact Error is : "NameError: name 'extension' is not defined" Can someone help me?I googled that error but did not found anything to cogs Extensions is not defined.

question from:https://stackoverflow.com/questions/65889520/discord-py-cogs-extension-is-not-defined

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You're in fact not defining extension, fix:

for extension in extensions:

I think you simply miscopied


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...