-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·70 lines (58 loc) · 1.64 KB
/
main.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
#!/usr/bin/env python3
from discord import Embed, Colour, Client, NotFound
from discord.ext import tasks
from secret import TOKEN
DEBUG = False
if DEBUG:
SERVERID = 235478105177718785 # Foobar
CHANNELID = 235478105177718785 # general
MESSAGEFILE = 'message-debug.txt'
try:
with open(MESSAGEFILE, 'r') as f:
MESSAGEID = int(f.read())
except:
MESSAGEID = 766695499532599316
else:
SERVERID = 219564389462704130 # Zeus Operations
CHANNELID = 287747328264372225 # welcome
MESSAGEFILE = 'message.txt'
try:
with open(MESSAGEFILE, 'r') as f:
MESSAGEID = int(f.read())
except:
MESSAGEID = 766703178082287616
client = Client()
URL = "https://banner.zeusops.com/image/banner.png?q={}"
if DEBUG:
URL=f"{URL}&rainbow"
with open('number.txt', 'r') as f:
try:
number = int(f.read())
except:
number = 983
message = None
@tasks.loop(seconds=15)
async def update():
global number
global message
number += 1
with open('number.txt', 'w') as f:
f.write(str(number))
if message:
await message.edit(content=URL.format(number))
@client.event
async def on_ready():
global message
server = client.get_guild(SERVERID)
channel = server.get_channel(CHANNELID)
try:
message = await channel.fetch_message(MESSAGEID)
except NotFound:
message = await channel.send(URL.format(number))
with open(MESSAGEFILE, 'w') as f:
f.write(str(message.id))
else:
await message.edit(content=URL.format(number))
update.start()
if __name__ == "__main__":
client.run(TOKEN)