From 370c108d9aa7c2c396a43751c2564a7a39694a39 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 17 Sep 2024 11:32:25 +0200 Subject: [PATCH] don't use default bad value, assert instead --- CONTRIBUTING.md | 4 +-- src/buttons/music/queueList-next.ts | 2 +- src/buttons/music/queueList-prec.ts | 2 +- src/commands/loader.ts | 2 +- src/commands/misc/archive.ts | 12 ++++----- src/commands/misc/help.ts | 12 ++++----- src/commands/misc/ping.ts | 4 +-- src/commands/misc/prep.ts | 12 ++++----- src/commands/misc/reminder.ts | 40 ++++++++++++++--------------- src/commands/music/lyrics.ts | 30 ++++++++++------------ src/commands/music/pause.ts | 4 +-- src/commands/music/play.ts | 12 ++++----- src/commands/music/queue.ts | 30 +++++++++++----------- src/commands/music/repeat.ts | 28 ++++++++++---------- src/commands/music/skip.ts | 8 +++--- src/commands/music/stop.ts | 2 +- src/utils/reminder.ts | 2 +- 17 files changed, 97 insertions(+), 109 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 76ebf8a..7302e2f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -124,9 +124,7 @@ export default { const filename = getFilename(__filename); return new SlashCommandBuilder() .setName(filename.toLowerCase()) - .setDescription( - client.locales.get(client.config.default_lang)?.get(`c_${filename}_desc`) ?? "" - ) + .setDescription(client.locales.get(client.config.default_lang)!.get(`c_${filename}_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`)); }, diff --git a/src/buttons/music/queueList-next.ts b/src/buttons/music/queueList-next.ts index a478175..a160587 100644 --- a/src/buttons/music/queueList-next.ts +++ b/src/buttons/music/queueList-next.ts @@ -31,7 +31,7 @@ export default { } // Get queue - const queue = useQueue(interaction.guildId ?? ""); + const queue = useQueue(interaction.guildId!); const embed = new EmbedBuilder(); const rows = []; diff --git a/src/buttons/music/queueList-prec.ts b/src/buttons/music/queueList-prec.ts index 4005788..3260334 100644 --- a/src/buttons/music/queueList-prec.ts +++ b/src/buttons/music/queueList-prec.ts @@ -31,7 +31,7 @@ export default { } // Get queue - const queue = useQueue(interaction.guildId ?? ""); + const queue = useQueue(interaction.guildId!); const embed = new EmbedBuilder(); const rows = []; diff --git a/src/commands/loader.ts b/src/commands/loader.ts index 747a418..d6b3e39 100644 --- a/src/commands/loader.ts +++ b/src/commands/loader.ts @@ -6,7 +6,7 @@ import { removeExtension } from "../utils/misc"; /** Load all the commands */ export default async (client: Client) => { - const rest = new REST({ version: "10" }).setToken(client.token ?? ""); + const rest = new REST({ version: "10" }).setToken(client.token!); const command_categories = (await readdir(__dirname)).filter( (element) => !element.endsWith(".js") && !element.endsWith(".ts"), diff --git a/src/commands/misc/archive.ts b/src/commands/misc/archive.ts index 8f8053f..2fa4bdf 100644 --- a/src/commands/misc/archive.ts +++ b/src/commands/misc/archive.ts @@ -19,9 +19,7 @@ export default { return ( new SlashCommandBuilder() .setName(filename.toLowerCase()) - .setDescription( - client.locales.get(client.config.default_lang)?.get(`c_${filename}_desc`) ?? "", - ) + .setDescription(client.locales.get(client.config.default_lang)!.get(`c_${filename}_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`)) @@ -29,10 +27,10 @@ export default { .addStringOption((option) => option .setName( - client.locales.get(client.config.default_lang)?.get(`c_${filename}_opt1_name`) ?? "", + client.locales.get(client.config.default_lang)!.get(`c_${filename}_opt1_name`)!, ) .setDescription( - client.locales.get(client.config.default_lang)?.get(`c_${filename}_opt1_desc`) ?? "", + client.locales.get(client.config.default_lang)!.get(`c_${filename}_opt1_desc`)!, ) .setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`)), @@ -44,8 +42,8 @@ export default { const loc = getLocale(client, interaction.locale); const desiredCat = interaction.options.get( client.locales - .get(client.config.default_lang) - ?.get(`c_${getFilename(__filename)}_opt1_name`) ?? "", + .get(client.config.default_lang)! + .get(`c_${getFilename(__filename)}_opt1_name`)!, )?.value as string; // If a category isn't specified diff --git a/src/commands/misc/help.ts b/src/commands/misc/help.ts index 48a455c..bd1238b 100644 --- a/src/commands/misc/help.ts +++ b/src/commands/misc/help.ts @@ -13,9 +13,7 @@ export default { return ( new SlashCommandBuilder() .setName(filename.toLowerCase()) - .setDescription( - client.locales.get(client.config.default_lang)?.get(`c_${filename}_desc`) ?? "", - ) + .setDescription(client.locales.get(client.config.default_lang)!.get(`c_${filename}_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`)) @@ -23,10 +21,10 @@ export default { .addStringOption((option) => option .setName( - client.locales.get(client.config.default_lang)?.get(`c_${filename}_opt1_name`) ?? "", + client.locales.get(client.config.default_lang)!.get(`c_${filename}_opt1_name`)!, ) .setDescription( - client.locales.get(client.config.default_lang)?.get(`c_${filename}_opt1_desc`) ?? "", + client.locales.get(client.config.default_lang)!.get(`c_${filename}_opt1_desc`)!, ) .setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`)), @@ -38,8 +36,8 @@ export default { const loc = getLocale(client, interaction.locale); const desired_command = interaction.options.getString( client.locales - .get(client.config.default_lang) - ?.get(`c_${getFilename(__filename)}_opt1_name`) ?? "", + .get(client.config.default_lang)! + .get(`c_${getFilename(__filename)}_opt1_name`)!, ); // If a command isn't specified diff --git a/src/commands/misc/ping.ts b/src/commands/misc/ping.ts index 0d80bc8..b2c98c0 100644 --- a/src/commands/misc/ping.ts +++ b/src/commands/misc/ping.ts @@ -10,9 +10,7 @@ export default { const filename = getFilename(__filename); return new SlashCommandBuilder() .setName(filename.toLowerCase()) - .setDescription( - client.locales.get(client.config.default_lang)?.get(`c_${filename}_desc`) ?? "", - ) + .setDescription(client.locales.get(client.config.default_lang)!.get(`c_${filename}_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`)); }, diff --git a/src/commands/misc/prep.ts b/src/commands/misc/prep.ts index eeffddf..fa4ab30 100644 --- a/src/commands/misc/prep.ts +++ b/src/commands/misc/prep.ts @@ -12,9 +12,7 @@ export default { return ( new SlashCommandBuilder() .setName(filename.toLowerCase()) - .setDescription( - client.locales.get(client.config.default_lang)?.get(`c_${filename}_desc`) ?? "", - ) + .setDescription(client.locales.get(client.config.default_lang)!.get(`c_${filename}_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`)) @@ -22,10 +20,10 @@ export default { .addStringOption((option) => option .setName( - client.locales.get(client.config.default_lang)?.get(`c_${filename}_opt1_name`) ?? "", + client.locales.get(client.config.default_lang)!.get(`c_${filename}_opt1_name`)!, ) .setDescription( - client.locales.get(client.config.default_lang)?.get(`c_${filename}_opt1_desc`) ?? "", + client.locales.get(client.config.default_lang)!.get(`c_${filename}_opt1_desc`)!, ) .setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`)), @@ -37,8 +35,8 @@ export default { const loc = getLocale(client, interaction.locale); const desired_cat = interaction.options.get( client.locales - .get(client.config.default_lang) - ?.get(`c_${getFilename(__filename)}_opt1_name`) ?? "", + .get(client.config.default_lang)! + .get(`c_${getFilename(__filename)}_opt1_name`)!, )?.value as string; // If a category isn't specified diff --git a/src/commands/misc/reminder.ts b/src/commands/misc/reminder.ts index 2d8ca3b..3138a34 100644 --- a/src/commands/misc/reminder.ts +++ b/src/commands/misc/reminder.ts @@ -35,23 +35,23 @@ export default { new SlashCommandBuilder() // Command .setName(filename.toLowerCase()) - .setDescription(loc_default.get(`c_${filename}_desc`) ?? "") + .setDescription(loc_default.get(`c_${filename}_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`)) // New reminder .addSubcommand((subcommand) => subcommand - .setName(loc_default.get(`c_${filename}_sub1_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_sub1_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_sub1_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_sub1_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_sub1_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub1_desc`)) // Specified Time .addStringOption((option) => option - .setName(loc_default.get(`c_${filename}_sub1_opt1_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_sub1_opt1_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_sub1_opt1_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_sub1_opt1_desc`)!) .setNameLocalizations( getLocalizations(client, `c_${filename}_sub1_opt1_name`, true), ) @@ -63,8 +63,8 @@ export default { // Specified message (not required) .addStringOption((option) => option - .setName(loc_default.get(`c_${filename}_sub1_opt2_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_sub1_opt2_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_sub1_opt2_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_sub1_opt2_desc`)!) .setNameLocalizations( getLocalizations(client, `c_${filename}_sub1_opt2_name`, true), ) @@ -77,16 +77,16 @@ export default { // List reminders .addSubcommand((subcommand) => subcommand - .setName(loc_default.get(`c_${filename}_sub2_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_sub2_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_sub2_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_sub2_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_sub2_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub2_desc`)) // User .addUserOption((option) => option - .setName(loc_default.get(`c_${filename}_sub2_opt1_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_sub2_opt1_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_sub2_opt1_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_sub2_opt1_desc`)!) .setNameLocalizations( getLocalizations(client, `c_${filename}_sub2_opt1_name`, true), ) @@ -98,8 +98,8 @@ export default { // Page .addIntegerOption((option) => option - .setName(loc_default.get(`c_${filename}_sub2_opt2_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_sub2_opt2_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_sub2_opt2_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_sub2_opt2_desc`)!) .setNameLocalizations( getLocalizations(client, `c_${filename}_sub2_opt2_name`, true), ) @@ -112,16 +112,16 @@ export default { // Delete a reminder .addSubcommand((subcommand) => subcommand - .setName(loc_default.get(`c_${filename}_sub3_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_sub3_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_sub3_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_sub3_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_sub3_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub3_desc`)) // ID .addIntegerOption((option) => option - .setName(loc_default.get(`c_${filename}_sub3_opt1_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_sub3_opt1_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_sub3_opt1_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_sub3_opt1_desc`)!) .setNameLocalizations( getLocalizations(client, `c_${filename}_sub3_opt1_name`, true), ) @@ -142,7 +142,7 @@ export default { const subcommand = interaction.options.getSubcommand(); switch (subcommand) { // New reminder - case loc_default?.get(`c_${filename}_sub1_name`)?.toLowerCase() ?? "": { + case loc_default?.get(`c_${filename}_sub1_name`)?.toLowerCase(): { // If time is already renseigned const time = interaction.options.getString( loc_default?.get(`c_${filename}_sub1_opt1_name`) as string, @@ -193,7 +193,7 @@ export default { } } // List reminders - case loc_default?.get(`c_${filename}_sub2_name`)?.toLowerCase() ?? "": { + case loc_default?.get(`c_${filename}_sub2_name`)?.toLowerCase(): { // Which user to show let user = interaction.options.getUser( loc_default?.get(`c_${filename}_sub2_opt1_name`) as string, @@ -244,7 +244,7 @@ export default { return; } // Delete a reminder - case loc_default?.get(`c_${filename}_sub3_name`)?.toLowerCase() ?? "": { + case loc_default?.get(`c_${filename}_sub3_name`)?.toLowerCase(): { const id = interaction.options.getInteger( loc_default?.get(`c_${filename}_sub3_opt1_name`) as string, ); diff --git a/src/commands/music/lyrics.ts b/src/commands/music/lyrics.ts index 9369481..3b7dcfb 100644 --- a/src/commands/music/lyrics.ts +++ b/src/commands/music/lyrics.ts @@ -17,23 +17,23 @@ export default { return ( new SlashCommandBuilder() .setName(filename.toLowerCase()) - .setDescription(loc_default.get(`c_${filename}_desc`) ?? "") + .setDescription(loc_default.get(`c_${filename}_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`)) // Normal .addSubcommand((subcommand) => subcommand - .setName(loc_default.get(`c_${filename}_sub1_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_sub1_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_sub1_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_sub1_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_sub1_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub1_desc`)) // Command option .addStringOption((option) => option - .setName(loc_default.get(`c_${filename}_opt1_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_opt1_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_opt1_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_opt1_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`)), ), @@ -42,16 +42,16 @@ export default { // Romanized .addSubcommand((subcommand) => subcommand - .setName(loc_default.get(`c_${filename}_sub2_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_sub2_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_sub2_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_sub2_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_sub2_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub2_desc`)) // Command option .addStringOption((option) => option - .setName(loc_default.get(`c_${filename}_opt1_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_opt1_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_opt1_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_opt1_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`)), ), @@ -60,8 +60,8 @@ export default { // Synced .addSubcommand((subcommand) => subcommand - .setName(loc_default.get(`c_${filename}_sub3_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_sub3_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_sub3_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_sub3_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_sub3_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub3_desc`)), ) @@ -82,12 +82,11 @@ export default { await interaction.deferReply(); const player = useMainPlayer() as Player; - const queue = useQueue(interaction.guildId ?? ""); + const queue = useQueue(interaction.guildId!); if (request) { if ( interaction.options.getSubcommand() == - loc_default?.get(`c_${filename}_sub2_name`)?.toLowerCase() ?? - "" + loc_default?.get(`c_${filename}_sub2_name`)?.toLowerCase() ) { // Romanized request += " romanized"; @@ -113,8 +112,7 @@ export default { if ( interaction.options.getSubcommand() == - loc_default?.get(`c_${filename}_sub3_name`)?.toLowerCase() ?? - "" + loc_default?.get(`c_${filename}_sub3_name`)?.toLowerCase() ) { if (queue === null) { return await interaction.followUp(`❌ | ${loc.get("c_lyrics1")}`); diff --git a/src/commands/music/pause.ts b/src/commands/music/pause.ts index 2f8dc3d..2e60bf6 100644 --- a/src/commands/music/pause.ts +++ b/src/commands/music/pause.ts @@ -16,14 +16,14 @@ export default { return new SlashCommandBuilder() .setName(filename.toLowerCase()) - .setDescription(loc_default.get(`c_${filename}_desc`) ?? "") + .setDescription(loc_default.get(`c_${filename}_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`)); }, interaction: async (interaction: ChatInputCommandInteraction, client: Client) => { const loc = getLocale(client, interaction.locale); - const queue = useQueue(interaction.guildId ?? ""); + const queue = useQueue(interaction.guildId!); if (queue) { const embed = new EmbedBuilder(); diff --git a/src/commands/music/play.ts b/src/commands/music/play.ts index 807c938..bda4646 100644 --- a/src/commands/music/play.ts +++ b/src/commands/music/play.ts @@ -25,15 +25,15 @@ export default { return ( new SlashCommandBuilder() .setName(filename.toLowerCase()) - .setDescription(loc_default.get(`c_${filename}_desc`) ?? "") + .setDescription(loc_default.get(`c_${filename}_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`)) // Command option .addStringOption((option) => option - .setName(loc_default.get(`c_${filename}_opt1_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_opt1_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_opt1_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_opt1_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`)) .setAutocomplete(true), @@ -47,8 +47,8 @@ export default { const filename = getFilename(__filename); const member = client.guilds.cache - .get(interaction.guildId ?? "") - ?.members.cache.get(interaction.member?.user.id ?? ""); + .get(interaction.guildId!) + ?.members.cache.get(interaction.member!.user.id); if (!member?.voice.channelId) { return await interaction.reply({ @@ -75,7 +75,7 @@ export default { if (!query) { // Now playing - const queue = useQueue(interaction.guildId ?? ""); + const queue = useQueue(interaction.guildId!); if (queue) { const track = queue.history.currentTrack; diff --git a/src/commands/music/queue.ts b/src/commands/music/queue.ts index ec6f6a6..2ba005e 100644 --- a/src/commands/music/queue.ts +++ b/src/commands/music/queue.ts @@ -27,23 +27,23 @@ export default { return ( new SlashCommandBuilder() .setName(filename.toLowerCase()) - .setDescription(loc_default.get(`c_${filename}_desc`) ?? "") + .setDescription(loc_default.get(`c_${filename}_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`)) // Show the queue .addSubcommand((subcommand) => subcommand - .setName(loc_default.get(`c_${filename}_sub1_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_sub1_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_sub1_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_sub1_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_sub1_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub1_desc`)) // Specified Page .addNumberOption((option) => option - .setName(loc_default.get(`c_${filename}_sub1_opt1_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_sub1_opt1_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_sub1_opt1_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_sub1_opt1_desc`)!) .setNameLocalizations( getLocalizations(client, `c_${filename}_sub1_opt1_name`, true), ) @@ -56,8 +56,8 @@ export default { // Shuffle Queue .addSubcommand((subcommand) => subcommand - .setName(loc_default.get(`c_${filename}_sub2_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_sub2_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_sub2_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_sub2_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_sub2_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub2_desc`)), ) @@ -65,8 +65,8 @@ export default { // Remove .addSubcommand((subcommand) => subcommand - .setName(loc_default.get(`c_${filename}_sub3_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_sub3_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_sub3_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_sub3_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_sub3_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub3_desc`)) @@ -74,8 +74,8 @@ export default { // TODO?: ID range -> as a string: 5-8 remove 5, 6, 7, 8 .addNumberOption((option) => option - .setName(loc_default.get(`c_${filename}_sub3_opt1_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_sub3_opt1_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_sub3_opt1_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_sub3_opt1_desc`)!) .setNameLocalizations( getLocalizations(client, `c_${filename}_sub3_opt1_name`, true), ) @@ -93,7 +93,7 @@ export default { const filename = getFilename(__filename); const loc = getLocale(client, interaction.locale); - const queue = useQueue(interaction.guildId ?? ""); + const queue = useQueue(interaction.guildId!); const embed = new EmbedBuilder(); @@ -101,7 +101,7 @@ export default { const subcommand = interaction.options.getSubcommand(); switch (subcommand) { // Show the queue - case loc_default?.get(`c_${filename}_sub1_name`)?.toLowerCase() ?? "": { + case loc_default?.get(`c_${filename}_sub1_name`)?.toLowerCase(): { const page = interaction.options.getNumber( loc_default?.get(`c_${filename}_sub1_opt1_name`) as string, @@ -142,7 +142,7 @@ export default { } // Shuffle Queue - case loc_default?.get(`c_${filename}_sub2_name`)?.toLowerCase() ?? "": { + case loc_default?.get(`c_${filename}_sub2_name`)?.toLowerCase(): { queue.tracks.shuffle(); embed.setDescription(loc.get("c_queue3")); @@ -150,7 +150,7 @@ export default { } // Remove - case loc_default?.get(`c_${filename}_sub3_name`)?.toLowerCase() ?? "": { + case loc_default?.get(`c_${filename}_sub3_name`)?.toLowerCase(): { const id = interaction.options.getNumber( loc_default?.get(`c_${filename}_sub3_opt1_name`) as string, ) as number; diff --git a/src/commands/music/repeat.ts b/src/commands/music/repeat.ts index 08d376b..3b131fe 100644 --- a/src/commands/music/repeat.ts +++ b/src/commands/music/repeat.ts @@ -17,15 +17,15 @@ export default { return ( new SlashCommandBuilder() .setName(filename.toLowerCase()) - .setDescription(loc_default.get(`c_${filename}_desc`) ?? "") + .setDescription(loc_default.get(`c_${filename}_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`)) // Disable repeat .addSubcommand((subcommand) => subcommand - .setName(loc_default.get(`c_${filename}_sub1_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_sub1_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_sub1_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_sub1_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_sub1_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub1_desc`)), ) @@ -33,8 +33,8 @@ export default { // Repeat current track .addSubcommand((subcommand) => subcommand - .setName(loc_default.get(`c_${filename}_sub2_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_sub2_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_sub2_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_sub2_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_sub2_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub2_desc`)), ) @@ -42,8 +42,8 @@ export default { // Repeat queue .addSubcommand((subcommand) => subcommand - .setName(loc_default.get(`c_${filename}_sub3_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_sub3_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_sub3_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_sub3_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_sub3_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub3_desc`)), ) @@ -51,8 +51,8 @@ export default { // Enable autoplay .addSubcommand((subcommand) => subcommand - .setName(loc_default.get(`c_${filename}_sub4_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_sub4_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_sub4_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_sub4_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_sub4_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub4_desc`)), ) @@ -64,31 +64,31 @@ export default { const filename = getFilename(__filename); const loc = getLocale(client, interaction.locale); - const queue = useQueue(interaction.guildId ?? ""); + const queue = useQueue(interaction.guildId!); if (queue) { const subcommand = interaction.options.getSubcommand(); switch (subcommand) { // Disable - case loc_default?.get(`c_${filename}_sub1_name`)?.toLowerCase() ?? "": { + case loc_default?.get(`c_${filename}_sub1_name`)?.toLowerCase(): { queue.setRepeatMode(QueueRepeatMode.OFF); return interaction.reply(loc.get("c_repeat2") + "."); } // Queue Repeat - case loc_default?.get(`c_${filename}_sub3_name`)?.toLowerCase() ?? "": { + case loc_default?.get(`c_${filename}_sub3_name`)?.toLowerCase(): { queue.setRepeatMode(QueueRepeatMode.QUEUE); return interaction.reply(`${loc.get("c_repeat3")} ${loc.get("c_repeat6")}.`); } // Autoplay - case loc_default?.get(`c_${filename}_sub4_name`)?.toLowerCase() ?? "": { + case loc_default?.get(`c_${filename}_sub4_name`)?.toLowerCase(): { queue.setRepeatMode(QueueRepeatMode.AUTOPLAY); return interaction.reply(`${loc.get("c_repeat4")} ${loc.get("c_repeat6")}.`); } // Track repeat - case loc_default?.get(`c_${filename}_sub2_name`)?.toLowerCase() ?? "": { + case loc_default?.get(`c_${filename}_sub2_name`)?.toLowerCase(): { queue.setRepeatMode(QueueRepeatMode.TRACK); return interaction.reply( `${loc.get("c_repeat5")} ${queue.history.currentTrack?.title} ${loc.get("c_repeat6")}.`, diff --git a/src/commands/music/skip.ts b/src/commands/music/skip.ts index d17038d..b16da2e 100644 --- a/src/commands/music/skip.ts +++ b/src/commands/music/skip.ts @@ -17,15 +17,15 @@ export default { return ( new SlashCommandBuilder() .setName(filename.toLowerCase()) - .setDescription(loc_default.get(`c_${filename}_desc`) ?? "") + .setDescription(loc_default.get(`c_${filename}_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`)) // Command option .addNumberOption((option) => option - .setName(loc_default.get(`c_${filename}_opt1_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_opt1_desc`) ?? "") + .setName(loc_default.get(`c_${filename}_opt1_name`)!.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_opt1_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`)), ) @@ -37,7 +37,7 @@ export default { const filename = getFilename(__filename); const loc = getLocale(client, interaction.locale); - const queue = useQueue(interaction.guildId ?? ""); + const queue = useQueue(interaction.guildId!); const id = interaction.options.getNumber(loc_default?.get(`c_${filename}_opt1_name`) as string); diff --git a/src/commands/music/stop.ts b/src/commands/music/stop.ts index 6a58220..eed0062 100644 --- a/src/commands/music/stop.ts +++ b/src/commands/music/stop.ts @@ -17,7 +17,7 @@ export default { return new SlashCommandBuilder() .setName(filename.toLowerCase()) - .setDescription(loc_default.get(`c_${filename}_desc`) ?? "") + .setDescription(loc_default.get(`c_${filename}_desc`)!) .setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`)); }, diff --git a/src/utils/reminder.ts b/src/utils/reminder.ts index 58b7f3d..1d065bf 100644 --- a/src/utils/reminder.ts +++ b/src/utils/reminder.ts @@ -168,7 +168,7 @@ export const sendReminder = (client: Client, info: infoReminder, option: OptionR } } else { // Channel - client.channels.fetch(info.channelId ?? "").then((channel) => { + client.channels.fetch(info.channelId!).then((channel) => { if (channel?.isSendable()) { let content = `<@${info.userId}>`; embed.setFooter({ -- 2.45.2