Skip to content

Instantly share code, notes, and snippets.

Avatar

OneEyedKnight

View GitHub Profile
@OneEyedKnight
OneEyedKnight / bot_example.py
Last active May 31, 2021 — forked from EvieePy/bot_example.py
A Cogs Example for the rewrite version of - discord.py
View bot_example.py
import discord
from discord.ext import commands
import sys, traceback
"""This is a multi file example showcasing many features of the command extension and the use of cogs.
These are examples only and are not intended to be used as a fully functioning bot. Rather they should give you a basic
understanding and platform for creating your own bot.
These examples make use of Python 3.6.2 and the rewrite version on the lib.
@OneEyedKnight
OneEyedKnight / paginator.py
Last active May 8, 2021
Lazy reaction paginator (can work without manage messages permissions and works for both embed and text) for the rewrite branch of discord.py
View paginator.py
# I know it looks like R.Danny's paginator, I looked at it for reference to try to figure out how to do the paginating and wrote it
# in my own way. So don't accuse me of stealing code and modifying it to my own liking. In some ways or another, this paginator is simply
# a more efficient version of the paginator found in ?tag help command (assuming you came here from discord.py).
class Paginator:
def __init__(self, ctx, entries: list, embed=True):
self.bot = ctx.bot
self.ctx = ctx
self.entries = entries
self.embed = embed
@OneEyedKnight
OneEyedKnight / help.py
Last active Dec 6, 2020
Help example for the rewrite branch of discord.py
View help.py
# NOTICE: Before you copy this example, be sure you understand what all this does. Remember: This is a gist, not a github file meaning
# you can't pip install this, you would need to put this into a new file and add it to your cog list.
import discord
import asyncio
from discord.ext import commands
def chunks(l, n):
@OneEyedKnight
OneEyedKnight / moderation.py
Last active Apr 5, 2021
An advanced moderation cog for the rewrite branch of discord.py
View moderation.py
import discord
from discord.ext import commands
# This prevents staff members from being punished
class Sinner(commands.Converter):
async def convert(self, ctx, argument):
argument = await commands.MemberConverter().convert(ctx, argument) # gets a member object
permission = argument.guild_permissions.manage_messages # can change into any permission
if not permission: # checks if user has the permission
return argument # returns user object