-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheveryone.py
47 lines (43 loc) · 1.75 KB
/
everyone.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
import discord
from datetime import *
from pytz import timezone
from discord.ext import commands
import sqlite3 as sqlite
from discord import app_commands
import sys
import os
from threading import Timer
import asyncio
import util
def add_commands(tree):
@tree.command(name="displayshow", description="Display some details about a specific show.", guild=discord.Object(id=util.GUILD_ID))
async def displayshow(context, name:str):
con = sqlite.connect(util.DB_PATH)
cur = con.cursor()
message = f"Error: show \"{name}\" not found."
for day in util.days_of_week:
result = cur.execute(f"SELECT name, hosts, desc, start_time, end_time, is_running FROM {day} WHERE name = ? COLLATE NOCASE", (name,)).fetchone()
if(not result is None):
message = util.format_show(result[0], result[1], result[2], day, result[3], result[4], result[5])
break
con.close()
await context.response.send_message(message)
@tree.command(name="nowplaying", description="Check the currently playing show.", guild=discord.Object(id=util.GUILD_ID))
async def nowplaying(context):
message = ""
dt = datetime.now(timezone("America/New_York"))
w = dt.weekday()
if(w >= 5):
message = "Nothing is playing right now."
else:
day = util.days_of_week[w]
time = dt.second+dt.minute*60+dt.hour*60*60
con = sqlite.connect(util.DB_PATH)
cur = con.cursor()
result = cur.execute(f"SELECT name, hosts, desc, start_time, end_time, is_running FROM {day} WHERE start_time < ? AND end_time > ? AND is_running = 1", (time, time)).fetchone()
if(result is None):
message = "Nothing is playing right now."
else:
message = util.format_show(result[0], result[1], result[2], day, result[3], result[4], result[5])
con.close()
await context.response.send_message(message)