Last active
November 12, 2019 00:28
-
-
Save Nevexo/1137aff8bba5a80ef07313c4ba826923 to your computer and use it in GitHub Desktop.
This tool will mark all of your Discord Servers as read, getting rid of that pesky NEW thing. Requires Python 3.7+ and a Discord Token.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import time | |
import sys, argparse | |
app_name = "DiscordAckkyBoi"; version = "2.0"; username = "heckboi" | |
base = "https://discordapp.com/api/v6" | |
print(f"[{app_name}/{version}] Hello World!") | |
class Discord: | |
def __init__(self, token): | |
self.token = token | |
self.headers = {"authorization": token} | |
def check_token(self): | |
""" | |
Check the token is valid, also greet the user, cause i'm a good boy""" | |
request = requests.get(f"{base}/users/@me", headers=self.headers) | |
if request.status_code == 200: | |
username = request.json()["username"] | |
print(f"[{app_name}/{version}] Welcome to {app_name}, {username}!") | |
return True | |
elif request.status_code == 401: | |
print(f"[{app_name}/{version}] Invalid token!") | |
else: | |
print(request.text) | |
return False | |
def get_guilds(self): | |
""" | |
Get a list of guilds the user is in""" | |
request = requests.get(f"{base}/users/@me/guilds", headers=self.headers) | |
if request.status_code == 200: | |
return request.json() | |
else: | |
print(request.text) | |
return False | |
def ack_guild(self, guild): | |
request = requests.post(f"{base}/guilds/{guild}/ack", headers=self.headers) | |
if request.status_code == 204: # Success | |
print(f" -> Ack {guild} OK.") | |
else: | |
print(f" -> Ack {guild} Failed. ({request.text})") | |
if __name__ == "__main__": | |
# Check for arguments | |
parser = argparse.ArgumentParser(description=app_name) | |
parser.add_argument("-t", type=str) | |
args = parser.parse_args() | |
token = None | |
if args.t == None: | |
print(f"[{app_name}/{version}] Parse Error: Please provide a token with the -t <token> argument.") | |
sys.exit(2) | |
else: | |
token = args.t | |
discord = Discord(token) | |
if discord.check_token(): | |
# Get list of guilds | |
print(f"[{app_name}/{version}] Getting guilds...") | |
guilds = discord.get_guilds() | |
if guilds != False: | |
print(f"[{app_name}/{version}] Get guilds success, you're in {len(guilds)} guilds!") | |
print(f"[{app_name}/{version}] This will take {len(guilds)} seconds to complete (1/second)") | |
for guild in guilds: | |
# BAD BAD BAD CODE NEV. | |
# I'm sorry | |
name=guild["name"]; guild_id = guild["id"] | |
print(f"[{app_name}/{version}] Ack'ing {name} ({guild_id})...") | |
discord.ack_guild(guild_id) | |
time.sleep(1) | |
print(f"[{app_name}/{version}] All done... for now.") | |
else: | |
print(f"[{app_name}/{version}] Sorry {username}, I failed to get guilds... I'm a bad boy.") | |
exit() | |
else: | |
print("[FAIL] Don't import me! Run me standalone!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment