Skip to content

Instantly share code, notes, and snippets.

View Taarek's full-sized avatar
In the end only kindness matters.

Tarek Taarek

In the end only kindness matters.
View GitHub Profile
//...
providers: [
Twitch({
clientId: process.env.TWITCH_ID,
clientSecret: process.env.TWITCH_SECRET,
authorization: { params: { scope: "openid user:read:email moderation:read" } },
async profile(profile, tokens) {
const id = profile.sub
const res = await fetch(`https://api.twitch.tv/helix/users?id=${id}}`, {
headers: { Authorization: `Bearer ${tokens.access_token}`, "Client-Id": process.env.TWITCH_ID },
const memTester = (() => {
const api = {
_timer: null,
start() {
if (api._timer != null) {
api.end();
}
let back = true;
api._timer = setInterval(() => {
if (back) {
@jegfish
jegfish / example_db.py
Last active March 19, 2024 03:26
Example code for connecting to and using a postgres database using discord.py and asyncpg.
# asyncpg docs: https://magicstack.github.io/asyncpg/current/
# This uses discord.py rewrite branch and .format(). If you are using the async branch of discord.py, it shouldn't matter much
# as only 'await ctx.send()' is something you should need to change. If you are using python 3.6+, you can use f strings as opposed to
# .format() for increased efficiency.
import discord
from discord.ext import commands
import asyncio
import asyncpg
@Painezor
Painezor / Checks.py
Last active April 18, 2024 05:22
Built-in Checks for the commands extension of discord py
@commands.guild_only()
# Command cannot be used in private messages.
@commands.dm_only()
# Command can only be used in private messages.
@commands.is_owner()
# Command can only be used by the bot owner.
@commands.is_nsfw()
@meew0
meew0 / apitosqa.md
Last active December 22, 2022 04:10
API ToS Q&A Summary

This is a summary of the Q&A regarding the new API ToS that took place in the #api channel on the Discord API server, starting around midnight UTC on Thursday, August 17, 2017.

All answers are from b1nzy unless marked otherwise. This is just a summary of my (meew0) own interpretation of the Q&A; obviously this shouldn't be interpreted as anything legally binding. If in doubt, ask the devs yourself or consult a lawyer. I'm not responsible if you get banned or sued because of this document. All subsequent usages of first-person pronouns refer to the people asking/answering the questions, respectively.

Q. How do we detect users deleting their accounts, if we have to delete their data within 7 days?
A. You will get an email by Discord if that happens. Make sure the account that registered the bot application has an email attached to it that you actually get messages with. This may change in the future but if it will, there will be plenty of time before the new mechanism goes into effect.

Q. **Do we need

@EvieePy
EvieePy / bot_example.py
Last active April 24, 2024 09:30
A Cogs Example for the rewrite version of - discord.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.
@leovoel
leovoel / basic_bot.py
Last active January 25, 2024 04:19
discord.py's basic_bot.py converted to use "cogs".
from discord.ext import commands
description = '''An example bot to showcase the discord.ext.commands extension
module.
There are a number of utility commands being showcased here.'''
# this specifies what extensions to load when the bot starts up
startup_extensions = ["members", "rng"]