From 87008a6d5eef31ede133cb259a6572f8220b8e64 Mon Sep 17 00:00:00 2001 From: Georgios Atheridis Date: Sat, 1 Jul 2023 14:22:25 +0100 Subject: [PATCH] Add sub counter command --- ihaspeks/commands/subs.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 ihaspeks/commands/subs.py diff --git a/ihaspeks/commands/subs.py b/ihaspeks/commands/subs.py new file mode 100644 index 0000000..0b0f65e --- /dev/null +++ b/ihaspeks/commands/subs.py @@ -0,0 +1,30 @@ +import os +import sqlite3 + +import tools.smart_privmsg +from aptbot.bot import Bot, Commands, Message + +PERMISSION = 99 +PREFIX = "?" +DESCRIPTION = "" +USER_COOLDOWN = 60 +GLOBAL_COOLDOWN = 30 + + +COMMANDS_PATH = os.path.dirname(os.path.realpath(__file__)) +PATH = os.path.join(COMMANDS_PATH, "..") + + +def main(bot: Bot, message: Message): + conn = sqlite3.connect(os.path.join(PATH, "subathon.db")) + c = conn.cursor() + + c.execute( + f""" + select sum(sub_count) from subs; + """ + ) + fetched = c.fetchone()[0] + conn.close() + msg = f"We are currently sitting at {int(fetched)} SUBS!!!!! ihaspeHappy" + tools.smart_privmsg.send_safe(bot, message.channel, msg) -- 2.30.2