const ESMCommand = require("../esm_command"); module.exports = class ESMCommand_Me extends ESMCommand { constructor(bot) { super(bot); this.permissions = { requires_registration: true, requires_server: true }; this.commandParams = { serverID: { regex: this.util.regex.serverID.base } }; this.information = { category: "server", params: "<server_id>", help: "Displays information about the player on the server" }; this.configuration = { allowedInTextChannels: { modifiable: true, default: false }, cooldown: { modifiable: true, default: [2, "seconds"] }, enabled: { modifiable: true, default: true } }; } async fromDiscord() { this.send({ serverID: this.params.serverID, command: "me", parameters: { query: "player_info", uid: this.params.steamUID } }); } async fromServer() { if (this.util.isEmpty(this.params)) { return this.ESMBot.send(this.info.channel, "I found nothing. Have you joined this server?"); } let embed = new this.ESMBot.discord.MessageEmbed(); embed.setTitle(`Player Information on ${this.serverID}`); embed.setColor(this.ESMBot.colors.BLUE); embed.setTimestamp(this.ESMBot.moment.utc()); embed.addField("Name", this.params.name); if (this.params.money) { embed.addField("Money", `${this.params.money} poptabs`, true); } embed.addField("Locker", `${this.params.locker} poptabs`, true); embed.addField("Respect", `${this.params.score}`, true); if (this.params.damage) { embed.addField("Health", `${Math.round(100 - (parseFloat(this.params.damage) * 100))}%`, true); } if (this.params.hunger) { embed.addField("Hunger", `${Math.round(parseFloat(this.params.hunger))}%`, true); } if (this.params.thirst) { embed.addField("Thirst", `${Math.round(parseFloat(this.params.thirst))}%`, true); } embed.addField("Kills/Deaths", `${this.params.kills} / ${this.params.deaths}`); embed.addField("KD Ratio", this.params.deaths === 0 ? "0" : `${parseInt(this.params.kills) / parseInt(this.params.deaths)}`); if (!this.params.money) { embed.setDescription("You do not have an alive player on this server, some information will be missing"); } if (this.params.territories) { embed.addField("Territories", this.util.objectToStringFormatted(JSON.parse(this.params.territories))); } this.ESMBot.send(this.info.channel, embed); } }