Skip to content

Instantly share code, notes, and snippets.

View 4Kaylum's full-sized avatar

Kae Bartlett 4Kaylum

View GitHub Profile
class Node(object):
def __init__(self, program):
self.raw = program
x = program.split(' ')
# name, weight (->, program, program..)
self.parent = None
self.name = x[0]
self.weight = int(x[1][1:-1])
self.children = ' '.join(x[3:]).split(', ')
self.children_objs = []
from json import load, dump
from random import choice
class JsonDB(object):
'''
An object to handle the quotes database for you
Parameters:
filename: str
@4Kaylum
4Kaylum / DiscordPy Tutorial.md
Last active January 16, 2026 13:45
A simple bot tutorial for Discord.py

Writing a Discord bot with Discord.py

Hey one, hey all, and welcome to a basic Discord bot writing tutorial. This is a basic tutorial that doesn't cover coding in general, but rather how to work with the Discord.py (v1.0.0a) library and how to write a simple bot with it. General help can be found on the Discord API guild and in the documentation.

This tutorial assumes some prior knowledge of programming, and assumes you already have Python3.5 (and Pip) or later installed and added to your PATH.

With that, let's get to it.

Installation

@4Kaylum
4Kaylum / provablyfair.py
Last active March 4, 2022 02:16
Implementation of the Primedice provably fair algorithm (https://dicesites.com/primedice/verifier)
import random
import secrets
import hashlib
import hmac
class ProvablyFair(random.Random):
"""An object that represents a provably fair algorithm"""
def __init__(self, client_seed:str=None, *, server_seed:str=None):
from random import shuffle
class Card(object):
'''
A card object - represents a card from the deck
'''
def __init__(self, value, suit):
self.value = value
from requests import get
def get_dog(*, dog_id:str='', limit:int=1) -> dict:
url = 'https://api.thedogapi.co.uk/v2/dog.php'
params = {}
if dog_id:
params.update({'id': dog_id})
if limit > 1:
params.update({'limit': limit})
site = get(url, params=params)
@4Kaylum
4Kaylum / colours.py
Last active September 26, 2020 20:45
COLOURS = {
"caleb blue": 0x5dadec,
"ollie yellow": 0xf5e59d,
"poop brown": 0x7a5901,
"stegosans": 0xf1e6a9,
"teddy purple": 0xb19cd9,
# Below this point is directly copied from the Github link,
# minus a bunch that were repeated colours later
"alice blue": 0xf0f8ff,
@4Kaylum
4Kaylum / mee6_rank.py
Created September 6, 2019 22:24
A cog that gets a person at rank N on the Mee6 leaderboards
"""Gets a member at the Nth place on Mee6's leaderboard"""
from discord.ext import commands
from cogs import utils
class Mee6Ranking(utils.Cog):
def __init__(self, bot:utils.CustomBot):
@4Kaylum
4Kaylum / everyone_ping.py
Created September 6, 2019 22:25
A cog that pings everyone on the server every 10 seconds
"""Make a bot that pings everyone on the server every 10 seconds"""
import discord
from discord.ext import commands
from discord.ext import tasks
from cogs import utils
class EveryonePing(utils.Cog):
@4Kaylum
4Kaylum / big_ben.py
Created September 6, 2019 22:26
A bot that says "bong" on the hour every hour
"""A bot that says "bong" on the hour every hour"""
from datetime import datetime as dt
import discord
from discord.ext import commands
from discord.ext import tasks
from cogs import utils