Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

forthebadge made-with-python

PyPI status PyPI version fury.io Downloads Documentation Status PyPI license

dpytools

Collection of easy to use, beginner friendly but powerful, orthogonal tools to speed up discord bots development (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 with a a role named "Moderator" ' 
             'or with a role with id 123456789 can use this command')
from dpytools.checks import any_checks

@commands.guild_only()       # This command must be called inside a server
@any_checks                  # Place the decorator above the checks you with to compare using "OR"
@commands.is_owner()         # The command will run if ctx.author is the owner of the bot
@commands.has_role('Admin')  # __OR__ if ctx.author has the role "Admin"
@bot.command()               # this decorator transforms this function in a command any_checks must be above it
async def test(ct):
    await ctx.send('The command works')

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. Add interactions

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.

Metadata

Release files for dpytools 0.18.0b0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dpytools 0.18.0b0
File Size Uploaded
dpytools-0.18.0b0.tar.gz 21.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dpytools 0.18.0b0
File Interpreter ABI Platform
dpytools-0.18.0b0-py3-none-any.whl Python 3 none any Details

Total release size: 46.1 kB

Release files / dpytools-0.18.0b0.tar.gz

Download URL dpytools-0.18.0b0.tar.gz
Size 21.8 kB
Tags Source
SHA-256 checksum
How to use checksums
faa3cf81bdd90b5499f830c13a1f2e00290422fe4c2d6b77b18b034a7bf5df02
BLAKE2b-256 checksum
How to use checksums
9731f9081f91fd89d305ecbf44846c50ceca7b3f2e4ddd166fe31b3884c6f0bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.8.10 Windows/10

Release files / dpytools-0.18.0b0-py3-none-any.whl

Download URL dpytools-0.18.0b0-py3-none-any.whl
Size 24.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9baf98bdd69a2d06c30a9de5bfe305a8004b287cb63a3ffda77f5e215c74328d
BLAKE2b-256 checksum
How to use checksums
218ffa0c6fdfad590c8246dd8180232295d46766b2b78471997e2ecec1e5811e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.8.10 Windows/10

Release history Release notifications | RSS feed

This release

0.18.0b0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page