discord.py /slash cog
A drop-in vanilla discord.py cog that acts as a translation layer to add slash command support with little to no code modifications, no forks needed
Features:
- Automatically generates a command map with argument listing for the entire bot
- Wraps around existing discord.py
Context, almost no code modifications needed - Automatic Multi-Instance bot detection (currently, it will only register if there is no shards or the bot runs shard
0) - Storage-less automatic permissions syncing
General TO-DOs & RFCs:
- Make the cog more modular in order to support more customizations
- Avoid monkey-patching command checks
- Translation for
has_role
Unsupported Features (Unsupported by Discord):
- Translation for Custom checks
- Translation for
@commands.check_any() -
is_nsfw(commands currently hidden) -
*has_permissions(only roles and user IDs are accepted) -
bot_has_(any)?_role -
guild_only -
dm_only
Fork Support:
I personally won't provide support for forks as for simplicity's sake I will be basing this cog on Rapptz/discord.py master v2.0.0a. However, fork-specific pull requests are allowed.
A word though, because everyone is making their own forks of discord.py, I would suggest changing up the readme to include what changes and features the fork has added apart from API parity and maintenance just to make everybody's lives easier.
3-step Usage:
Simply install the pip package with:
pip install -U slash_cog
Then in your bot's cog loader, load the command handler (CRITICAL: Load it as the first extension as the cog needs to monkey patch command checks):
bot.load_extension("slash_cog")
Create a new cog to register the commands globally or per-guild, you may copy the example.
Preferably, you should only register the commands once and keep them registered as Discord will retain the command data unless you replace them, but the code for this is for you to decide and/or modify the example to.
P.S. If this project / POC has been useful sponsor me pls, iambroke
Metadata
Release files for slash-cog 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| slash_cog-0.0.3.tar.gz | 9.8 kB | Without provenance | Details for slash_cog-0.0.3.tar.gz |
Release files / slash_cog-0.0.3.tar.gz
| Download URL | slash_cog-0.0.3.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e948fe958a0339b205e861bf6aacb0d2b725116e8b3df2971285ebff570baa73
|
|
BLAKE2b-256 checksum How to use checksums |
1bcb06c11b6de65a33bbd37c9b4413281d9fd316fac768e58129e2fbc26f0527
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.0.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.6
|
Security for slash-cog 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.