const ESMCommand = require("../esm_command"); module.exports = class ESMCommand_Reset extends ESMCommand { constructor(bot) { super(bot); this.permissions = { disabled_in_player_mode: true, requires_registration: true, requires_server: true, text_only: true }; this.commandParams = { serverID: { regex: this.util.regex.serverID.base }, target: { regex: this.util.regex.target.base, nullable: true } }; this.information = { category: "server", params: "<server_id> <@user | steam_uid>", help: "Resets a user's player in the database to fix the respawn dead glitch.\nIf a discord tag or steam UID is not provided, ESM will reset every stuck player in the database" }; this.configuration = { permissions: { modifiable: true, default: {} }, allowedInTextChannels: { modifiable: false, default: true }, cooldown: { modifiable: true, default: [2, "seconds"] }, enabled: { modifiable: true, default: true } }; } async fromDiscord() { if (this.params.target != null && this.util.regex.discordTag.base.test(this.params.target)) { let discordUser = await this.ESMBot.getUser(this.params.target); if (discordUser == null) { return this.ESMBot.send(this.message.channel, this.ESMBot.errors.format(this.message.author, "USER_NOT_FOUND")); } let isRegistered = await this.db.isRegistered(discordUser.id); if (!isRegistered) { return this.ESMBot.send(this.message.channel, this.ESMBot.errors.format(this.message.author, "USER_NOT_REGISTERED")); } this.params.target = await this.db.getSteamUIDFromID(discordUser.id); if (this.params.target == null) return; } this.send({ serverID: this.params.serverID, command: "reset", parameters: { query: this.params.target ? "reset_player" : "reset_all", targetUID: this.params.target } }); } async fromServer() { if (this.params.success) { this.ESMBot.send(this.info.channel, this.params.targetUID ? `${this.info.author.tag}, \`${this.params.targetUID}\` has been reset` : `${this.info.author.tag}, reset all stuck players on \`${this.serverID}\``); this.ESMBot.send(await this.db.getLoggingChannel(this.serverID), { color: this.ESMBot.colors.GREEN, title: this.params.targetUID ? `\`${this.params.targetUID}\` has been reset` : "All stuck players reset", description: `Requested by ${this.info.author.tag}` }); } else { this.ESMBot.send(this.info.channel, this.params.targetUID ? `${this.info.author.tag}, \`${this.params.targetUID}\` is not stuck` : `${this.info.author.tag}, I didn't find anyone who was stuck`); } } }