#๐ load extension help
37 messages ยท Page 1 of 1 (latest)
@weary ridge
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.
use .listen('on_message') instead of .event
you're processing commands anyway
also dont print your exceptions
it was for debugging perposes
show me your file structure
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
oh thx the $test actually responds now!
again, subclassing and overriding would be better
if theres any changes needed
alright
yeah i'd change a few things:
- use
Bot.run()instead ofasync with BotandBot.start() - remove the
on_messagehandler, since it doesn't do anything - don't pass on generic exceptions
- merge
setup_hookandload_extensions - override the
__init__to add its own args to thesuper().__init__()instead of needing to pass your own
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
make sure you raise the error in the command too btw
otherwise you'll never find the error
is this better?
oh yeah thats perfect
remember to raise the error btw 
!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.
