Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bot code restructuring suggestion #53

Open
user4752 opened this issue May 17, 2024 · 3 comments
Open

Bot code restructuring suggestion #53

user4752 opened this issue May 17, 2024 · 3 comments

Comments

@user4752
Copy link
Contributor

After hearing you state you wished to reorganize the code, I was reminded of a feature discordjs has and read up on the docs for discordpy and was happy to find out it does also implement a similar feature.

Discordpy extensions allow separating out sections of code into sub-modules as you had indicated you thought about doing, and allow for hot reloading and loading of new code without needing to shut the bot down in order to do so (assuming the main bot process has been coded in a sufficient manner to allow this)

Discordpy cogs allow grouping of functions into a shared class space inside of modules which provide skeleton for a framework to run commands and bind listeners to event emitted from the discord api.

Cogs can be the basis for organizing of slash commands into groups.
Cogs would also simplify parameter passing between classes and functions as cogs classes can be referenced externally via the get_cog() function call.

@SocksTheWolf
Copy link
Owner

That could be kinda nice, BotMain is getting really bloated with the number of base class references it currently has. I would love to see it more lean if possible.

@user4752
Copy link
Contributor Author

Once #55 has been reviewed discussion on how commands can be logically organized can occur in order to further development in this idea.

I have created a sample bot using extensions and cogs have found they're extremely easy to setup, deciding on how to group commands is the difficult part.

Next steps on testing for me are

  • hot reload of commands for when updates are pushed without restarting the bot
  • passing data around the cogs without needing function parameters or global variables

@SocksTheWolf
Copy link
Owner

Yeah, I think reorganizing via cogs would be nice. Some of these classes are so big it can be hard to find things. I don't think necessarily we need to do a full on refactor though, but reorg would be good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants