updated lang strings

This commit is contained in:
2022-02-13 19:35:16 -06:00
parent b1d01b414e
commit 343ed640ae
10 changed files with 43 additions and 15 deletions

2
dist/api.js vendored
View File

@@ -204,7 +204,7 @@ async function getPlayerInteraction(interaction) {
await interaction.deferReply();
let data = await getPlayer(username);
if (data === null)
throw (0, util_1.emsg)('Unable to find user');
throw (0, util_1.emsg)('api.noUser');
else
sendPlayerEmbed(interaction, data);
}

1
dist/discord.js vendored
View File

@@ -60,7 +60,6 @@ async function registerCommands(token, clientId, guildIds) {
for (let i = 0; i < guildIds.length; i++) {
try {
await rest.put(v9_1.Routes.applicationGuildCommands(clientId, guildIds[i]), { body: commands });
console.log(`[${guildIds[i]}] registered command`);
}
catch (error) {
console.error(error);

11
dist/index.js vendored
View File

@@ -23,6 +23,7 @@ const discord_js_1 = require("discord.js");
const fs = __importStar(require("fs"));
const api_1 = require("./api");
const discord_1 = require("./discord");
const lang_1 = require("./lang");
const queue_1 = require("./queue");
const util_1 = require("./util");
const CLIENT = new discord_js_1.Client({ intents: [discord_js_1.Intents.FLAGS.GUILDS] });
@@ -31,16 +32,22 @@ console.log(new Date().toISOString() + '\n\n');
//get token
if (!fs.existsSync('./token.txt')) {
fs.writeFileSync('./token.txt', '');
console.error('Missing Discord Token, please enter the bot token into the token file');
console.error(lang_1.Lang.get('error.main.missingToken'));
process.exit(1);
}
const TOKEN = fs.readFileSync('./token.txt').toString();
//discord connections
CLIENT.on('ready', client => {
console.log(`Logged in as ${client.user.tag}`);
console.log(lang_1.Lang.get('main.login', {
user: client.user.tag
}));
client.guilds.fetch().then(guilds => (0, discord_1.registerCommands)(TOKEN, client.user.id, guilds.map(g => g.id)));
(0, queue_1.discordInit)(client);
});
CLIENT.on('guildCreate', guild => {
if (guild.client.user)
(0, discord_1.registerCommands)(TOKEN, guild.client.user.id, guild.id);
});
CLIENT.on('interactionCreate', async (interaction) => {
if (!interaction.isCommand())
return;

9
dist/lang.js vendored
View File

@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.Lang = void 0;
const LANG = {
en: {
main: {
login: 'Logged in as {user}'
},
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',
@@ -11,6 +14,9 @@ const LANG = {
leave: 'Left the queue'
},
error: {
main: {
missingToken: 'Missing Discord Token, please enter the bot token into the token file'
},
discord: {
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}',
@@ -22,6 +28,9 @@ const LANG = {
general: {
noMember: 'Unable to retrieve guild member information, please try again',
noChannel: 'Unable to retrieve text channel information, please try again'
},
api: {
noUser: 'Unable to find user'
}
}
}

7
dist/queue.js vendored
View File

@@ -154,13 +154,14 @@ var QueueCommands;
function queueCreate(interaction) {
(0, util_1.memberIsModThrow)(interaction);
let { channelId } = interaction, teamsize = interaction.options.getInteger('teamsize', true);
if (QUEUE.has(channelId))
let existing = QUEUE.get(channelId);
if (existing)
throw (0, util_1.emsg)(lang_1.Lang.get('error.discord.noCreate', {
teamsize: QUEUE.get(channelId)?.teamsize
teamsize: existing.teamsize.toString()
}));
Queue.create(channelId, teamsize);
interaction.reply(lang_1.Lang.get('discord.create', {
teamsize
teamsize: teamsize.toString()
}));
}
QueueCommands.queueCreate = queueCreate;