updated to es2020

This commit is contained in:
2022-01-31 15:53:23 -06:00
parent 5ee97cfd08
commit 5ce68086b8
5 changed files with 88 additions and 136 deletions

28
dist/index.js vendored
View File

@@ -18,15 +18,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const discord_js_1 = require("discord.js");
const fs = __importStar(require("fs"));
@@ -34,33 +25,36 @@ const api_1 = require("./api");
const discord_1 = require("./discord");
const queue_1 = require("./queue");
const CLIENT = new discord_js_1.Client({ intents: [discord_js_1.Intents.FLAGS.GUILDS] });
//init logs with a timestamp
console.log(new Date().toISOString() + '\n\n');
//get token
if (!fs.existsSync('./token')) {
fs.writeFileSync('./token', '');
console.error('Missing Discord Token, please enter the bot token into the token file');
process.exit(1);
}
const TOKEN = fs.readFileSync('./token').toString();
//discord connections
CLIENT.on('ready', client => {
console.log(`Logged in as ${client.user.tag}`);
client.guilds.fetch().then(guilds => (0, discord_1.registerCommands)(TOKEN, client.user.id, guilds.map(g => g.id)));
});
CLIENT.on('interactionCreate', (interaction) => __awaiter(void 0, void 0, void 0, function* () {
CLIENT.on('interactionCreate', async (interaction) => {
if (!interaction.isCommand())
return;
try {
if (interaction.commandName === 'queue')
yield (0, queue_1.createQueue)(interaction);
await (0, queue_1.createQueue)(interaction);
else if (interaction.commandName === 'join')
yield (0, queue_1.joinQueue)(interaction);
await (0, queue_1.joinQueue)(interaction);
else if (interaction.commandName === 'leave')
yield (0, queue_1.leaveQueue)(interaction);
await (0, queue_1.leaveQueue)(interaction);
else if (interaction.commandName === 'ready')
yield (0, queue_1.readyQueue)(interaction);
await (0, queue_1.readyQueue)(interaction);
else if (interaction.commandName === 'queueinfo')
yield (0, queue_1.queueInfo)(interaction);
await (0, queue_1.queueInfo)(interaction);
else if (interaction.commandName === 'elo')
yield (0, api_1.getPlayerInteraction)(interaction);
await (0, api_1.getPlayerInteraction)(interaction);
}
catch (e) {
if (typeof e === 'string') {
@@ -72,5 +66,5 @@ CLIENT.on('interactionCreate', (interaction) => __awaiter(void 0, void 0, void 0
else
console.error(e);
}
}));
});
CLIENT.login(TOKEN);