From fedad8df3ed1e00ba4a9389541133823efa2504a Mon Sep 17 00:00:00 2001 From: tresabhi Date: Tue, 11 Jul 2023 19:00:10 +0000 Subject: [PATCH] feat: added timezone help --- docs/guide/timezones.md | 9 +++++++ src/commands/help.ts | 57 +++++++++++++++++++++++------------------ 2 files changed, 41 insertions(+), 25 deletions(-) create mode 100644 docs/guide/timezones.md diff --git a/docs/guide/timezones.md b/docs/guide/timezones.md new file mode 100644 index 000000000..3b344cc55 --- /dev/null +++ b/docs/guide/timezones.md @@ -0,0 +1,9 @@ +# Timezones + +What is considered a "day's worth of games" is determined by the reset time. The reset time is generally at midnight everyday after which newer games are counted towards the next day. Reset times vary from region to region: + +- North America: UTC-5:00 (Central North American Time midnight) +- Europe: UTC+1:00 (Central European Time midnight) +- Asia: UTC+7:00 (Central Asia Standard Time midnight) + +**Reset times are different from Blitz Stars** (Blitz Stars resets at 5:00 am locally relative to the user opening their website). Inconsistencies with Blitz Stars only occur with sleep-deprived players and players who play in the wrong region. diff --git a/src/commands/help.ts b/src/commands/help.ts index 210a68980..c5bd5135f 100644 --- a/src/commands/help.ts +++ b/src/commands/help.ts @@ -1,44 +1,51 @@ -import { SlashCommandBuilder } from 'discord.js'; +import { + SlashCommandBuilder, + SlashCommandSubcommandsOnlyBuilder, +} from 'discord.js'; import { COMMANDS_RAW, CommandRegistry, } from '../events/interactionCreate/index.js'; const RAW_PATH = `https://raw.githubusercontent.com/tresabhi/blitzkrieg/main/docs/`; -const DOCS: Record = { +const DOCS = { permissions: 'guide/permissions', embeds: 'guide/embeds', about: 'guide/about', invite: 'guide/invite', + timezones: 'guide/timezones', }; +const DOC_DESCRIPTIONS: Record = { + permissions: 'The permissions needed for the bot to function', + embeds: 'How embeds work', + about: 'About the bot', + invite: 'How to invite the bot', + timezones: 'How Blitzkrieg infers and uses your timezone', +}; + +function addDocsSubcommands(option: SlashCommandSubcommandsOnlyBuilder) { + Object.entries(DOC_DESCRIPTIONS).forEach(([key, value]) => { + option.addSubcommand((sub) => sub.setName(key).setDescription(value)); + }); + + return option; +} export const helpCommand: CommandRegistry = { inProduction: true, inDevelopment: true, inPublic: true, - command: new SlashCommandBuilder() - .setName('help') - .setDescription('All the help you need about the bot') - .addSubcommand((option) => - option - .setName('commands') - .setDescription('List of all commands and their descriptions'), - ) - .addSubcommand((option) => - option - .setName('permissions') - .setDescription('The permissions needed for the bot to function'), - ) - .addSubcommand((option) => - option.setName('about').setDescription('About the bot'), - ) - .addSubcommand((option) => - option.setName('embeds').setDescription('How embeds work'), - ) - .addSubcommand((option) => - option.setName('invite').setDescription('How to invite the bot'), - ), + command: addDocsSubcommands( + new SlashCommandBuilder() + .setName('help') + .setDescription('All the help you need about the bot') + .addSubcommand((option) => + option + .setName('commands') + .setDescription('List of all commands and their descriptions'), + ), + ), handler(interaction) { const subcommand = interaction.options.getSubcommand(); @@ -54,7 +61,7 @@ export const helpCommand: CommandRegistry = { .join('\n')}`; } - const url = `${RAW_PATH}${DOCS[subcommand]}.md`; + const url = `${RAW_PATH}${DOCS[subcommand as keyof typeof DOCS]}.md`; const content = fetch(url).then((response) => response.text()); return content;