From 17643dc7302c1dc62f1fc65fe746dc847536e714 Mon Sep 17 00:00:00 2001 From: ashley zomo Date: Sun, 13 Feb 2022 19:23:28 -0600 Subject: [PATCH] updated lang strings --- dist/lang.js | 13 ++++++++++--- dist/queue.js | 10 +++++----- dist/util.js | 9 +++++---- src/lang.ts | 13 ++++++++++--- src/queue.ts | 10 +++++----- src/util.ts | 9 +++++---- 6 files changed, 40 insertions(+), 24 deletions(-) diff --git a/dist/lang.js b/dist/lang.js index b908234..201a6b9 100644 --- a/dist/lang.js +++ b/dist/lang.js @@ -8,13 +8,20 @@ const LANG = { create: 'A queue for teams of {teamsize} has been created', close: 'Queue has been closed', join: 'Joined the queue', - leave: 'Left the queue', - error: { + leave: 'Left the queue' + }, + error: { + discord: { noQueue: 'There is not an active queue in this channel, type `/open` to create one', noChannel: 'Unable to find channel {channelId} for teams of {teamsize}', noCreate: 'There is already an active queue in this channel for teams of ${teamsize}', inQueue: 'You are already in the queue', - notInQueue: 'You aren\'t in the queue' + notInQueue: 'You aren\'t in the queue', + notMod: 'Member is not a moderator' + }, + general: { + noMember: 'Unable to retrieve guild member information, please try again', + noChannel: 'Unable to retrieve text channel information, please try again' } } } diff --git a/dist/queue.js b/dist/queue.js index af574d1..697574b 100644 --- a/dist/queue.js +++ b/dist/queue.js @@ -98,7 +98,7 @@ async function discordInit(client) { continue; } if (!channel || !(channel instanceof discord_js_1.TextChannel)) { - console.error(lang_1.Lang.get('discord.error.noChannel'), { + console.error(lang_1.Lang.get('error.discord.noChannel'), { channelId, teamsize: info.teamsize }); @@ -120,7 +120,7 @@ var QueueCommands; function getInfo(interaction) { let info = QUEUE.get(interaction.channelId); if (!info) - throw (0, util_1.emsg)(lang_1.Lang.get('discord.error.noQueue')); + throw (0, util_1.emsg)('discord.noQueue'); return info; } /** @@ -155,7 +155,7 @@ var QueueCommands; (0, util_1.memberIsModThrow)(interaction); let { channelId } = interaction, teamsize = interaction.options.getInteger('teamsize', true); if (QUEUE.has(channelId)) - throw (0, util_1.emsg)(lang_1.Lang.get('discord.error.noCreate', { + throw (0, util_1.emsg)(lang_1.Lang.get('error.discord.noCreate', { teamsize: QUEUE.get(channelId)?.teamsize })); Queue.create(channelId, teamsize); @@ -207,7 +207,7 @@ var QueueCommands; async function join(interaction) { let { member, info, channel } = getAll(interaction); if (queueContains(interaction)) - throw (0, util_1.emsg)(lang_1.Lang.get('discord.error.inQueue')); + throw (0, util_1.emsg)('discord.inQueue'); info.players.push(member); QUEUE.set(interaction.channelId, info); await interaction.reply(lang_1.Lang.get('discord.join')); @@ -222,7 +222,7 @@ var QueueCommands; async function leave(interaction) { let { member, info } = getAll(interaction); if (!queueContains(interaction)) - throw (0, util_1.emsg)(lang_1.Lang.get('discord.error.notInQueue')); + throw (0, util_1.emsg)('discord.notInQueue'); info.players.splice(info.players.indexOf(member), 1); QUEUE.set(interaction.channelId, info); await interaction.reply(lang_1.Lang.get('discord.leave')); diff --git a/dist/util.js b/dist/util.js index 6c1c30e..929aa42 100644 --- a/dist/util.js +++ b/dist/util.js @@ -2,6 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.memberIsModThrow = exports.memberIsMod = exports.getChannel = exports.getMember = exports.emsg = exports.errorMessage = exports.shuffle = void 0; const discord_js_1 = require("discord.js"); +const lang_1 = require("./lang"); /** * shuffles an array * https://stackoverflow.com/a/2450976/2856416 @@ -36,7 +37,7 @@ exports.errorMessage = errorMessage; * @param ephemeral (default=true) * @returns new errorMessage */ -const emsg = (msg, ephemeral = true) => new errorMessage(msg, ephemeral); +const emsg = (msg, ephemeral = true) => new errorMessage(lang_1.Lang.get(`error.${msg}`), ephemeral); exports.emsg = emsg; /** * get the GuildMember of an interaction @@ -47,7 +48,7 @@ exports.emsg = emsg; function getMember(interaction) { let member = interaction.member; if (!(member instanceof discord_js_1.GuildMember)) - throw (0, exports.emsg)('Unable to retrieve guild member information, please try again'); + throw (0, exports.emsg)('general.noMember'); return member; } exports.getMember = getMember; @@ -60,7 +61,7 @@ exports.getMember = getMember; function getChannel(interaction) { let channel = interaction.channel; if (!(channel instanceof discord_js_1.TextChannel)) - throw (0, exports.emsg)('Unable to retrieve text channel information, please try again'); + throw (0, exports.emsg)('general.noChannel'); return channel; } exports.getChannel = getChannel; @@ -71,6 +72,6 @@ function memberIsMod(interaction) { exports.memberIsMod = memberIsMod; function memberIsModThrow(interaction) { if (!memberIsMod(interaction)) - throw (0, exports.emsg)('Member is not a moderator'); + throw (0, exports.emsg)('discord.notMod'); } exports.memberIsModThrow = memberIsModThrow; diff --git a/src/lang.ts b/src/lang.ts index a42585e..438d43b 100644 --- a/src/lang.ts +++ b/src/lang.ts @@ -8,13 +8,20 @@ const LANG: LangObjWhold = { create: 'A queue for teams of {teamsize} has been created', close: 'Queue has been closed', join: 'Joined the queue', - leave: 'Left the queue', - error: { + leave: 'Left the queue' + }, + error: { + discord: { noQueue: 'There is not an active queue in this channel, type `/open` to create one', noChannel: 'Unable to find channel {channelId} for teams of {teamsize}', noCreate: 'There is already an active queue in this channel for teams of ${teamsize}', inQueue: 'You are already in the queue', - notInQueue: 'You aren\'t in the queue' + notInQueue: 'You aren\'t in the queue', + notMod: 'Member is not a moderator' + }, + general: { + noMember: 'Unable to retrieve guild member information, please try again', + noChannel: 'Unable to retrieve text channel information, please try again' } } } diff --git a/src/queue.ts b/src/queue.ts index 4ad4e6f..e0ea0bd 100644 --- a/src/queue.ts +++ b/src/queue.ts @@ -104,7 +104,7 @@ export async function discordInit(client: Client) { } if (!channel || !(channel instanceof TextChannel)) { - console.error(Lang.get('discord.error.noChannel'), { + console.error(Lang.get('error.discord.noChannel'), { channelId, teamsize: info.teamsize }); @@ -129,7 +129,7 @@ export namespace QueueCommands { let info = QUEUE.get(interaction.channelId); if (!info) - throw emsg(Lang.get('discord.error.noQueue')); + throw emsg('discord.noQueue'); return info; } @@ -174,7 +174,7 @@ export namespace QueueCommands { teamsize = interaction.options.getInteger('teamsize', true); if (QUEUE.has(channelId)) - throw emsg(Lang.get('discord.error.noCreate', { + throw emsg(Lang.get('error.discord.noCreate', { teamsize: QUEUE.get(channelId)?.teamsize })); @@ -240,7 +240,7 @@ export namespace QueueCommands { let {member, info, channel} = getAll(interaction); if (queueContains(interaction)) - throw emsg(Lang.get('discord.error.inQueue')); + throw emsg('discord.inQueue'); info.players.push(member); @@ -262,7 +262,7 @@ export namespace QueueCommands { let {member, info} = getAll(interaction); if (!queueContains(interaction)) - throw emsg(Lang.get('discord.error.notInQueue')); + throw emsg('discord.notInQueue'); info.players.splice(info.players.indexOf(member), 1); diff --git a/src/util.ts b/src/util.ts index a9e324d..37effb1 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,4 +1,5 @@ import { CommandInteraction, GuildMember, TextChannel } from "discord.js"; +import { Lang } from "./lang"; /** * shuffles an array @@ -42,7 +43,7 @@ export class errorMessage { * @param ephemeral (default=true) * @returns new errorMessage */ -export const emsg = (msg: string, ephemeral: boolean = true) => new errorMessage(msg, ephemeral); +export const emsg = (msg: string, ephemeral: boolean = true) => new errorMessage(Lang.get(`error.${msg}`), ephemeral); @@ -63,7 +64,7 @@ export function getMember(interaction: CommandInteraction): GuildMember { let member = interaction.member; if (!(member instanceof GuildMember)) - throw emsg('Unable to retrieve guild member information, please try again'); + throw emsg('general.noMember'); return member; } @@ -78,7 +79,7 @@ export function getChannel(interaction: CommandInteraction): TextChannel { let channel = interaction.channel; if (!(channel instanceof TextChannel)) - throw emsg('Unable to retrieve text channel information, please try again'); + throw emsg('general.noChannel'); return channel; } @@ -91,5 +92,5 @@ export function memberIsMod(interaction: CommandInteraction): boolean { export function memberIsModThrow(interaction: CommandInteraction) { if (!memberIsMod(interaction)) - throw emsg('Member is not a moderator'); + throw emsg('discord.notMod'); }