-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathattribs.py
58 lines (51 loc) · 2.05 KB
/
attribs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from random import randint
from variables import attributes, attributes_nsfw
import pandas as pd
from tabulate import tabulate
def write_top100(username, user_input):
with open("top100.csv", "a") as file:
file.writelines(f"\n{username.lower()}; {user_input}")
return
def get_attr(user_input, usermention, channel, username):
# Convert discord module objects to strings.
user_input = str(user_input)
channel = str(channel)
username = str(username)
attributes.sort()
attributes_nsfw.sort()
attr_list = ", ".join(attributes)
attr_nsfw_list = ", ".join(attributes_nsfw)
if user_input == "help" and channel.startswith("nsfw"):
return f"""# __Carnage Commands__ (attr)
Here is the full list of currently available attributes **({len(attributes)})**:
{attr_list}
NSFW attributes 😈 **({len(attributes_nsfw)})**:
{attr_nsfw_list}
"""
elif user_input == "help":
attributes.sort()
attributes_nsfw.sort()
return f"""# __Carnage Commands__ (attr)
Here is the full list of currently available attributes **({len(attributes)})**:
{attr_list}
"""
elif user_input == "top":
df = pd.read_csv("top100.csv", sep=";")
return tabulate(
df, headers=["Username", "Attribute"], tablefmt="simple", showindex=False
)
if (
channel.startswith("nsfw")
and user_input in attributes
or user_input in attr_nsfw_list
):
return f"{usermention} is {randint(0, 100)}% {user_input} 😈"
elif user_input in attributes:
percentage = randint(0, 100)
if percentage == 100:
write_top100(username, user_input)
return f"# Congratulations!!!\n{usermention} is {percentage}% {user_input} and has been added to our TOP 100 hall of fame"
else:
return f"{usermention} is {percentage}% {user_input}"
else:
return f"{usermention} '{user_input}' is not a valid attribute. To view a current list of valid attributes ,type `,attr help`"