Skip to main content

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 name to override function name
    • name is optional, if not specified, the function name will be used
    • In the function, ctx is required.
    • You can have as many arguments and keyword arguments as you want! *args is supported, but not **kwargs. However, *, is supported.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

interactions-message-commands-0.1.1.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

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

Hashes for interactions-message-commands-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2cf6b89fe1caf673b024c5f55630e7a3344e5867086eb49b252353272d945ce7
MD5 59dab9fa350eb35a43189cdfae6a3a8a
BLAKE2b-256 470e5fb746445f0a1b0c9739a7b3b390e1384a7f721b1cd95724c68c167aad03

See more details on using hashes here.

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

Hashes for interactions_message_commands-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 51368a7e933787c4296e0faf1cb52c1c52b6a4c9a4c900e93d57636e180c0efa
MD5 8ca232fc431e51e7e52397bbc45e05d3
BLAKE2b-256 c4b28dd57e9968d32d103adaf9fa9ac721ae151c0df4130a3b5b83c41c1e3f8b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page