updated lang strings
This commit is contained in:
13
src/lang.ts
13
src/lang.ts
@@ -4,8 +4,17 @@ type LangObjWhold = { [langid:string]: LangObj }
|
||||
const LANG: LangObjWhold = {
|
||||
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'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +38,7 @@ export namespace Lang {
|
||||
* @param id ex: discord.error.noActiveQueue
|
||||
* @returns language value, defaults to `id` parameter
|
||||
*/
|
||||
export function get(id: string): string {//discord.error.noActiveQueue
|
||||
export function get(id: string, args: {[keys: string]: any} = {}): string {//discord.error.noActiveQueue
|
||||
|
||||
let keySpl = id.split('.').map(k => k.trim()).filter(k => k);
|
||||
|
||||
|
||||
31
src/queue.ts
31
src/queue.ts
@@ -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'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user