Adding some system info to help command

This commit is contained in:
Noikoio 2018-09-01 13:26:47 -07:00
parent 4bc7836ec0
commit 2735fcb454
2 changed files with 22 additions and 2 deletions

View file

@ -6,6 +6,7 @@ from textwrap import dedent
import discord
import pytz
from datetime import datetime
import subprocess
from userdb import UserDatabase
from common import tzlcmap, logPrint
@ -83,10 +84,18 @@ class WtCommands:
# def cmd_NAME(self, guild: discord.Guild, channel: discord.TextChannel, author: discord.User, msgcontent: str)
async def cmd_help(self, guild: discord.Guild, channel: discord.TextChannel, author: discord.User, msgcontent: str):
# Be a little fancy.
versionstr = subprocess.check_output(["git", "describe", "--always"]).strip()
tzcount = self.userdb.get_unique_tz_count()
em = discord.Embed(
color=14742263,
title='Help & About',
description='This bot aims to answer the age-old question, "What time is it for everyone here?"')
description=dedent('''
"What time is it for everyone here?" - Version `{0}`.
Serving {1} communities across {2} time zones.
'''.format(versionstr, len(self.dclient.guilds), tzcount))
)
em.set_footer(text='World Time', icon_url=self.dclient.user.avatar_url)
em.add_field(name='Commands', value=dedent('''
`tz.help` - This message.

View file

@ -109,4 +109,15 @@ class UserDatabase:
result[row[0]] = []
inlist = result[row[0]]
inlist.append(row[1])
c.close()
return result
def get_unique_tz_count(self):
'''
Gets the number of unique time zones in the database.
'''
c = self.db.cursor()
c.execute('SELECT COUNT(DISTINCT zone) FROM users')
result = c.fetchall()
c.close()
return result[0][0]