Skip to content

Instantly share code, notes, and snippets.

View LeoCx1000's full-sized avatar

Leonardo LeoCx1000

  • Italy
  • 10:00 (UTC +02:00)
View GitHub Profile
@LeoCx1000
LeoCx1000 / file.py
Created February 18, 2025 01:29
3y3 encoding in python because why not.
def encode_3y3(text: str) -> str:
"""Encodes a string using invisible 3y3 encoding."""
return ''.join([chr((val := ord(c)) + (0xE0000 if 0x00 < val < 0x7F else 0)) for c in text])
def decode_3y3(text: str) -> str:
"""Converts all 3y3 text within the string into normal text."""
return ''.join([chr((val := ord(c)) - (0xE0000 if 0xE0000 < val < 0xE007F else 0)) for c in text])
@LeoCx1000
LeoCx1000 / 01-guide.md
Created November 30, 2024 00:18
How to create a resourceful lootbags lootbag

Creating a Resourceful Lootbags custom bag

Rationale

The information that I found on the web about how to integrate with this modpack were scarse, so I decided to create this gist to explain a little bit.

Note: This guide was created with the intention of explaining this for server creators who want to integrate this modpack into their server, however it could also help people who are trying to use this mod for their own mod or pack.

The basics

@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 March 27, 2025 17:45
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 python file of your project, and import MentionableTree from it.

You can also use git clone [gist link] folder_name and then from folder_name import MentionableTree

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.