Friday, September 20, 2024 1:41:44 AM
> settings

Customize


Authenticate

> transfer.js
const ESMCommand = require("../esm_command");
module.exports = class ESMCommand_Transfer extends ESMCommand {
    constructor(bot) {
        super(bot);
        this.permissions = {
            requires_registration: true,
            requires_server: true
        };

        this.commandParams = {
            serverID: {
                regex: this.util.regex.serverID.base
            },
            target: {
                regex: this.util.regex.target.base
            },
            amount: {
                regex: /\d+/,
                parseAs: "int"
            }
        };

        this.information = {
            category: "server",
            params: "<server_id> <@user | steam_uid> <amount>",
            help: "Transfer poptabs out of your locker to the target player's locker on that server. The target player MUST be registered with ESM"
        };

        this.configuration = {
            allowedInTextChannels: {
                modifiable: true,
                default: true
            },
            cooldown: {
                modifiable: true,
                default: [2, "seconds"]
            },
            enabled: {
                modifiable: true,
                default: true
            }
        };
    }

    async fromDiscord() {
        if (this.params.amount < 1) {
            return this.ESMBot.send(this.message.channel, `Nice try, ${this.message.author.toString()}. You can't send nothing 😜`);
        }

        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 === this.params.steamUID) {
            return this.ESMBot.send(this.message.channel, `${this.message.author.toString()}, you cannot send yourself money 😜`);
        }

        this.send({
            command: "transfer",
            parameters: {
                function_name: "transferPoptabs",
                playerUID: this.params.steamUID,
                targetUID: this.params.target,
                amount: this.params.amount
            }
        });
    }

    async fromServer() {
        this.ESMBot.send(this.info.channel, `${this.info.author.tag}, your transfer of \`${this.info.parameters.amount}\` poptabs was a success.\nYou have \`${this.params.locker}\` poptabs left in your locker`);
    }
}
All opinions represented herein are my own
- © 2024 itsthedevman
- build 340fbb8