Friday, September 20, 2024 2:51:24 AM
> settings

Customize


Authenticate

> gamble_response.js
const ESMCommand = require("../esm_command");
module.exports = class ESMCommand_Gamble_Response extends ESMCommand {
    constructor(bot) {
        super(bot);
        this.permissions = {
            restricted: true
        };
    }

    async fromServer() {
        if (this.this.util.isEmpty(this.params)) {
            return this.ESMBot.send(this.info.channel, "Something went wrong, please try again later");
        }

        let user = await this.ESMBot.getUser(this.info.author.id)
        if (this.this.util.isEmpty(user)) {
            this.ESMBot.send(this.info.channel, "I was unable to find the specified user.");
            return this.ESMBot.send(this.info.channel, `Anywho, someone just ${this.params.type} **${this.params.amount}** poptabs. They now have **${this.params.locker_after}** poptabs.\nUnfortunately, this won't count towards this person statistics.\nSomeone should tell someone about this so it can maybe be fixed... Maybe`);
        }

        let info = {};
        let winMessages = [{
                title: `Damn, you won **${user.username}**`,
                description: `You won **${this.params.amount}** poptabs. You now have **${this.params.locker_after}** poptabs`
            },
            {
                title: `Slow down **${user.username}**`,
                description: `You just won **${this.params.amount}** poptabs. You have **${this.params.locker_after}** poptabs in your locker`
            },
            {
                title: `Looks like drinks are on **${user.username}**`,
                description: `They just won **${this.params.amount}** poptabs. **${user.toString()}**, you have **${this.params.locker_after}** poptabs now.`
            },
            {
                title: `Hey **${user.username}**`,
                description: `Yes, you just won **${this.params.amount}** poptabs. Yes, your locker balance is now **${this.params.locker_after}** poptabs. But did you know gambling is a serious addiction? We are concerned about you, so we found [this](http://www.gamblersanonymous.org/ga/) for you.`
            },
            {
                title: `Guess what **${user.username}**?`,
                description: `You're one step closer to a new attack helicopter! You won **${this.params.amount}** poptabs, and have a total of **${this.params.locker_after}** poptabs in your locker`,
                submitted_by: "Geekm0nkey#9181"
            },
            {
                title: `**${user.username}**`,
                description: `Congratulations, you won **${this.params.amount}** poptabs, this is just enough to afford one month of FarmersOnly.com, **PREMIUM**`,
                submitted_by: "An Embarrassed Player"
            }
        ];

        let loseMessages = [{
                title: `RIPs, you are not a winner **${user.username}**`,
                description: `You lost **${this.params.amount}** poptabs. You have **${this.params.locker_after}** poptabs remaining.`
            },
            {
                title: `I'm sorry **${user.username}**`,
                description: `You just lost **${this.params.amount}** poptabs, but don't worry! Try gambling again and maybe you'll win it back. :wink:\nYou have **${this.params.locker_after}** poptabs left.`
            },
            {
                title: `Maybe next time **${user.username}**!`,
                description: `You lost **${this.params.amount}** poptabs. You have **${this.params.locker_after}** poptabs remaining.`
            },
            {
                title: `Don't quit your day job **${user.username}**`,
                description: `I'm serious, don't. You can't afford to. You lost **${this.params.amount}** poptabs and you have **${this.params.locker_after}** poptabs left.`
            },
            {
                title: `Look **${user.username}**, there is still hope.`,
                description: `You just lost **${this.params.amount}** poptabs, but that doesn't have to happen anymore. This [website](http://www.gamblersanonymous.org/ga/) has some awesome resources to help you get over your addiction. If you won't do it for yourself, please, do it for your community. You have **${this.params.locker_after}** poptabs left.`
            }
        ];

        switch (this.params.type) {
            case "won":
                info = await this.db.addGambleWin(this.params.user_id, this.serverID, parseInt(this.params.amount));
                break;
            case "loss":
                info = await this.db.addGambleLoss(this.params.user_id, this.serverID, parseInt(this.params.amount));
                break;
            default:
                this.ESMBot.send(this.info.channel, "It appears someone has attempted to break the code on the server and sent an invalid type. Please yell at the server owner to double check their code and tell them to stop messing with shit");
                return;
        }

        if (this.util.isEmpty(info)) {
            this.ESMBot.send(this.info.channel, "Something went wrong in the backend. Please try again later");
            return;
        }

        let message = info.last_action === "win" ? this.util.selectRandom(winMessages) : this.util.selectRandom(loseMessages);

        this.ESMBot.send(this.info.channel, {
            color: info.last_action === "win" ? Colors.GREEN : Colors.RED,
            title: message.title,
            description: message.description,
            footer: {
                text: `Current streak: ${info.current_streak}`
            }
        });
    }
}
All opinions represented herein are my own
- © 2024 itsthedevman
- build 340fbb8