added more strings
This commit is contained in:
34
dist/lang.js
vendored
34
dist/lang.js
vendored
@@ -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
20
dist/queue.js
vendored
@@ -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
|
||||
|
||||
47
src/lang.ts
47
src/lang.ts
@@ -2,7 +2,10 @@ import { MessageEmbed } from 'discord.js';
|
||||
|
||||
/* TYPES */
|
||||
|
||||
type basicObject = {[keys: string]: string};
|
||||
//this is a generic type, and needs 'any'
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
type basicObject = {[keys: string]: any};
|
||||
type basicObjectStr = {[keys: string]: string};
|
||||
|
||||
type URL = string;
|
||||
|
||||
@@ -99,7 +102,7 @@ function embedObjStr(embedData: embedObj, fallback = ''): string {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
function embedObjEmbed(embedObj: embedObj, args: basicObject = {}): MessageEmbed {
|
||||
function embedObjEmbed(embedObj: embedObj, args: basicObjectStr = {}): MessageEmbed {
|
||||
const embed = new MessageEmbed(),
|
||||
{ author, color, description, fields, footer, image, thumbnail, timestamp, title, url } = embedObj;
|
||||
|
||||
@@ -205,7 +208,28 @@ const LANG: LangObjWhole = {
|
||||
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: {
|
||||
@@ -272,9 +296,10 @@ export function setLang(langid: string) {
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
export function get(id: string, args: basicObject = {}): string {
|
||||
export function get(id: string, args: basicObjectStr = {}): string {
|
||||
|
||||
const keySpl = id.split('.').map(k => k.trim()).filter(k => k);
|
||||
|
||||
@@ -305,11 +330,14 @@ export function get(id: string, args: basicObject = {}): string {
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
export function getEmbed(id: string, args: basicObject = {}): embedData {
|
||||
export function getEmbed(id: string, args: basicObjectStr = {}, otherOptions: basicObject = {}): embedData {
|
||||
|
||||
const embedData: embedData = {
|
||||
...otherOptions,
|
||||
embeds: []
|
||||
};
|
||||
|
||||
@@ -331,10 +359,9 @@ export function getEmbed(id: string, args: basicObject = {}): embedData {
|
||||
if (found.embed === true) {
|
||||
const embedObj = found as embedObj,
|
||||
{content} = embedObj,
|
||||
embed = embedObjEmbed(embedObj, args),
|
||||
embedData: embedData = {
|
||||
embeds: [embed]
|
||||
};
|
||||
embed = embedObjEmbed(embedObj, args);
|
||||
|
||||
embedData.embeds.push(embed);
|
||||
|
||||
if (content !== undefined)
|
||||
embedData.content = content;
|
||||
@@ -351,3 +378,5 @@ export function getEmbed(id: string, args: basicObject = {}): embedData {
|
||||
|
||||
return embedData;
|
||||
}
|
||||
|
||||
debugger;
|
||||
|
||||
24
src/queue.ts
24
src/queue.ts
@@ -3,7 +3,7 @@
|
||||
join message should contain your current position in the queue, editing it to keep it current
|
||||
*/
|
||||
|
||||
import { Client, CommandInteraction, MessageEmbed, TextChannel } from 'discord.js';
|
||||
import { Client, CommandInteraction, TextChannel } from 'discord.js';
|
||||
import * as fs from 'fs';
|
||||
import { emsg, getChannel, getMember, memberIsModThrow, queueInfo, queueInfoBase } from './util';
|
||||
import * as Lang from './lang';
|
||||
@@ -51,12 +51,7 @@ async function checkQueue(channel: TextChannel) {
|
||||
|
||||
const team = info.players.splice(0, info.teamsize).map(m => m.toString());
|
||||
|
||||
//TODO add embeds to lang.ts
|
||||
const embed = new MessageEmbed()
|
||||
.setTitle('Team')
|
||||
.setDescription(team.join('\n'));
|
||||
|
||||
await channel.send({embeds: [embed]});
|
||||
await channel.send(Lang.getEmbed('discord.team', { team: team.join('\n') }));
|
||||
|
||||
}
|
||||
|
||||
@@ -86,7 +81,7 @@ export async function discordInit(client: Client) {
|
||||
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;
|
||||
}
|
||||
@@ -198,13 +193,12 @@ async function queue(interaction: CommandInteraction) {
|
||||
|
||||
const info = getInfo(interaction);
|
||||
|
||||
const embed = new 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
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user