Message commands extension for discord-py-interactions
Project description
interactions-message-commands
Message commands extension for discord-py-interactions
README IS NOT FINISHED YET BUT IT IS A GOOD START
Installation
pip install -U interactions-message-commands
Usage
Here is the example code for how to use message commands:
import interactions
from interactions.ext.message_commands import MessageCommands, MessageContext
bot = interactions.Client(
token="token here"
)
cmd = MessageCommands(bot, "!")
@cmd.message()
async def ping(ctx):
await ctx.send("pong")
@cmd.message(name="hello")
async def hi(ctx: MessageContext, name: str):
await ctx.send(f"Hello, {name}!")
bot.start()
First, you need to initialize your client.
Next, you need to initialize MessageCommands().
- Multiple string prefixes in a list, tuple, or set is also allowed!
Then, you need to register your message commands.
@cmd.message(): register a message command- Only keyword argument at the time is
nameto override function name nameis optional, if not specified, the function name will be used- In the function,
ctxis required. - You can have as many arguments and keyword arguments as you want!
*argsis supported, but not**kwargs. However,*,is supported.
- Only keyword argument at the time is
Finally, start the bot.
Use message commands in the Discord chat, and the bot will respond!
Example: !ping or !hello John
There is also when_mentioned() and when_mentioned_or() for the prefix:
from interactions.ext.message_commands import MessageCommands, when_mentioned_or
cmd = MessageCommands(bot, when_mentioned_or("!", "?"))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file interactions-message-commands-0.1.1.tar.gz.
File metadata
- Download URL: interactions-message-commands-0.1.1.tar.gz
- Upload date:
- Size: 19.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cf6b89fe1caf673b024c5f55630e7a3344e5867086eb49b252353272d945ce7
|
|
| MD5 |
59dab9fa350eb35a43189cdfae6a3a8a
|
|
| BLAKE2b-256 |
470e5fb746445f0a1b0c9739a7b3b390e1384a7f721b1cd95724c68c167aad03
|
File details
Details for the file interactions_message_commands-0.1.1-py3-none-any.whl.
File metadata
- Download URL: interactions_message_commands-0.1.1-py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51368a7e933787c4296e0faf1cb52c1c52b6a4c9a4c900e93d57636e180c0efa
|
|
| MD5 |
8ca232fc431e51e7e52397bbc45e05d3
|
|
| BLAKE2b-256 |
c4b28dd57e9968d32d103adaf9fa9ac721ae151c0df4130a3b5b83c41c1e3f8b
|