From 04cd205fee04d5f732d219c6dd0e8203da69c87c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sat, 16 Mar 2024 15:07:05 -0500 Subject: [PATCH] feat: preview servers --- src/commands/research.tsx | 1 + .../handlers/chatInputCommand.ts | 15 +++++++++++++++ src/events/interactionCreate/index.ts | 1 + src/lang/en-US.json | 3 ++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/commands/research.tsx b/src/commands/research.tsx index 246a28d60..43dc84788 100644 --- a/src/commands/research.tsx +++ b/src/commands/research.tsx @@ -31,6 +31,7 @@ export const researchCommand = new Promise((resolve) => { resolve({ inProduction: true, inPublic: true, + inPreview: true, command: createLocalizedCommand('research') .addStringOption((option) => diff --git a/src/events/interactionCreate/handlers/chatInputCommand.ts b/src/events/interactionCreate/handlers/chatInputCommand.ts index 9d796176b..a3208c3a2 100644 --- a/src/events/interactionCreate/handlers/chatInputCommand.ts +++ b/src/events/interactionCreate/handlers/chatInputCommand.ts @@ -15,6 +15,11 @@ import { psa } from '../../../core/discord/psa'; import { translator } from '../../../core/localization/translator'; import { UserError } from '../../../hooks/userError'; +const previewServers = [ + '734786591205359697', // abhi + '460165161156870161', // optml +]; + export default async function handleChatInputCommand( interaction: ChatInputCommandInteraction, ) { @@ -24,6 +29,16 @@ export default async function handleChatInputCommand( await interaction.deferReply(); try { + if ( + registry.inPreview && + !previewServers.includes(`${interaction.guildId}`) + ) { + const { t } = translator(interaction.locale); + interaction.editReply(t`bot.common.errors.preview`); + + return; + } + const returnable = await registry.handler(interaction); if (registry.handlesInteraction) return; diff --git a/src/events/interactionCreate/index.ts b/src/events/interactionCreate/index.ts index 25a277c53..bcbdcfe95 100644 --- a/src/events/interactionCreate/index.ts +++ b/src/events/interactionCreate/index.ts @@ -55,6 +55,7 @@ export type InteractionReturnable = interface CommandRegistryBase { inProduction: boolean; inPublic: boolean; + inPreview?: boolean; command: | SlashCommandBuilder diff --git a/src/lang/en-US.json b/src/lang/en-US.json index fc270bf77..c07c3eff5 100644 --- a/src/lang/en-US.json +++ b/src/lang/en-US.json @@ -190,7 +190,8 @@ "tank_id_not_found": "# Tank not found\nCould not find tank by the ID \"%s\". Try typing the name of the tank instead of a number.", "no_tank_stats": "# No tank stats available\nThis player doesn't have any stats available. This may not be the player you are looking for.", "get_help": "Help Discord server", - "uncaught_error": "# Blitzkrieg ran into an error!\nWe're so sorry about this. Feel free to [join the official Discord server](https://discord.gg/nDt7AjGJQH) to get help." + "uncaught_error": "# Blitzkrieg ran into an error!\nWe're so sorry about this. Feel free to [join the official Discord server](https://discord.gg/nDt7AjGJQH) to get help.", + "preview": "# This command is in preview\n\nYou can only access this command in [the official Discord server](https://discord.gg/nDt7AjGJQH). The command will be generally available soon." } },