Skip to content

Instantly share code, notes, and snippets.

View cyrus01337's full-sized avatar

Cyrus cyrus01337

View GitHub Profile
@cyrus01337
cyrus01337 / traceback.py
Last active October 27, 2022 09:39
Full Traceback Example
Ignoring exception in on_command_error
Traceback (most recent call last):
File "C:\Users\Cyrus\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 312, in _run_event
await coro(*args, **kwargs)
File "D:\Users\Cyrus\Documents\Code\Python\Bases\bot\cogs\error_handler.py", line 27, in on_command_error
raise error
File "C:\Users\Cyrus\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\bot.py", line 892, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Cyrus\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 790, in invoke
await self.prepare(ctx)
@cyrus01337
cyrus01337 / inline.py
Created December 23, 2020 15:51
Jishaku eval code used to generate the image example for ?tag inline
kwargs = {"title": "title", "description": "description"}
embeds = (discord.Embed(**kwargs), discord.Embed(**kwargs))
values = ("not inline", "inline")
for i, inline in enumerate((False, True)):
embed = embeds[i]
for n in range(1, 7):
embed.add_field(name=f"field #{n}", value=values[i], inline=inline)
_=await _ctx.send(embed=embed) # replace "_ctx" according to your bot's jishaku underscore settings
@cyrus01337
cyrus01337 / shortcuts.txt
Created February 11, 2021 12:31
Context Shortcuts for DIscord.py
Format:
Attribute == Shortcut
Attribute ~~ Shortcut (can be equal to)
Guild.me == ctx.me (Gives ClientUser in DMs)
Command.cog == ctx.cog
Message.guild == ctx.guild (Gives None in DMs)
commands.Bot() == ctx.bot
Message.author == ctx.author (Gives User in DMs)
Message.channel == ctx.channel
@cyrus01337
cyrus01337 / get_emoji_format.py
Created February 16, 2021 15:37
Function that grabs emotes based on name - useful for those without Nitro attemping to grab the formatting of animated emotes.
import os
import discord
def get_emoji_format(name: str):
guild_obj: discord.Guild = None
if os.environ.get("JISHAKU_NO_UNDERSCORE", False):
guild_obj = guild
@cyrus01337
cyrus01337 / QueueSystem.lua
Created May 6, 2022 03:48
My attempt at a queue system for event callbacks.
type QueueKey = {
RBXScriptSignal,
(...)
}
local arguments = { [QueueKey]: {any}? }
local connections: { [QueueKey]: RBXScriptConnection } = {}
local queues: { [QueueKey]: number } = {}
@cyrus01337
cyrus01337 / global.code-snippets
Created June 16, 2022 15:45
Zustand useStore snippet
"useStore Hook": {
"scope": "javascript,typescript,javascriptreact",
"prefix": ["use", "usestore"],
"body": [
"let ${0:slice} = useStore(state => state.${0:slice});"
]
},
@cyrus01337
cyrus01337 / 1 FEATURES.md
Last active December 6, 2022 05:46
Curated list of Discord bot commands to be used as a reference (for creating the ultimate bot in history duh /s)

List of Commands

General

  • Standard and edit snipes
  • Display invite info
  • Reminders
  • Member inspection (Whois)

Logging

  • Kicks (fetch audit logs to verify)
:root {
--default-emoji-size: 1.375rem;
--default-emoji-jumboable-size: 3rem;
--emoji-size: calc(var(--default-emoji-size) * 2);
--emoji-jumboable-size: calc(var(--default-emoji-jumboable-size) * 2);
}
/* Change emoji size */
[class*="messageContent"]:not([class*="repliedTextContent"]) .emoji {
height: var(--emoji-size) !important;
@cyrus01337
cyrus01337 / Devices.jsx
Created January 5, 2023 11:36
Responsive component that conditionally renders based on resolution
import { useEffect, useState } from "react";
const MOBILE_WIDTH = 1024;
export const isDesktop = (limit = MOBILE_WIDTH) => window.innerWidth > limit;
export const isMobile = (limit = MOBILE_WIDTH) => window.innerWidth <= limit;2
const useResolutionChecker = ({ desktop, mobile }) => {
const [inMobileResolution, setInMobileResolution] = useState(isMobile());
@cyrus01337
cyrus01337 / 1 Embed.py
Created March 29, 2023 04:45
Example of custom Embed sub-class that avoids method calls by passing data as kwargs and hiding calls in the initialiser. This concept can also be thought of as providing sensible defaults to simplify developer input when creating embeds en masse.
# src/utils.py
from __future__ import annotations
from collections import namedtuple
import discord
Author = namedtuple("Author", ["name", "url", "icon_url"])
Footer = namedtuple("Footer", ["text", "icon_url"])
Field = namedtuple(