const ESMCommand = require("../esm_command"); module.exports = class ESMCommand_SetTerritoryID extends ESMCommand { constructor(bot) { super(bot); this.permissions = { requires_registration: true, requires_server: true }; this.commandParams = { serverID: { regex: this.util.regex.serverID.base }, originalTerritoryID: { regex: this.util.regex.territoryID.base }, newTerritoryID: { regex: this.util.regex.territoryID.base } }; this.information = { category: "territory", params: "<server_id> <old_territory_id> <new_territory_id>", help: "Set a custom territory ID for your territory on the server.\nThe ID must be at least 3 characters long and can **only contain letters, numbers, and underscores**. The ID is also **case insensitive** and will be automatically **converted to lowercase.**" }; this.configuration = { allowedInTextChannels: { modifiable: true, default: false }, cooldown: { modifiable: true, default: [30, "minutes"] }, enabled: { modifiable: true, default: true } }; } async fromDiscord() { if (this.params.newTerritoryID.length < 3) { return this.ESMBot.send(this.message.channel, `${this.message.author.toString()}, your new territory ID must be **at least 3 characters**`); } this.send({ serverID: this.params.serverID, command: "setterritoryid", parameters: { query: "set_custom_territory_id", old_territory_id: this.params.originalTerritoryID, new_territory_id: this.params.newTerritoryID, player_uid: this.params.steamUID } }); } async fromServer() { if (this.params.success) { this.ESMBot.send(this.info.channel, `👝 Your new ID is \`${this.params.new_id}\`. You can now use this ID wherever a command requires \`<territory_id>\`\nFor example: \`!pay ${this.serverID} ${this.params.new_id}\``); this.ESMBot.send(await this.db.getLoggingChannel(this.serverID), { color: this.ESMBot.colors.GREEN, description: `Territory ID changed by ${this.info.author.tag}`, fields: [{ name: "Previous ID", value: this.params.old_id }, { name: "New ID", value: this.params.new_id }] }); } else { this.resetCooldown(); if (this.util.isEmpty(this.params.reason)) { this.ESMBot.send(this.info.channel, this.ESMBot.errors.format(this.info.author.tag, "UHH_UHH_UHH")); } else { this.ESMBot.send(this.info.channel, `${this.info.author.tag}, ${this.params.reason}`); } } } }