-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
99 lines (79 loc) · 3.87 KB
/
app.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import discord
import os
from utils import ping, meme, get_htb_top_100, get_user_info_username, get_user_info_id, get_unreleased
import time as t
token = open('./token.txt', 'r').read()
intents = discord.Intents.all()
intents.message_content = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
# CREATES A COUNTER TO KEEP TRACK OF HOW MANY GUILDS / SERVERS THE BOT IS CONNECTED TO.
guild_count = 0
# LOOPS THROUGH ALL THE GUILD / SERVERS THAT THE BOT IS ASSOCIATED WITH.
for guild in client.guilds:
# PRINT THE SERVER'S ID AND NAME.
print(f"- {guild.id} (name: {guild.name})")
# INCREMENTS THE GUILD COUNTER.
guild_count = guild_count + 1
@client.event
async def on_message(message):
print(message)
if message.author == client.user:
return
if message.content.startswith('$hello'):
c = message.content.replace('$hello ', '')
await message.channel.send(f'Hello {c}!')
if message.content.startswith('$ping') or message.content.startswith('$Ping'):
data = ping()
await message.channel.send(f'pinged google.com with: {data} latency!')
if message.content.startswith('$meme'):
data = meme()
response = f"here's one from {data['sub']} posted by, {data['op']} \n\n{data['title']} \n {data['preview']}"
await message.channel.send(response)
# HTB Stuff
if message.content.startswith('$topusers'):
limit = message.content.replace('$topusers ', '')
if limit == '' or limit == '$topusers':
limit = 5
print(limit)
data = get_htb_top_100(limit)
response = f'obtained the top: {limit} users'
await message.channel.send(response)
place = 1
for user in data:
await message.channel.send(f"""#{place}: {user['country']}'s {user["name"]}, 🩸s:{user["bloods"]}, ♢s:{user["points"]}, and {user['owns']} owns""")
place = place + 1
t.sleep(0.01)
if message.content.startswith('$user'):
user = message.content.replace('$user ', '')
try:
data = get_user_info_username(user)
response = f"user: {data['name']} \n{data['avatar']}\nbloods 🩸: {data['bloods']} \npoints ♢: {data['points']} \nrank: {data['rank']} \nrank progress: {data['rank progress']}% \ncompletion: {data['completion']}% \nglobal rank 🌐: {data['global rank']}"
except:
try:
data = get_user_info_id(user)
response = f"user: {data['name']} \n{data['avatar']}\nbloods 🩸: {data['bloods']} \npoints ♢: {data['points']} \nrank: {data['rank']} \nrank progress: {data['rank progress']}% \ncompletion: {data['completion']}% \nglobal rank 🌐: {data['global rank']}"
except:
response = f"user: {user} not in Elliot's database!"
await message.channel.send(response)
if message.content.startswith('$unreleased'):
machines = get_unreleased()
for machine in machines:
response = f"""machine name: {machine['name']}\n
{machine['avatar']}\n
difficulty: {machine['difficulty']}\n
OS: {machine['os']}\n
creators: {machine['creators']}\n
release data: {machine['release date']}\n\n"""
await message.channel.send(response)
if message.content.startswith('$help'):
response = """Command list: \n
`$unreleased` gets the unreleased machine list\n
`$user` 'id or username'\n
`$topusers` 'top number' gets the top number of users ex: '`$topusers 5`' gets the top 5 users\n
`$hello` 'who to say hello to' \n
`$meme` gets a meme\n
`$ping` pings google.com"""
await message.channel.send(response)
client.run(token)