76 lines
2.5 KiB
JavaScript
76 lines
2.5 KiB
JavaScript
"use strict";
|
|
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 });
|
|
exports.registerCommands = void 0;
|
|
const rest_1 = require("@discordjs/rest");
|
|
const v9_1 = require("discord-api-types/v9");
|
|
const commands = [
|
|
{
|
|
name: 'queue',
|
|
description: 'creates a queue',
|
|
options: [
|
|
{
|
|
type: 4,
|
|
name: 'teamsize',
|
|
description: 'size of each team',
|
|
required: true
|
|
}
|
|
]
|
|
},
|
|
{
|
|
name: 'join',
|
|
description: 'joins the active queue'
|
|
},
|
|
{
|
|
name: 'ready',
|
|
description: 'readys the queue and displays team info'
|
|
},
|
|
{
|
|
name: 'queueinfo',
|
|
description: 'gets info of the current queue'
|
|
},
|
|
{
|
|
name: 'elo',
|
|
description: 'displays your elo information',
|
|
options: [
|
|
{
|
|
type: 3,
|
|
name: 'username',
|
|
description: 'your in game name',
|
|
required: true
|
|
}
|
|
]
|
|
}
|
|
];
|
|
/**
|
|
* register/reload commands on guild(s)
|
|
* @param token discord bot token
|
|
* @param clientId discord bot client id
|
|
* @param guildIds discord guild id(s)
|
|
*/
|
|
function registerCommands(token, clientId, guildIds) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
const rest = new rest_1.REST({ version: '9' }).setToken(token);
|
|
if (typeof guildIds === 'string')
|
|
guildIds = [guildIds];
|
|
for (let i = 0; i < guildIds.length; i++) {
|
|
try {
|
|
yield rest.put(v9_1.Routes.applicationGuildCommands(clientId, guildIds[i]), { body: commands });
|
|
console.log(`[${guildIds[i]}] registered command`);
|
|
}
|
|
catch (error) {
|
|
console.error(error);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
exports.registerCommands = registerCommands;
|