a standalone library to bring discord.py developer experience to your python applications, focus on building your logic rather then an event manager or command manager
- Familiar Decorator API – Leverages the intuitive
discord.pypattern for registering commands and events. - Automatic Type Conversion – Uses Python type hints to automatically convert input strings into integers, floats, or custom objects.
- Asynchronous by Design – Built from the ground up for
asyncio, allowing command and event handlers to run concurrently within your existing event loop. - Zero Bloat – A focused codebase with zero dependencies.
been tested in python 3.10
Run the following to install:
pip install commandkitpython -m pip install commandkitif that didn't work, try replacing pip with pip3.
need help? or have bugs to report, let me know in here
importasynciofromcommandkitimportCommandLine, Greedycmder=CommandLine(prefix="!")
@cmder.command()defadd(a: int, b: int):
"""Adds two numbers."""returna+b@cmder.command()asyncdefannounce(title: str, *, message: str):
"""Capture the rest of the string as a single argument."""awaitasyncio.sleep(0.1)
returnf"[{title}] {message}"asyncdefmain():
# Sync command callres=awaitcmder.process_command("!add 10 20")
print(res) # 30# Rest captureres=awaitcmder.process_command('!announce "System Alert" This is a test message.')
print(res) # [System Alert] This is a test message.if__name__=="__main__":
asyncio.run(main())CommandKit includes a standalone EventManager for dispatching async events.
fromcommandkitimportEventManagerimportasyncioem=EventManager()
@em.eventasyncdefon_message(arg):
print(f"Event received: {arg}")
asyncdefrun_events():
# dispatch("test") will trigger all "on_message" eventsawaitem.dispatch("message", "Hello World!")
asyncio.run(run_events())you can check commandkit docs here
We value technical contributions and bug reports.
- Issues:Open a ticket for bugs or feature requests.
- PRs: Pull requests are welcome. Please ensure code follows PEP 8 standards.
CommandKit is distributed under the MIT License.