updated lang strings

This commit is contained in:
2022-02-13 19:15:55 -06:00
parent 9da9650f92
commit f225bf924a
4 changed files with 62 additions and 27 deletions

14
dist/lang.js vendored
View File

@@ -4,8 +4,17 @@ exports.Lang = void 0;
const LANG = {
en: {
discord: {
botRestart: 'The bot has just restarted, anybody previously in the queue has been reset',
create: 'A queue for teams of {teamsize} has been created',
close: 'Queue has been closed',
join: 'Joined the queue',
leave: 'Left the queue',
error: {
noActiveQueue: '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}',
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'
}
}
}
@@ -27,7 +36,7 @@ var Lang;
* @param id ex: discord.error.noActiveQueue
* @returns language value, defaults to `id` parameter
*/
function get(id) {
function get(id, args = {}) {
let keySpl = id.split('.').map(k => k.trim()).filter(k => k);
let finding = LANG[LANGID];
for (let key of keySpl) {
@@ -44,4 +53,3 @@ var Lang;
}
Lang.get = get;
})(Lang = exports.Lang || (exports.Lang = {}));
debugger;

31
dist/queue.js vendored
View File

@@ -27,6 +27,7 @@ exports.QueueCommands = exports.discordInit = void 0;
const discord_js_1 = require("discord.js");
const fs = __importStar(require("fs"));
const util_1 = require("./util");
const lang_1 = require("./lang");
//load queues from file
if (!fs.existsSync('./queues.json'))
fs.writeFileSync('./queues.json', '{}');
@@ -52,6 +53,7 @@ async function checkQueue(channel) {
return;
if (info.players.length >= info.teamsize) {
let team = info.players.splice(0, info.teamsize).map(m => m.toString());
//TODO add embeds to lang.ts
let embed = new discord_js_1.MessageEmbed()
.setTitle('Team')
.setDescription(team.join('\n'));
@@ -96,11 +98,14 @@ async function discordInit(client) {
continue;
}
if (!channel || !(channel instanceof discord_js_1.TextChannel)) {
console.error(`Unable to find channel ${channelId} for teams of ${info?.teamsize}`);
console.error(lang_1.Lang.get('discord.error.noChannel'), {
channelId,
teamsize: info.teamsize
});
Queue.remove(channelId);
continue;
}
channel.send('The bot has just restarted, anybody previously in the queue has been reset');
channel.send(lang_1.Lang.get('discord.botRestart'));
}
}
exports.discordInit = discordInit;
@@ -115,7 +120,7 @@ var QueueCommands;
function getInfo(interaction) {
let info = QUEUE.get(interaction.channelId);
if (!info)
throw (0, util_1.emsg)('There is not an active queue in this channel, type `/open` to create one');
throw (0, util_1.emsg)(lang_1.Lang.get('discord.error.noQueue'));
return info;
}
/**
@@ -150,9 +155,13 @@ 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)(`There is already an active queue in this channel for teams of ${QUEUE.get(channelId)?.teamsize}`);
throw (0, util_1.emsg)(lang_1.Lang.get('discord.error.noCreate', {
teamsize: QUEUE.get(channelId)?.teamsize
}));
Queue.create(channelId, teamsize);
interaction.reply(`A queue for teams of ${teamsize} has been started`);
interaction.reply(lang_1.Lang.get('discord.create', {
teamsize
}));
}
QueueCommands.queueCreate = queueCreate;
/**
@@ -172,7 +181,7 @@ var QueueCommands;
async function close(interaction) {
(0, util_1.memberIsModThrow)(interaction);
QUEUE.delete(interaction.channelId);
await interaction.reply('Queue has been reset');
await interaction.reply(lang_1.Lang.get('discord.close'));
}
QueueCommands.close = close;
/**
@@ -186,7 +195,7 @@ var QueueCommands;
.setTitle('Active Queue')
.addField('Team Size', info.teamsize.toString(), true)
.addField('Players Joined', info.players.length.toString(), true)
.setFooter({ text: 'type /join' });
.setFooter({ text: 'type /join' }); //TODO
await interaction.reply({ embeds: [embed], ephemeral: true });
}
QueueCommands.queue = queue;
@@ -198,10 +207,10 @@ var QueueCommands;
async function join(interaction) {
let { member, info, channel } = getAll(interaction);
if (queueContains(interaction))
throw (0, util_1.emsg)('You are already in the queue');
throw (0, util_1.emsg)(lang_1.Lang.get('discord.error.inQueue'));
info.players.push(member);
QUEUE.set(interaction.channelId, info);
await interaction.reply('Joined the queue');
await interaction.reply(lang_1.Lang.get('discord.join'));
checkQueue(channel);
}
QueueCommands.join = join;
@@ -213,10 +222,10 @@ var QueueCommands;
async function leave(interaction) {
let { member, info } = getAll(interaction);
if (!queueContains(interaction))
throw (0, util_1.emsg)('You aren\'t in the queue');
throw (0, util_1.emsg)(lang_1.Lang.get('discord.error.notInQueue'));
info.players.splice(info.players.indexOf(member), 1);
QUEUE.set(interaction.channelId, info);
await interaction.reply('Left the queue');
await interaction.reply(lang_1.Lang.get('discord.leave'));
}
QueueCommands.leave = leave;
})(QueueCommands = exports.QueueCommands || (exports.QueueCommands = {}));