const ESMCommand = require("../esm_command"); module.exports = class ESMCommand_Stuck extends ESMCommand { constructor(bot) { super(bot); this.permissions = { requires_registration: true, requires_server: true }; this.commandParams = { serverID: { regex: this.util.regex.serverID.base }, acceptDecline: { regex: this.util.regex.acceptDecline.base, nullable: true } }; this.information = { category: "server", params: "<server_id>", help: "Allows players to unstuck themselves if they are in an infinite spawn loop or can't respawn. After running this command, the player will be required to confirm." }; this.configuration = { allowedInTextChannels: { modifiable: true, default: true }, enabled: { modifiable: true, default: true } }; } async fromDiscord() { if (this.util.isNull(this.params.acceptDecline)) { let requests = await this.db.getRequests(this.params.steamUID, { type: "stuck", serverID: this.params.serverID }); if (!this.util.isEmpty(requests)) { return this.ESMBot.send(this.message.channel, `You already have a pending confirmation.\nYou can accept or decline by running \`!stuck ${this.params.serverID} accept\` or \`!stuck ${this.params.serverID} decline\``); } await this.db.addRequest(this.params.steamUID, { type: "stuck", serverID: this.params.serverID }); this.ESMBot.send(this.message.channel, { author: { name: this.message.author.tag, icon_url: this.message.author.avatarURL() }, title: `Please confirm to reset your player on ${this.params.serverID}`, description: `Note: Your player MUST be spawned in on this server and you CANNOT be logged into the server when you confirm this.\nWARNING: Confirming will delete your player, any items or poptabs WILL BE LOST.`, fields: [{ name: "To Accept", value: `Reply with \`!stuck ${this.params.serverID} accept\`` }, { name: "To Decline", value: `Reply with \`!stuck ${this.params.serverID} decline\`` } ], footer: { text: "This confirmation will decline after 1 day" } }); } else if (this.params.acceptDecline === "accept") { let requests = await this.db.getRequests(this.params.steamUID, { type: "stuck", serverID: this.params.serverID }); if (this.util.isEmpty(requests)) { return this.ESMBot.send(this.message.channel, `${this.info.author.tag}, you do not have any pending confirmations for this server`); } this.send({ serverID: this.params.serverID, command: "stuck", parameters: { query: "reset_player", targetUID: this.params.steamUID } }); this.db.removeRequest(requests.id); } else if (this.params.acceptDecline === "decline") { let requests = await this.db.getRequests(this.params.steamUID, { type: "stuck", serverID: this.params.serverID }); if (this.util.isEmpty(requests)) { return this.ESMBot.send(this.message.channel, `${this.info.author.tag}, you do not have any pending confirmations for this server`); } this.db.removeRequest(requests.id); this.ESMBot.send(this.message.channel, `${this.info.author.tag}, confirmation for \`!stuck\` declined`); } } async fromServer() { if (this.params.success) { this.ESMBot.send(this.info.channel, `${this.info.author.tag}, you've been reset successfully. Please join the server to spawn back in`); this.ESMBot.send(await this.db.getLoggingChannel(this.serverID), { color: this.ESMBot.colors.GREEN, title: `\`${this.params.targetUID}\` has been reset`, description: `Requested by ${this.info.author.tag}` }); } else { this.ESMBot.send(this.info.channel, `${this.info.author.tag}, I was unsuccessful at resetting your player. Did you forget to spawn back in?`); } } }