Skip to main content

Toolset to speed up discord bot development using discord.py

Project description

forthebadge made-with-python

PyPI status PyPI version fury.io Downloads PyPI license

dpytools

Collection of tools to speed up developing discord bots using discord.py

Features

  • The batteries of discord.py
  • Easy to read type-hinted code
  • Active development
  • Minimal dependencies

Instalation

Install the latest version of the library with pip.

pip install -U dpytools

Useful links:

Use Examples:

The library has a couple of reaction menus that are really easy to use. dpytools.menus.arrows takes a list of embeds and displays it using a reaction menu.

@bot.command()
async def arrow_menu(ctx):
    """
    This command sends a list of embeds in a reaction menu with emojis aid in navigation
    """
    from dpytools.menus import arrows
    long_list_of_embeds = [discord.Embed(...), ...]
    await arrows(ctx, long_list_of_embeds)

There are multiple checks you can use directly on your commands dpytools.checks.admin_or_roles takes any number of strings (Role names) and ints (role ID) and checks if the person using the command has those roles or has administrator permissions.

from dpytools.checks import admin_or_roles
@bot.command()
@admin_or_roles('Moderator', 123456789)
async def moderation(ctx):
    ctx.send('Only admins and people witha a role named "Moderator" ' 
             'or with a role with id 123456789 can use this command')

There are also multiple argument parsers. Functions that convert a user's input to something more useful. dpytools.parsers.to_timedelta takes a string in the format <number>[s|m|h|d|w] and returns a timedelta object

from dpytools.parsers import to_timedelta
@bot.command()
@commands.guild_only()
async def mute(ctx, member: discord.Member, time: to_timedelta):
    await ctx.send(f"{member.mention} muted for {time.total_seconds()} seconds")
    mute_role = ctx.guild.get_role(1234567890)
    await member.add_roles(mute_role)
    await asyncio.sleep(time.total_seconds())
    await member.remove_roles(mute_role)
    await ctx.send(f"{member.mention} unmuted")

This argument parsers can also be used outside the context of discord.ext.commands In the end most of them only take a string and return the appropriate object. Only converter classes that inherit from discord.ext.commands.Converter require a command context to work.

There are many other tools available in the library, check them in docs/All.md

Todos:

  1. Adjust Menus to use buttons where it makes sense.
  2. Add proper documentation

Status of the project

Beta. All functions have been tested but new tools are frequently added. Breaking changes may come depending on changes on API or discord. Use in production only after extensive testing.

Contributing

Feel free to make a pull request or rise any issues.

Contact

Message me on discord at ChrisDewa#4552 if you have any questions, ideas or suggestions.

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

dpytools-0.13.0b0.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

dpytools-0.13.0b0-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file dpytools-0.13.0b0.tar.gz.

File metadata

  • Download URL: dpytools-0.13.0b0.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.10 Windows/10

File hashes

Hashes for dpytools-0.13.0b0.tar.gz
Algorithm Hash digest
SHA256 1b14ce71ddf2ab6d002d2e110bd0e28e7b7cc76435d900baa257c29536f958cc
MD5 0be4776df91504d273f58bb2ff42662b
BLAKE2b-256 0236131370100d137b0162f5bec5fbd34b529e375e37e749e864ffbca56f5f2f

See more details on using hashes here.

File details

Details for the file dpytools-0.13.0b0-py3-none-any.whl.

File metadata

  • Download URL: dpytools-0.13.0b0-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.10 Windows/10

File hashes

Hashes for dpytools-0.13.0b0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b1921ecec6a127cf1e8c047c7b1bc95e89f5eb076b7ae2d243009ab19d96026
MD5 a9c5fcf8122ce05c88090b0066092778
BLAKE2b-256 63b612404c046dbdfada4570dee1a79bcbe0de2340d069f5005ca6c736bbd5ff

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