const ESMCommand = require("../esm_command"); module.exports = class ESMCommand_Restore extends ESMCommand { constructor(bot) { super(bot); this.permissions = { disabled_in_player_mode: true, requires_server: true, text_only: true }; this.commandParams = { serverID: { regex: this.util.regex.serverID.base }, territoryID: { regex: this.util.regex.territoryID.base } }; this.information = { category: "server", params: "<server_id> <territory_id>", help: "Restores a territory on the server. This command can only be used in a text channel and is only available for a certain role." }; this.configuration = { permissions: { modifiable: true, default: {} }, allowedInTextChannels: { modifiable: false, default: true }, cooldown: { modifiable: true, default: [2, "seconds"] }, enabled: { modifiable: true, default: true } }; } async fromDiscord() { let communityID = await this.db.getCommunityID(this.message.guild.id); if (this.util.isEmpty(communityID)) { return this.ESMBot.send(this.message.channel, this.ESMBot.errors.format(this.message.author, "FAILED_TO_FIND_COMMUNITY")); } let parsedID = this.util.getCommunityID(this.params.serverID); if (parsedID !== communityID) { return this.ESMBot.send(this.message.channel, this.ESMBot.errors.format(this.message.author, "UHH_UHH_UHH")); } this.send({ serverID: this.params.serverID, command: "restore", parameters: { query: "restore", territory_id: this.params.territoryID } }); } async fromServer() { if (this.params.success) { this.ESMBot.send(this.info.channel, `${this.info.author.tag}, **${this.params.id}** has been restored`); this.ESMBot.send(await this.db.getLoggingChannel(this.serverID), { color: this.ESMBot.colors.GREEN, title: `Territory \`${this.params.id}\` has been restored`, description: `Requested by ${this.info.author.tag}` }) } else { this.ESMBot.send(this.info.channel, `${this.info.author.tag}, **${this.params.id}** territory doesn't exist`); } } }