72 lines
2.4 KiB
JavaScript
72 lines
2.4 KiB
JavaScript
"use strict";
|
|
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',
|
|
close: 'Queue has been closed',
|
|
join: 'Joined the queue',
|
|
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}',
|
|
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',
|
|
notMod: 'Member is not a moderator'
|
|
},
|
|
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'
|
|
}
|
|
}
|
|
}
|
|
};
|
|
var Lang;
|
|
(function (Lang) {
|
|
var LANGID = 'en';
|
|
if (!(LANGID in LANG))
|
|
throw 'language id does not exist';
|
|
function setLang(langid) {
|
|
if (langid in LANG)
|
|
LANGID = langid;
|
|
else
|
|
throw 'language id does not exist';
|
|
}
|
|
Lang.setLang = setLang;
|
|
/**
|
|
* reads language json
|
|
* @param id ex: discord.error.noActiveQueue
|
|
* @returns language value, defaults to `id` parameter
|
|
*/
|
|
function get(id, args = {}) {
|
|
let keySpl = id.split('.').map(k => k.trim()).filter(k => k);
|
|
let finding = LANG[LANGID];
|
|
for (let key of keySpl) {
|
|
if (key in finding) {
|
|
let found = finding[key];
|
|
if (typeof found === 'string')
|
|
return found;
|
|
finding = found;
|
|
}
|
|
else
|
|
break;
|
|
}
|
|
return id;
|
|
}
|
|
Lang.get = get;
|
|
})(Lang = exports.Lang || (exports.Lang = {}));
|