Skip to content

Instantly share code, notes, and snippets.

View Soheab's full-sized avatar
📚

Soheab Soheab

📚
  • 22:28 (UTC +02:00)
View GitHub Profile
@Soheab
Soheab / 0-discord.Colour.md
Last active April 30, 2024 12:28
See everything related to discord.Colour in a clean way with their usages.

discord.Colour

See here every colour and method the discord.Colour class has.

Jump Links

Colours

@Soheab
Soheab / API's.md
Last active April 25, 2024 19:48
See here some of the API's you can use in your discord bot or anything

Some API's for you.

See here some of the API's you can use in your discord bot or anything. For any help or questions on how to use one, please contact the owner of the API and not me.

A much bigger list of APIs can be found here


[TOKEN] = API requires a token to access some if not all endpoints.

The descriptions are mostly copied from the API, sometimes personal or from the dev.

@Soheab
Soheab / timezones.md
Last active March 30, 2024 12:36
See here all timezones supported by Python PyTz and ZoneInfo!

⬇️ End

ℹ️ Information
All supported timezones by the pytz package, Python's built-in ZoneInfo and probably others too.
Use Ctrl/CMD + F to look for a specific timezone or use the Jump URLs
❗ Important ZoneInfo is case sensitive. What this means is that ETC/... should be Etc/...
@Soheab
Soheab / 0-simple_paginator.py
Last active January 23, 2024 20:27
A simple paginator with three buttons.
from __future__ import annotations
from typing import (
Dict,
Generic,
List,
Optional,
TypeVar,
Any,
TYPE_CHECKING,
Sequence,
@Soheab
Soheab / wait_for_modal.md
Last active January 13, 2024 11:57
See how to wait for user input using a modal!

Wait for with a Modal

See here an overcomplicated way to wait for input from a user using a modal. Every step is explained using comments.

This is meant to replace Client.wait_for("message") for application commands.

Features

  • Easy way to construct a Modal with one text input field.
  • Easily pass a check from the constructor

Files

from typing import Any, TYPE_CHECKING, List
import asyncio
from discord import ui, Interaction
class GlobalView(ui.View):
def __init__(
self,
@Soheab
Soheab / self_bot.md
Last active October 7, 2023 21:03
Read here how "self.bot" works in a discord.py cog. For a tag called `?tag self.bot` on the dpy server.

What is self.bot and how does it work?

TLDR: it's a custom attribute which you define.

self = class instance bot = attribute that's usually assigned to the bot instance given in an extension's setup function.

Basically:

class MyCog(Cog):
    # this function is called when we do MyCog()
@Soheab
Soheab / markdown.md
Last active August 10, 2023 21:51
See here the progress of the discord.py library after discontinuation.

The hyperlinks are either links to a gist or discord message in the discord.py server

  • Danny reworks async stuff, breaking changes for all!
@Soheab
Soheab / wait_for in command.md
Last active July 11, 2023 16:56
Examples for a wait_for in ext.commands.

This gist shows how to make the bot wait for a message or reaction after doing a command. This should not be copypasted.

Docs

Check the discord.py docs for a detailed explanation of how it all works internally and which kwargs it takes.

Commands

See here two commands, one waiting for any message in a channel and the other waiting for a reaction with a specific emoji.

Check

# for testing:
# import collections
# emoji = collections.namedtuple("emo", ["animated"])(False)
emoji = ... # some (Partial)Emoji object
guild = ... # some Guild object
emojis = guild.emojis
total = len(guild.emojis)
limit = guild.emoji_limit
animated = sum(1 for e in emojis if e.animated)