mirror of
https://github.com/TotalFreedomMC/TotalFreedomBot.git
synced 2025-07-27 16:02:07 +00:00
Various formatting
Hopefully this will make the static analysis tool happier
This commit is contained in:
parent
2d2bde604d
commit
866054884a
14 changed files with 202 additions and 147 deletions
18
functions.py
18
functions.py
|
@ -5,16 +5,20 @@ import requests
|
|||
from discord.ext import commands
|
||||
from checks import *
|
||||
|
||||
|
||||
def format_list_entry(embed, list, name):
|
||||
embed.add_field(name="{} ({})".format(name, len(list)), value=", ".join(list), inline=False)
|
||||
embed.add_field(name="{} ({})".format(name, len(list)),
|
||||
value=", ".join(list), inline=False)
|
||||
return embed
|
||||
|
||||
|
||||
|
||||
def did_mention_other_user(users, author):
|
||||
for user in users:
|
||||
if user is not author:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def removed_user_mentions(old, new):
|
||||
users = []
|
||||
for user in old:
|
||||
|
@ -22,6 +26,7 @@ def removed_user_mentions(old, new):
|
|||
users.append(user)
|
||||
return users
|
||||
|
||||
|
||||
def removed_role_mentions(old, new):
|
||||
roles = []
|
||||
for role in old:
|
||||
|
@ -29,6 +34,7 @@ def removed_role_mentions(old, new):
|
|||
roles.append(role)
|
||||
return roles
|
||||
|
||||
|
||||
def get_avatar(user, animate=True):
|
||||
if user.avatar_url:
|
||||
avatar = str(user.avatar_url).replace(".webp", ".png")
|
||||
|
@ -38,20 +44,24 @@ def get_avatar(user, animate=True):
|
|||
avatar = avatar.replace(".gif", ".png")
|
||||
return avatar
|
||||
|
||||
|
||||
def read_json(file_name):
|
||||
with open(f'/root/totalfreedom/{file_name}.json', 'r') as file:
|
||||
data = json.load(file)
|
||||
return data
|
||||
|
||||
|
||||
def write_json(file_name, data):
|
||||
with open(f'/root/totalfreedom/{file_name}.json', 'w') as file:
|
||||
json.dump(data,file,indent=4)
|
||||
json.dump(data, file, indent=4)
|
||||
return data
|
||||
|
||||
|
||||
def hit_endpoint(command):
|
||||
url = [CENSORED_URL]
|
||||
payload = {}
|
||||
headers = {}
|
||||
|
||||
response = json.loads(requests.request("GET", url, headers=headers, data = payload, timeout=100).text)
|
||||
response = json.loads(requests.request(
|
||||
"GET", url, headers=headers, data=payload, timeout=100).text)
|
||||
return response['response']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue