added more strings

This commit is contained in:
2022-02-14 14:56:47 -06:00
parent 458d3f3d76
commit 513a9d1582
4 changed files with 84 additions and 41 deletions

34
dist/lang.js vendored
View File

@@ -105,7 +105,27 @@ 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'
leave: 'Left the queue',
team: {
embed: true,
title: 'Team',
description: '{team}'
},
queue: {
embed: true,
title: 'Active Queue',
fields: [
{
name: 'Team Size',
value: '{teamsize}'
},
{
name: 'Players Joined',
value: '{playercount}'
}
],
footer: 'type `/join`'
}
},
api: {
player: {
@@ -160,6 +180,7 @@ exports.setLang = setLang;
/**
* reads language json (just strings)
* @param id ex: discord.error.noActiveQueue
* @param args list of key/value pairs to represent template values
* @returns language value, defaults to `id` parameter
*/
function get(id, args = {}) {
@@ -183,10 +204,13 @@ exports.get = get;
/**
* reads language json as an object (could be embed or just string)
* @param id ex: discord.error.noActiveQueue
* @param args list of key/value pairs to represent template values
* @param otherOptions values to be passed through to the return value
* @returns language value, defaults to `id` parameter
*/
function getEmbed(id, args = {}) {
function getEmbed(id, args = {}, otherOptions = {}) {
const embedData = {
...otherOptions,
embeds: []
};
const keySpl = id.split('.').map(k => k.trim()).filter(k => k);
@@ -199,9 +223,8 @@ function getEmbed(id, args = {}) {
break;
}
if (found.embed === true) {
const embedObj = found, { content } = embedObj, embed = embedObjEmbed(embedObj, args), embedData = {
embeds: [embed]
};
const embedObj = found, { content } = embedObj, embed = embedObjEmbed(embedObj, args);
embedData.embeds.push(embed);
if (content !== undefined)
embedData.content = content;
return embedData;
@@ -214,3 +237,4 @@ function getEmbed(id, args = {}) {
return embedData;
}
exports.getEmbed = getEmbed;
debugger;

20
dist/queue.js vendored
View File

@@ -55,11 +55,7 @@ async function checkQueue(channel) {
return;
if (info.players.length >= info.teamsize) {
const team = info.players.splice(0, info.teamsize).map(m => m.toString());
//TODO add embeds to lang.ts
const embed = new discord_js_1.MessageEmbed()
.setTitle('Team')
.setDescription(team.join('\n'));
await channel.send({ embeds: [embed] });
await channel.send(Lang.getEmbed('discord.team', { team: team.join('\n') }));
}
}
function queueCreate(channelId, teamsize) {
@@ -80,7 +76,7 @@ SaveQueue();
async function discordInit(client) {
for (const channelId of QUEUE.keys()) {
const info = QUEUE.get(channelId), channel = await client.channels.fetch(channelId);
if (!info) { //no idea what could cause this but TS complains
if (!info) {
queueRemove(channelId);
continue;
}
@@ -166,12 +162,12 @@ async function close(interaction) {
*/
async function queue(interaction) {
const info = getInfo(interaction);
const embed = new discord_js_1.MessageEmbed()
.setTitle('Active Queue')
.addField('Team Size', info.teamsize.toString(), true)
.addField('Players Joined', info.players.length.toString(), true)
.setFooter({ text: 'type /join' }); //TODO
await interaction.reply({ embeds: [embed], ephemeral: true });
await interaction.reply(Lang.getEmbed('discord.queue', {
teamsize: info.teamsize.toString(),
playercount: info.players.length.toString(),
}, {
ephemeral: true
}));
}
/**
* joins a queue