Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Port command system to discord.ext.commands #380

Merged
merged 21 commits into from
May 21, 2022

Conversation

Mega-JC
Copy link
Member

@Mega-JC Mega-JC commented Apr 19, 2022

This PR ports the entire backbone of the current command system to discord.py's discord.ext.commands. This port is an addition to the changes in the snakecore_port branch.

There are a few reasons for this:

1. Portable

The command framework is built right into discord.py and is bot-agnostic and server-agnostic by design, meaning that porting commands from one bot to another should be a lot easier.

2. Popular

The framework itself is used by a large amount of discord.py users, and large projects (like the bots in the Python Discord) make use of it without many problems. It would also make it easy for others to provide external contributions to command-related code.

3. Extensible, Feature-Rich

The framework is designed in a way that allows you to write commands and parse them using a built-in powerful system, as well as to allow for custom parsing of raw command input, should it be necessary. With enough time, one can work around limitations that might show at first.

Regarding 3.: Commands still preserve the entirety of their input syntax, as the custom parser used in the command code is being ported into snakecore.

This PR will hopefully allow for a more robust system to build command functionality on.

Copy link
Member

@ankith26 ankith26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can probably drop the OOP structure if we are using ctx in all methods anyways

pgbot/__init__.py Show resolved Hide resolved
pgbot/__init__.py Outdated Show resolved Hide resolved
pgbot/commands/admin/__init__.py Outdated Show resolved Hide resolved
@Mega-JC
Copy link
Member Author

Mega-JC commented Apr 19, 2022

we can probably drop the OOP structure if we are using ctx in all methods anyways

The OOP based separation is still used by our command help system and commands that use separate methods for implementing command code, which are shared by different commands along the inheritance tree of the command cogs, I think it still has its use.

@Mega-JC Mega-JC added PR: Needs Core Review A PR that is substantial, and needs more review Code: Base Commands Something related to base.py and/or command handling base code Difficulty: Hard 😭 This will be hard to do for most contributors enhancement ✨ Improvements to existing features labels Apr 20, 2022
@Mega-JC Mega-JC added Code: Commands For non-specific command related functionality Priority: Medium ☕️ This is interesting and worth tackling when the chance arises and removed Difficulty: Hard 😭 This will be hard to do for most contributors labels May 12, 2022
@Mega-JC Mega-JC added the Difficulty: Hard 😭 This will be hard to do for most contributors label May 14, 2022
@Mega-JC Mega-JC merged commit d14d296 into pygame-community:snakecore_port May 21, 2022
@Mega-JC Mega-JC deleted the dpy_ext_commands branch May 21, 2022 12:45
Mega-JC added a commit that referenced this pull request Aug 7, 2022
* begin porting PygameCommunityBot to discord.py v2.0

* run black

* add snakecore as a dependency from GitHub repository

* fix missing attribute from port

* add thread messaging support, fix bugs relating to avatar/icon Asset objects

* add support for receiving  messages from threads in bot commands

* fix embed refresh bug, sort requirements.txt

* Fully port codebase to use `snakecore.utils` (#378)

* begin porting to snakecore utils modules

* partial port of snakecore.embed_utils

* finish porting to snakecore utility modules

* fix relocated constant typo

* fix string typo for message browse command

* add inactivity timeout parameter in EmbedPaginator

* replace removed Messageable.trigger_typing with Messageable.typing

* Port command system to `discord.ext.commands` (#380)

* begin porting to discord.ext.commands

* begin porting to discord.ext.commands 2

* finish porting command codebase to discord.ext.commands, many heavy improvements and fixes

* revamp code for controlling the deletion of repsonse messages using reaction

* add some extra references for globally used asyncio task objects (port)

* improved command refresh command

* add more module docstrings

* fix typos, simplify decorator code

* improve command error handling, improvements

* fix imports and change command decorators

* fix imports and change command decorators

* remove CustomContext, improvements

* more import cleanups

* more import cleanups

* prefer self.bot over common.bot in cogs

* tweak clock command

* abstract away common.global_task_set

* tweak command refreshing code

* modularize commands module into extensions, use pseudo DB from snakecore, delete emotion-related functionality and unused modules, implement bootstrap.json, various refactorings

* run black

* remove unused files

* rename constants, remove more unneeded code

* add bootstrap runtime override code

* add missing assets

* fully restructure entire codebase, turn command modules into extensions fixes and improvements

* more fixes and improvments

* update README

* Major Codebase Refactoring: Adhere to `bot-template` repository structure (#383)

* modularize commands module into extensions, use pseudo DB from snakecore, delete emotion-related functionality and unused modules, implement bootstrap.json, various refactorings

* remove unused files and modules, rename constants

* more fixes and improvments

* update README and project requirements to Python 3.9

* correct some string inconsistencies

* add optional uvloop dependency for optimization

* add discord logging configuration, fixes and improvements

* fix malfunctioning discord bot console

* improve RedirectTextIOWrapper class

* fix output bug in 'sudo' command

* fix error in 'sudo edit' command

* add group_by_author_timedelta kwarg to 'archive' command

* fix error in previous commit

* fix error in previous commit 2

* use snakecore 0.1.0 as a dependency version

* change code formatter line-length to 88, improve command enabling/disabling, update runtime.txt

* update setup.cfg

* fix 'sudo edit' command bug
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Code: Base Commands Something related to base.py and/or command handling base code Code: Commands For non-specific command related functionality Difficulty: Hard 😭 This will be hard to do for most contributors enhancement ✨ Improvements to existing features PR: Needs Core Review A PR that is substantial, and needs more review Priority: Medium ☕️ This is interesting and worth tackling when the chance arises
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants