updated lang strings

This commit is contained in:
2022-02-13 19:23:28 -06:00
parent f225bf924a
commit 17643dc730
6 changed files with 40 additions and 24 deletions

13
dist/lang.js vendored
View File

@@ -8,13 +8,20 @@ const LANG = {
create: 'A queue for teams of {teamsize} has been created', create: 'A queue for teams of {teamsize} has been created',
close: 'Queue has been closed', close: 'Queue has been closed',
join: 'Joined the queue', join: 'Joined the queue',
leave: 'Left the queue', leave: 'Left the queue'
error: { },
error: {
discord: {
noQueue: 'There is not an active queue in this channel, type `/open` to create one', 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}', noChannel: 'Unable to find channel {channelId} for teams of {teamsize}',
noCreate: 'There is already an active queue in this channel 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', 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'
} }
} }
} }

10
dist/queue.js vendored
View File

@@ -98,7 +98,7 @@ async function discordInit(client) {
continue; continue;
} }
if (!channel || !(channel instanceof discord_js_1.TextChannel)) { 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, channelId,
teamsize: info.teamsize teamsize: info.teamsize
}); });
@@ -120,7 +120,7 @@ var QueueCommands;
function getInfo(interaction) { function getInfo(interaction) {
let info = QUEUE.get(interaction.channelId); let info = QUEUE.get(interaction.channelId);
if (!info) if (!info)
throw (0, util_1.emsg)(lang_1.Lang.get('discord.error.noQueue')); throw (0, util_1.emsg)('discord.noQueue');
return info; return info;
} }
/** /**
@@ -155,7 +155,7 @@ var QueueCommands;
(0, util_1.memberIsModThrow)(interaction); (0, util_1.memberIsModThrow)(interaction);
let { channelId } = interaction, teamsize = interaction.options.getInteger('teamsize', true); let { channelId } = interaction, teamsize = interaction.options.getInteger('teamsize', true);
if (QUEUE.has(channelId)) 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 teamsize: QUEUE.get(channelId)?.teamsize
})); }));
Queue.create(channelId, teamsize); Queue.create(channelId, teamsize);
@@ -207,7 +207,7 @@ var QueueCommands;
async function join(interaction) { async function join(interaction) {
let { member, info, channel } = getAll(interaction); let { member, info, channel } = getAll(interaction);
if (queueContains(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); info.players.push(member);
QUEUE.set(interaction.channelId, info); QUEUE.set(interaction.channelId, info);
await interaction.reply(lang_1.Lang.get('discord.join')); await interaction.reply(lang_1.Lang.get('discord.join'));
@@ -222,7 +222,7 @@ var QueueCommands;
async function leave(interaction) { async function leave(interaction) {
let { member, info } = getAll(interaction); let { member, info } = getAll(interaction);
if (!queueContains(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); info.players.splice(info.players.indexOf(member), 1);
QUEUE.set(interaction.channelId, info); QUEUE.set(interaction.channelId, info);
await interaction.reply(lang_1.Lang.get('discord.leave')); await interaction.reply(lang_1.Lang.get('discord.leave'));

9
dist/util.js vendored
View File

@@ -2,6 +2,7 @@
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.memberIsModThrow = exports.memberIsMod = exports.getChannel = exports.getMember = exports.emsg = exports.errorMessage = exports.shuffle = void 0; exports.memberIsModThrow = exports.memberIsMod = exports.getChannel = exports.getMember = exports.emsg = exports.errorMessage = exports.shuffle = void 0;
const discord_js_1 = require("discord.js"); const discord_js_1 = require("discord.js");
const lang_1 = require("./lang");
/** /**
* shuffles an array * shuffles an array
* https://stackoverflow.com/a/2450976/2856416 * https://stackoverflow.com/a/2450976/2856416
@@ -36,7 +37,7 @@ exports.errorMessage = errorMessage;
* @param ephemeral (default=true) * @param ephemeral (default=true)
* @returns new errorMessage * @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; exports.emsg = emsg;
/** /**
* get the GuildMember of an interaction * get the GuildMember of an interaction
@@ -47,7 +48,7 @@ exports.emsg = emsg;
function getMember(interaction) { function getMember(interaction) {
let member = interaction.member; let member = interaction.member;
if (!(member instanceof discord_js_1.GuildMember)) 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; return member;
} }
exports.getMember = getMember; exports.getMember = getMember;
@@ -60,7 +61,7 @@ exports.getMember = getMember;
function getChannel(interaction) { function getChannel(interaction) {
let channel = interaction.channel; let channel = interaction.channel;
if (!(channel instanceof discord_js_1.TextChannel)) 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; return channel;
} }
exports.getChannel = getChannel; exports.getChannel = getChannel;
@@ -71,6 +72,6 @@ function memberIsMod(interaction) {
exports.memberIsMod = memberIsMod; exports.memberIsMod = memberIsMod;
function memberIsModThrow(interaction) { function memberIsModThrow(interaction) {
if (!memberIsMod(interaction)) if (!memberIsMod(interaction))
throw (0, exports.emsg)('Member is not a moderator'); throw (0, exports.emsg)('discord.notMod');
} }
exports.memberIsModThrow = memberIsModThrow; exports.memberIsModThrow = memberIsModThrow;

View File

@@ -8,13 +8,20 @@ const LANG: LangObjWhold = {
create: 'A queue for teams of {teamsize} has been created', create: 'A queue for teams of {teamsize} has been created',
close: 'Queue has been closed', close: 'Queue has been closed',
join: 'Joined the queue', join: 'Joined the queue',
leave: 'Left the queue', leave: 'Left the queue'
error: { },
error: {
discord: {
noQueue: 'There is not an active queue in this channel, type `/open` to create one', 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}', noChannel: 'Unable to find channel {channelId} for teams of {teamsize}',
noCreate: 'There is already an active queue in this channel 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', 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'
} }
} }
} }

View File

@@ -104,7 +104,7 @@ export async function discordInit(client: Client) {
} }
if (!channel || !(channel instanceof TextChannel)) { if (!channel || !(channel instanceof TextChannel)) {
console.error(Lang.get('discord.error.noChannel'), { console.error(Lang.get('error.discord.noChannel'), {
channelId, channelId,
teamsize: info.teamsize teamsize: info.teamsize
}); });
@@ -129,7 +129,7 @@ export namespace QueueCommands {
let info = QUEUE.get(interaction.channelId); let info = QUEUE.get(interaction.channelId);
if (!info) if (!info)
throw emsg(Lang.get('discord.error.noQueue')); throw emsg('discord.noQueue');
return info; return info;
} }
@@ -174,7 +174,7 @@ export namespace QueueCommands {
teamsize = interaction.options.getInteger('teamsize', true); teamsize = interaction.options.getInteger('teamsize', true);
if (QUEUE.has(channelId)) if (QUEUE.has(channelId))
throw emsg(Lang.get('discord.error.noCreate', { throw emsg(Lang.get('error.discord.noCreate', {
teamsize: QUEUE.get(channelId)?.teamsize teamsize: QUEUE.get(channelId)?.teamsize
})); }));
@@ -240,7 +240,7 @@ export namespace QueueCommands {
let {member, info, channel} = getAll(interaction); let {member, info, channel} = getAll(interaction);
if (queueContains(interaction)) if (queueContains(interaction))
throw emsg(Lang.get('discord.error.inQueue')); throw emsg('discord.inQueue');
info.players.push(member); info.players.push(member);
@@ -262,7 +262,7 @@ export namespace QueueCommands {
let {member, info} = getAll(interaction); let {member, info} = getAll(interaction);
if (!queueContains(interaction)) if (!queueContains(interaction))
throw emsg(Lang.get('discord.error.notInQueue')); throw emsg('discord.notInQueue');
info.players.splice(info.players.indexOf(member), 1); info.players.splice(info.players.indexOf(member), 1);

View File

@@ -1,4 +1,5 @@
import { CommandInteraction, GuildMember, TextChannel } from "discord.js"; import { CommandInteraction, GuildMember, TextChannel } from "discord.js";
import { Lang } from "./lang";
/** /**
* shuffles an array * shuffles an array
@@ -42,7 +43,7 @@ export class errorMessage {
* @param ephemeral (default=true) * @param ephemeral (default=true)
* @returns new errorMessage * @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; let member = interaction.member;
if (!(member instanceof GuildMember)) if (!(member instanceof GuildMember))
throw emsg('Unable to retrieve guild member information, please try again'); throw emsg('general.noMember');
return member; return member;
} }
@@ -78,7 +79,7 @@ export function getChannel(interaction: CommandInteraction): TextChannel {
let channel = interaction.channel; let channel = interaction.channel;
if (!(channel instanceof TextChannel)) if (!(channel instanceof TextChannel))
throw emsg('Unable to retrieve text channel information, please try again'); throw emsg('general.noChannel');
return channel; return channel;
} }
@@ -91,5 +92,5 @@ export function memberIsMod(interaction: CommandInteraction): boolean {
export function memberIsModThrow(interaction: CommandInteraction) { export function memberIsModThrow(interaction: CommandInteraction) {
if (!memberIsMod(interaction)) if (!memberIsMod(interaction))
throw emsg('Member is not a moderator'); throw emsg('discord.notMod');
} }