UNPKG

@antibot/interactions

Version:

## 🗡️ An interactions library made for Discord interactions

140 lines 5.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Interactions = void 0; const Routes_1 = require("./Routes"); const RequestManager_1 = require("./request/RequestManager"); const typings_1 = require("./request/typings"); const Wrap_1 = require("./utils/Wrap"); class Interactions { options; request; api; routes; constructor(options) { this.options = options; this.api = 'https://discord.com/api/v10'; this.options.publicKey = options.publicKey; this.options.botID = options.botID; this.options.botToken = options.botToken; this.routes = new Routes_1.Routes(); this.request = new RequestManager_1.RequestManager(this.options.publicKey, this.options.botToken, this.api, this.options.debug); } get botID() { return this.options.botID; } get botToken() { return this.options.botToken; } async createGlobalCommand(command) { return (await (0, Wrap_1.Wrap)(this.request.POST({ route: this.routes.createApplicationCommand(this.options.botID), contentType: typings_1.APPLICATION_TYPE.JSON, data: command, }))); } async getGlobalCommand(commandId) { return (await (0, Wrap_1.Wrap)(this.request.GET({ route: this.routes.getGlobalApplicationCommand(this.options.botID, commandId), contentType: typings_1.APPLICATION_TYPE.JSON, }))); } async editGlobalCommand(commandId, command) { return (await (0, Wrap_1.Wrap)(this.request.PATCH({ route: this.routes.editGlobalApplicationCommand(this.options.botID, commandId), contentType: typings_1.APPLICATION_TYPE.JSON, data: command, }))); } async deleteGlobalCommand(commandId) { await this.request.DELETE({ route: this.routes.deleteGlobalApplicationCommand(this.options.botID, commandId), contentType: typings_1.APPLICATION_TYPE.JSON, }); } async getGlobalCommands() { return (await (0, Wrap_1.Wrap)(this.request.GET({ route: this.routes.getApplicationCommands(this.options.botID), contentType: typings_1.APPLICATION_TYPE.JSON, }))); } async overwriteGlobalCommands(...commands) { await this.request.PUT({ route: this.routes.bulkOverwriteGlobalApplicationCommands(this.options.botID), contentType: typings_1.APPLICATION_TYPE.JSON, data: commands, }); } async createGuildCommand(guildId, command) { return (await (0, Wrap_1.Wrap)(this.request.POST({ route: this.routes.createGuildApplicationCommand(this.options.botID, guildId), contentType: typings_1.APPLICATION_TYPE.JSON, data: command, }))); } async getGuildCommands(guildId) { return (await (0, Wrap_1.Wrap)(this.request.GET({ route: this.routes.getGuildApplicationCommands(this.options.botID, guildId), contentType: typings_1.APPLICATION_TYPE.JSON, }))); } async editGuildCommand(options) { return (await (0, Wrap_1.Wrap)(this.request.PATCH({ route: this.routes.editGuildApplicationCommand({ applicationId: this.options.botID, guildId: options.guildId, commandId: options.commandId, }), contentType: typings_1.APPLICATION_TYPE.JSON, data: options.command, }))); } async deleteGuildCommand(guildId, commandId) { await this.request.DELETE({ route: this.routes.deleteGuildApplicationCommand({ applicationId: this.options.botID, guildId: guildId, commandId: commandId, }), contentType: typings_1.APPLICATION_TYPE.JSON, }); } async overwriteGuildCommands(guildId, ...commands) { await this.request.PUT({ route: this.routes.bulkOverwriteGuildApplicationCommands(this.options.botID, guildId), contentType: typings_1.APPLICATION_TYPE.JSON, data: commands, }); } async getGuildCommand(guildId, commandId) { return (await (0, Wrap_1.Wrap)(this.request.GET({ publicKey: true, route: this.routes.getGuildApplicationCommand({ applicationId: this.options.botID, guildId: guildId, commandId: commandId, }), contentType: typings_1.APPLICATION_TYPE.JSON, }))); } async getGuildCommandPermissions(guildId) { return (await (0, Wrap_1.Wrap)(this.request.GET({ publicKey: true, route: this.routes.getGuildApplicationCommandPermissions(this.options.botID, guildId), contentType: typings_1.APPLICATION_TYPE.JSON, }))); } async editGuildCommandPermissions(options) { return (await (0, Wrap_1.Wrap)(this.request.PUT({ publicKey: true, route: this.routes.editApplicationCommandPermissions({ applicationId: this.options.botID, guildId: options.guildId, commandId: options.commandId, }), contentType: typings_1.APPLICATION_TYPE.JSON, data: options.permissions, }))); } } exports.Interactions = Interactions; //# sourceMappingURL=Interactions.js.map