Skip to content

Instantly share code, notes, and snippets.

View LeoCx1000's full-sized avatar

Leonardo LeoCx1000

  • Italy
  • 22:50 (UTC +01:00)
View GitHub Profile
@LeoCx1000
LeoCx1000 / dpy_async_cooldown.py
Created September 18, 2024 12:38
d.py cooldown decorator with async bucket support.
from typing import Any, Callable, Optional, TypeVar
import discord
from discord.ext import commands
T_contra = TypeVar('T_contra', contravariant=True)
class AsyncCooldownMapping(commands.CooldownMapping[T_contra]):
@LeoCx1000
LeoCx1000 / ___README.md
Last active August 25, 2024 15:24
Mentionable CommandTree implementation to allow mentioning slash commands in discord.py

discord.py MentionableTree implementation

My implementation of a CommandTree subclass which allows for finding a mention for a given app command.

How to use?

Just copy the entire third file into a new file python of your project, and import it.

Additions to the default CommandTree.

Multiple concurrencies

Here is an example on how to use commmands.MaxConcurrency for multiple bucket types. If you want to add more concurrencies, you will need to add more try/except blocks and in each one's except statement you need to release all the previous concurrencies that you have acquired.