Skip to content

Instantly share code, notes, and snippets.

View MrEdinLaw's full-sized avatar

MrEdinLaw MrEdinLaw

View GitHub Profile
@MrEdinLaw
MrEdinLaw / roleTransfer.py
Created March 18, 2024 10:52
Transfer role and username, from one discord server to another
import nextcord
from nextcord.ext import commands
BOT_TOKEN = "your_bot_token_here"
SPECIFIC_ROLE_ID_IN_SERVER_A = 1219228201667133470
ROLE_ID_IN_SERVER_B = 1219228524401917953
SERVER_A_ID = 1219228133727801384
SERVER_B_ID = 1219228491246211103
SERVER_A_CHANNEL = 1219228133727801387
SERVER_B_CHANNEL = 1219228491694870559
@MrEdinLaw
MrEdinLaw / init.py
Created February 18, 2020 19:36
Reddit praw - Comment and Submission stream at once
def submissions_and_comments(subreddit, **kwargs):
results = []
results.extend(subreddit.new(**kwargs))
results.extend(subreddit.comments(**kwargs))
results.sort(key=lambda post: post.created_utc, reverse=True)
return results
subreddit = r.subreddit('redditdev')
stream = praw.models.util.stream_generator(lambda **kwargs: submissions_and_comments(subreddit, **kwargs))
@MrEdinLaw
MrEdinLaw / main.py
Created October 9, 2019 19:30
Widget updater for /r/bannerrequests
# Copyright (C) 2020 Edin Demic @MrEdinLaw - All Rights Reserved
# You may use, and modify this code but not distribute
import praw
import re
from time import sleep
# REST API connection
reddit = praw.Reddit(client_id="",
client_secret="",
@MrEdinLaw
MrEdinLaw / init.py
Created October 1, 2019 12:42
Reddit image poster from folder. Credits to u/CivilizedGravy
import os
import os.path
import praw
# bot login credentials
username = ''
password = ''
@MrEdinLaw
MrEdinLaw / init.py
Last active September 19, 2019 19:22
Randomization of a table with a backup table on the side, using python and sqlite3
import sqlite3
sql_config = sqlite3.connect('Tunes.db')
sql_con = sql_config.cursor()
sql_con.execute("CREATE TABLE IF NOT EXISTS 'temp' (Title TEXT, Length TEXT)") # Create temp table
sql_con.execute("DELETE FROM 'temp'") # Clean temp
# sql_con.execute("vacuum") # Commit clea
sql_con.execute("INSERT INTO 'temp' SELECT * FROM Tunes") # Copy Data to temp
sql_con.execute("DELETE FROM 'Tunes'") # Clean Tunes