Skip to content

Instantly share code, notes, and snippets.

View trevorflahardy's full-sized avatar
🙃

Trevor Flahardy trevorflahardy

🙃
  • Florida
View GitHub Profile
@trevorflahardy
trevorflahardy / slash_utils_cooldowns.py
Created November 28, 2021 06:30
A simple addon to slash utils that allows for max_concurrency and cooldowns
from __future__ import annotations
from enum import Enum
import datetime
import inspect
from collections import defaultdict
import discord
import discord, discord.channel, discord.http, discord.state
from discord.ext import commands
@trevorflahardy
trevorflahardy / cog_metaclass_example.py
Last active September 9, 2023 13:04
Cog metaclass example for discord.py
from discord.ext import commands, tasks
class MetaTask(commands.CogMeta):
"""
A simple Metclass that can be used to get all tasks.Loop from the class,
and cancel them easily.
"""
def __new__(cls, name, bases, attrs, **kwargs):
new_cls = super().__new__(cls, name, bases, attrs)
_inner_tasks = [] # We'll attach any tasks we find to this
@trevorflahardy
trevorflahardy / example.py
Last active February 8, 2024 04:22
A simple button paginator.
import discord
from discord import app_commands
# My custom bot subclass:
class MyBot(commands.Bot):
...
# Create a subclass of our paginator. It accepts two generic arguments, the type of entries
# passed to the format_page function and the bot subclass. The bot generic argument is optional.