Skip to content

Instantly share code, notes, and snippets.

@whinee
Last active October 31, 2021 15:27
Show Gist options
  • Save whinee/0b6603b2358efdaa5f9e740875ad51c7 to your computer and use it in GitHub Desktop.
Save whinee/0b6603b2358efdaa5f9e740875ad51c7 to your computer and use it in GitHub Desktop.
Collection of scripts that (ab)uses Discord's API to do a specific task

(Ab)User

Collection of scripts that (ab)uses Discord's API to do a specific task.

Scripts:

  • constantNickname:

    Will revert your nickname back if somebody changed your nickname. Needs a "CHANGE_NICKNAME" permission.

    Usage

    Put your token, server id, and nickname in a .env file in the same directory as shown below:

    NICK=<nickname>
    SERVER=<server id>
    TOKEN=<token>

    ps: will add support for multiple servers later

import httpx
import time
from typing import Any, Dict, List
from functools import partial
from dotenv import load_dotenv
import os
load_dotenv()
class ENV:
pass
for i in ["NICK", "SERVER", "TOKEN"]:
setattr(ENV, i, os.environ[i])
headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": ENV.TOKEN,
}
session = httpx.Client()
def ra(resp: httpx.Response) -> int:
op = int(resp.headers["X-RateLimit-Reset"]) - int(time.time()) + 1
return op
def _req(url: str, method: str = "get", *args: List[Any], **kwargs: Dict[str, Any]):
resp = getattr(session, method)(url, *args, **kwargs)
if resp.status_code == 429:
if ra:
time.sleep(ra(resp))
return req(url, method, *args, **kwargs)
return resp
class req:
pass
for i in ["get", "options", "head", "post", "put", "patch", "delete"]:
setattr(req, i, partial(_req, ra=ra, method=i))
UID = httpx.get("https://canary.discord.com/api/v9/users/@me", headers=headers).json()["id"]
while 1:
if ENV.NICK != req.get(f"https://canary.discord.com/api/v9/guilds/{ENV.SERVER}/members/{UID}", headers=headers).json()["nick"]:
req.patch(f"https://canary.discord.com/api/v9/guilds/{ENV.SERVER}/members/@me", headers=headers, json={"nick": ENV.NICK})
time.sleep(5)

Copyright (c) 2021 Github Account whinee Owner

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment