Skip to main content

An extension library for interactions.py to add prefixed commands. A demonstration of molter-core.

Project description

The banner for molter for interactions.py.

Molter for interactions.py.

PyPI Downloads Code style: black

An extension library for interactions.py to add prefixed (AKA text-based or 'message') commands. This is a demonstration of the molter framework, a framework for adding prefixed commands into Discord Python libraries.

This attempts to make the prefixed command experience much like discord.py's prefixed commands, though it is not 1:1 on purpose.

NOTE: This extension is primarily developed by Astrea49. Direct questions about this to her, please!

Installation

pip install interactions-molter

Examples

Note

There are more in-depth examples about how molter works in the examples folder in this repository. These can be considered the documentation for this extension as of right now, so please take a look at them!

Standalone

import interactions
from interactions.ext import molter

client = interactions.Client(
    token="TOKEN",
    intents=interactions.Intents.DEFAULT | interactions.Intents.GUILD_MESSAGE_CONTENT,
)
# See examples folder for more information.
# molter.setup(client, default_prefix="!")
molter.setup(client)


@molter.prefixed_command(aliases=["test2"])
async def test(ctx: molter.MolterContext, some_var: int):
    await ctx.reply(str(some_var))


client.start()

Extension

import interactions
from interactions.ext import molter

# very important to use the below instead of Extension
# it's a subclass of it, so application commands will work
# fine, but it's needed for prefixed commands to also work
class Extend(molter.MolterExtension):
    def __init__(self, client: interactions.Client):
        self.client = client

    @molter.prefixed_command()
    async def soup(self, ctx: molter.MolterContext):
        await ctx.reply("Give soup, please!")

def setup(client: interactions.Client):
    Extend(client)

Branch Explanation

  • The main branch is the PyPI version - this branch will never deviate from it. This is done to make sure the PyPI page's example links link to the right code.
  • The stable branch is code considered code that is stable enough to use in daily use, though it is not perfect. This branch also will target any beta, pre-release, or release candidate version of interactions.py, if possible.
  • The dev branch mirrors interactions.py's unstable branch, and is also a general testing ground for new and experimental changes. Bugs are common on this branch. If you decide to use this branch, I highly suggest pinning to a specific commit you know is stable.

Credit

Thanks to both NAFF and Toricane's interactions-message-commands for a decent part of this! They both had a huge influence over how this port was designed.

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-molter-0.6.0.tar.gz (28.4 kB view hashes)

Uploaded Source

Built Distribution

interactions_molter-0.6.0-py3-none-any.whl (29.8 kB view hashes)

Uploaded Python 3

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