-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
45 lines (36 loc) · 1.71 KB
/
main.py
File metadata and controls
45 lines (36 loc) · 1.71 KB
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
from discord.ext import commands, tasks
from zoneinfo import ZoneInfo
import discord, datetime, json, os, dotenv
with open("settings.json", "r") as read_file: data = json.load(read_file)
CHANNEL_ID = int(data["channel_id"])
REPORT_TIME0 = datetime.datetime.strptime(data["time0"], '%H:%M')
MESSAGE0 = data["message0"]
#THREAD0 = data["thread0"]
"""REPORT_TIME1 = datetime.datetime.strptime(data["time1"], '%H:%M')
MESSAGE1 = data["message1"]
THREAD1 = data["thread1"]"""
try: TOKEN = os.environ["TOKEN"]
except: TOKEN = dotenv.dotenv_values(".env")["TOKEN"]
intents = discord.Intents.all()
client = commands.Bot(command_prefix='!', intents=intents)
client.remove_command('help')
@client.event
async def on_ready():
task0.start()
#task1.start()
print(f'{client.user} online!')
time0 = datetime.time(hour=REPORT_TIME0.hour, minute=REPORT_TIME0.minute, tzinfo=ZoneInfo("Europe/Prague"))
@tasks.loop(time=time0)
async def task0():
channel = client.get_channel(CHANNEL_ID)
message = await channel.send(MESSAGE0.replace("%date%", datetime.datetime.now().strftime("%d/%m")))
#await channel.create_thread(name=THREAD0.replace("%date%", datetime.datetime.now().strftime("%d/%m")), message=message)
"""time1 = datetime.time(hour=REPORT_TIME1.hour, minute=REPORT_TIME1.minute, tzinfo=ZoneInfo("Europe/Prague"))
@tasks.loop(time=time1)
async def task1():
channel = client.get_channel(CHANNEL_ID)
message = await channel.send(MESSAGE1.replace("%date%", datetime.datetime.now().strftime("%d/%m")))
await channel.create_thread(name=THREAD1.replace("%date%", datetime.datetime.now().strftime("%d/%m")), message=message)
#await message.add_reaction("❌")
#await message.add_reaction("✅")"""
client.run(TOKEN)