Skip to content

Instantly share code, notes, and snippets.

View binarybrat's full-sized avatar

Cloei binarybrat

View GitHub Profile
import sqlite3
class SQL():
def __init__(self) -> None:
conn = sqlite3.connect('data.db')
cur = conn.cursor()
cur.execute("""CREATE TABLE IF NOT EXISTS students(
discord_id INT,
name TEXT,
@TheTechRobo
TheTechRobo / bot.py
Last active September 15, 2023 21:29
import discord, aiohttp, asyncio
from config import TOKEN
bot = discord.Bot()
@bot.event
async def on_ready():
global session
session = aiohttp.ClientSession()
@richdrummer33
richdrummer33 / toggl_timer_automater.py
Last active September 15, 2023 21:32
Auto-Toggl Toggle Timer Script: Automatically starts/stops the Toggl timer based on user inactivity or based on keywords in a messenger app.
import time
import datetime
import requests
import threading
import os
from pytz import timezone
# Created by Richard Beare, as a balm for his forgetfulness
# Toggl Automation
@0187773933
0187773933 / DiscordBotArchiveAllGuilds.py
Last active September 15, 2023 21:39
Python Script to Download All Messages In All Categories in All Guilds the Bot Has Joined
#!/usr/bin/env python3
import requests
from pprint import pprint
from box import Box
from pathlib import Path
import shutil
import json
from tqdm import tqdm
from concurrent.futures import ThreadPoolExecutor
import urllib.parse
@chainyo
chainyo / send_summary.py
Created January 9, 2023 19:01
The function that send summary to users' DM.
async def send_summary_as_dm(
self,
guild: discord.Guild,
user: discord.User,
summary_size: str,
timeframe: str,
language: str,
job_name: str,
token: str,
summarized_chat: Optional[List[str]] = None,
def run_bot():
try:
print('Working...')
unread_conversations = reddit.subreddit(sub_name).modmail.conversations(state="highlighted")
for conversation in unread_conversations:
if (len(conversation.authors) > 1 and len(conversation.messages) > 1 and "find_last" in conversation.messages[-1].body_markdown):
print(f'Match Found: {conversation.id}')
username = conversation.user
target_sub = conversation.owner
api = PushshiftAPI()
# Copyright 2020-present Michael Hall
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@CoutinhoElias
CoutinhoElias / sub_query.py
Last active September 18, 2023 09:12
Subquery on peewee
# When referencing a table multiple times, we'll call Model.alias() to create
# a secondary reference to the table.
EstoqueAlias = Estoque.alias()
# Create a subquery that will calculate the maximum Post timestamp for each
# user.
subquery = (EstoqueAlias
.select(
EstoqueAlias.iddetalhe,
fn.MAX(EstoqueAlias.dtreferencia).alias('max_ts'))
@alkasm
alkasm / dataclass_required_field.py
Created July 24, 2022 02:24
A pattern for "required" arguments in dataclasses, allowing for fields without defaults to follow fields with defaults.
from dataclasses import dataclass, field
from datetime import datetime
from typing import Optional, TypeVar
T = TypeVar("T")
def required() -> T:
f: T
@InterStella0
InterStella0 / Pagination_walkthrough.md
Last active April 3, 2025 19:53
A walkthrough on action based pagination in discord.py

Pagination Walkthrough in discord.py

In this tutorial I will go through the entire length of pagination in discord.py

I kindly ask you to go through the entire thing, as it is not recommended to skip the subtopics because they are interconnected in some way.

Table Content