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

View File

@@ -6,6 +6,7 @@ join message should contain your current position in the queue, editing it to ke
import { Client, CommandInteraction, GuildMember, MessageEmbed, TextChannel } from "discord.js";
import * as fs from 'fs';
import { emsg, getChannel, getMember, memberIsModThrow, queueInfo, queueInfoBase } from "./util";
import { Lang } from './lang';
//load queues from file
if (!fs.existsSync('./queues.json'))
@@ -48,6 +49,7 @@ async function checkQueue(channel: TextChannel) {
let team = info.players.splice(0, info.teamsize).map(m => m.toString());
//TODO add embeds to lang.ts
let embed = new MessageEmbed()
.setTitle('Team')
.setDescription(team.join('\n'));
@@ -102,12 +104,15 @@ export async function discordInit(client: Client) {
}
if (!channel || !(channel instanceof TextChannel)) {
console.error(`Unable to find channel ${channelId} for teams of ${info?.teamsize}`);
console.error(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.get('discord.botRestart'));
}
@@ -124,7 +129,7 @@ export namespace QueueCommands {
let info = QUEUE.get(interaction.channelId);
if (!info)
throw emsg('There is not an active queue in this channel, type `/open` to create one');
throw emsg(Lang.get('discord.error.noQueue'));
return info;
}
@@ -169,11 +174,15 @@ export namespace QueueCommands {
teamsize = interaction.options.getInteger('teamsize', true);
if (QUEUE.has(channelId))
throw emsg(`There is already an active queue in this channel for teams of ${QUEUE.get(channelId)?.teamsize}`);
throw emsg(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.get('discord.create', {
teamsize
}))
}
@@ -198,7 +207,7 @@ export namespace QueueCommands {
QUEUE.delete(interaction.channelId);
await interaction.reply('Queue has been reset');
await interaction.reply(Lang.get('discord.close'));
}
@@ -215,7 +224,7 @@ export namespace 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});
@@ -231,13 +240,13 @@ export namespace QueueCommands {
let {member, info, channel} = getAll(interaction);
if (queueContains(interaction))
throw emsg('You are already in the queue');
throw emsg(Lang.get('discord.error.inQueue'));
info.players.push(member);
QUEUE.set(interaction.channelId, info);
await interaction.reply('Joined the queue');
await interaction.reply(Lang.get('discord.join'));
checkQueue(channel);
@@ -253,13 +262,13 @@ export namespace QueueCommands {
let {member, info} = getAll(interaction);
if (!queueContains(interaction))
throw emsg('You aren\'t in the queue');
throw emsg(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.get('discord.leave'));
}