Skip to content

Instantly share code, notes, and snippets.

@manucabral
Last active December 23, 2021 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manucabral/f5ae25c04a79fe5e1eec867b2a8b215b to your computer and use it in GitHub Desktop.
Save manucabral/f5ae25c04a79fe5e1eec867b2a8b215b to your computer and use it in GitHub Desktop.
"""
Discord Status Changer by ne0de
Needs a file called status.txt
Does not support emojis
This is not allowed by the Discord ToS
"""
from requests import get, patch
from time import sleep
class StatusChanger:
filename = 'status.txt'
url = "https://discord.com/api/v9/users/@me/settings"
def __init__(self, token: str, delay: int):
self.token = token
self.delay = delay
self.status = []
self.header = {'Authorization': self.token}
def check_token(self) -> bool:
return False if get(self.url, headers=self.header).status_code == 401 else True
def set_content_type(self) -> None:
self.header['Content-Type'] = 'application/json'
def read_all_status(self) -> [str]:
status = []
with open(self.filename, 'r') as f:
for line in f:
status.append(line.rstrip())
f.close()
return status
def change_status(self, status: str) -> bool:
data = ({
'custom_status': {
'text': status
}
})
response = patch(self.url, headers=self.header, json=data)
return True if response.status_code == 200 else False
def run(self) -> None:
if not self.check_token():
print('Invalid token')
return
self.set_content_type()
try:
self.status = self.read_all_status()
except FileNotFoundError:
print(filename, 'not found')
return
try:
while True:
for status in self.status:
res = self.change_status(status)
if not res:
print('Error on set status', status)
else:
print('Status changed to:', status)
sleep(self.delay)
except KeyboardInterrupt:
print('Interrupted')
return
if __name__== "__main__":
client = StatusChanger('TOKEN', 1)
client.run()
My status
Me second status
Hello there
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment