Skip to content

Instantly share code, notes, and snippets.

View izxxr's full-sized avatar

Izhar Ahmad izxxr

View GitHub Profile

Representing Ludo Board and Calculating Piece Movements

This gist outlines the way of programatically representing a Ludo board and the algorithm for calculating the next position of a ludo piece after performing a move with any number of steps.

Although most important details are elaborated in this gist, a basic knowledge of Ludo is obviously required to understand unexplained trivial details.

Definitions

To simplify further reading, the terms used frequently next are defined below:

# Install Neocord (git required):
# pip install git+github.com/nerdguyahmad/neocord.git
import neocord
import random
import asyncio
import logging
client = neocord.Client(intents=neocord.GatewayIntents.all())
@izxxr
izxxr / README.MD
Last active October 8, 2024 19:02
Discord.py Webhook Guide (Both async and sync).

⚠️ Notice

This guide is for discord.py 1.7 version. In upcoming v2.0, Webhooks were greatly overhauled and in fact simplified a lot. They no longer require adapters. Usage of webhooks is now quite straight forward. As such, this guide is now outdated and should not be followed.

Furthermore, this guide is focused on discord.py. No support for forks are covered in this guide.

Basic Webhooks Example using Discord.py (Rewrite)

Webhooks are a great way to send messages to Discord without having a bot account. You just need a webhook URL and just do a POST request on that URL and the message will be sent to discord.

Webhooks can also be used if your bot has to send messages to a channel a lot. For example, If your bot has event logging so everytime having to fetch channel and sending can be slow so you can use some webhook magic.

@minibox24
minibox24 / bot.py
Created April 10, 2021 14:04
discord.py activities invite generator
import discord
from discord.ext import commands
from discord.http import Route
bot = commands.Bot(command_prefix='!')
@bot.command('youtube')
async def youtube(ctx):
voice = ctx.author.voice
@simmsb
simmsb / eval.py
Last active January 30, 2024 05:39
A good eval for discord.py
import ast
import discord
from discord.ext import commands
def insert_returns(body):
# insert return stmt if the last expression is a expression statement
if isinstance(body[-1], ast.Expr):
body[-1] = ast.Return(body[-1].value)