#๐Ÿ”’ load extension help

37 messages ยท Page 1 of 1 (latest)

tulip slateBOT
#

@weary ridge

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

main heron
#

use .listen('on_message') instead of .event

you're processing commands anyway

#

also dont print your exceptions

weary ridge
#

it was for debugging perposes

main heron
#

ah wait, you're not awaiting your task

#

i suggest subclassing Bot and overriding setup_hook instead of having a separate function for it all

#

read my last two messages

weary ridge
weary ridge
#

also just to make sure

#

ill send my main again

main heron
#

again, subclassing and overriding would be better

weary ridge
#

if theres any changes needed

main heron
#

yeah i'd change a few things:

  1. use Bot.run() instead of async with Bot and Bot.start()
  2. remove the on_message handler, since it doesn't do anything
  3. don't pass on generic exceptions
  4. merge setup_hook and load_extensions
  5. override the __init__ to add its own args to the super().__init__() instead of needing to pass your own
weary ridge
main heron
# main heron yeah i'd change a few things: 1. use `Bot.run()` instead of `async with Bot` an...

something like: ```py
from discord import Intents
from discord.ext.commands import Bot
from pathlib import Path

class MyBot(Bot):
def init(self) -> None: # blank init
intents = Intents.all()
intents.presences = False

    super().__init__( # we add our own stuff here
        command_prefix = ...,
        intents = intents
    )

async def setup_hook(self) -> None:
    commands = Path("commands")

    for path in commands.glob("commands/*.py"):
        await self.load_extension(f"commands.{path.stem}")
#

i think that looks decent

main heron
#

otherwise you'll never find the error

weary ridge
#

is that all?

main heron
#

looks good

#

!close to close the thread

weary ridge
weary ridge
main heron
#

remember to raise the error btw kek

weary ridge
#

alright!

#

tysm

main heron
#

in the on_command_error handler

#

no problem

weary ridge
#

!close

tulip slateBOT
#
Python help channel closed with !close

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.