diff --git a/src/commands/fun/modules/eco-bet.ts b/src/commands/fun/modules/eco-bet.ts index 9852f6a..669a931 100644 --- a/src/commands/fun/modules/eco-bet.ts +++ b/src/commands/fun/modules/eco-bet.ts @@ -39,11 +39,14 @@ export const BetCommand = new NamedCommand({ // handle invalid amount if (amount <= 0) return send("You must bet at least one Mon!"); else if (sender.money < amount) - return send({content: "You don't have enough Mons for that.", embeds: [getMoneyEmbed(author)]}); + return send({ + content: "You don't have enough Mons for that.", + embeds: [getMoneyEmbed(author, true)] + }); else if (receiver.money < amount) return send({ content: "They don't have enough Mons for that.", - embeds: [getMoneyEmbed(target)] + embeds: [getMoneyEmbed(target, true)] }); return send("How long until the bet ends?"); @@ -72,12 +75,12 @@ export const BetCommand = new NamedCommand({ else if (sender.money < amount) return send({ content: "You don't have enough Mons for that.", - embeds: [getMoneyEmbed(author)] + embeds: [getMoneyEmbed(author, true)] }); else if (receiver.money < amount) return send({ content: "They don't have enough Mons for that.", - embeds: [getMoneyEmbed(target)] + embeds: [getMoneyEmbed(target, true)] }); // handle invalid duration diff --git a/src/commands/fun/modules/eco-core.ts b/src/commands/fun/modules/eco-core.ts index 7f7e3c4..9ccad85 100644 --- a/src/commands/fun/modules/eco-core.ts +++ b/src/commands/fun/modules/eco-core.ts @@ -1,4 +1,3 @@ -import {TextChannel} from "discord.js"; import {Command, getUserByNickname, NamedCommand, confirm, RestCommand} from "onion-lasers"; import {pluralise} from "../../../lib"; import {Storage} from "../../../structures"; @@ -139,7 +138,10 @@ export const PayCommand = new NamedCommand({ if (amount <= 0) return send("You must send at least one Mon!"); else if (sender.money < amount) - return send({content: "You don't have enough Mons for that.", embeds: [getMoneyEmbed(author)]}); + return send({ + content: "You don't have enough Mons for that.", + embeds: [getMoneyEmbed(author, true)] + }); else if (target.id === author.id) return send("You can't send Mons to yourself!"); else if (target.bot && !IS_DEV_MODE) return send("You can't send Mons to a bot!"); @@ -166,7 +168,10 @@ export const PayCommand = new NamedCommand({ if (amount <= 0) return send("You must send at least one Mon!"); else if (sender.money < amount) - return send({content: "You don't have enough Mons to do that!", embeds: [getMoneyEmbed(author)]}); + return send({ + content: "You don't have enough Mons to do that!", + embeds: [getMoneyEmbed(author, true)] + }); else if (!guild) return send("You have to use this in a server if you want to send Mons with a username!"); diff --git a/src/commands/fun/modules/eco-extras.ts b/src/commands/fun/modules/eco-extras.ts index 35a46b4..87b8a4b 100644 --- a/src/commands/fun/modules/eco-extras.ts +++ b/src/commands/fun/modules/eco-extras.ts @@ -21,7 +21,7 @@ export const MondayCommand = new NamedCommand({ user.money++; user.lastMonday = now.getTime(); Storage.save(); - send({content: "It is **Mon**day, my dudes.", embeds: [getMoneyEmbed(author)]}); + send({content: "It is **Mon**day, my dudes.", embeds: [getMoneyEmbed(author, true)]}); } else send("You've already claimed your **Mon**day reward for this week."); } else { const weekdayName = WEEKDAY[weekday]; @@ -47,7 +47,7 @@ export const AwardCommand = new NamedCommand({ const user = Storage.getUser(target.id); user.money++; Storage.save(); - send({content: `1 Mon given to ${target.username}.`, embeds: [getMoneyEmbed(target)]}); + send({content: `1 Mon given to ${target.username}.`, embeds: [getMoneyEmbed(target, true)]}); } else { send("This command is restricted to the bean."); } @@ -64,7 +64,7 @@ export const AwardCommand = new NamedCommand({ Storage.save(); send({ content: `${pluralise(amount, "Mon", "s")} given to ${target.username}.`, - embeds: [getMoneyEmbed(target)] + embeds: [getMoneyEmbed(target, true)] }); } else { send("You need to enter a number greater than 0."); diff --git a/src/commands/fun/modules/eco-utils.ts b/src/commands/fun/modules/eco-utils.ts index dba9251..fd9ddc6 100644 --- a/src/commands/fun/modules/eco-utils.ts +++ b/src/commands/fun/modules/eco-utils.ts @@ -4,66 +4,91 @@ import {User, Guild, TextChannel, DMChannel, NewsChannel, Channel, TextBasedChan export const ECO_EMBED_COLOR = 0xf1c40f; -export function getMoneyEmbed(user: User): object { +export function getMoneyEmbed(user: User, inline: boolean = false): object { const profile = Storage.getUser(user.id); console.log(profile); + if (inline) { + return { + color: ECO_EMBED_COLOR, + author: { + name: user.username, + icon_url: user.displayAvatarURL({ + format: "png", + dynamic: true + }) + }, + fields: [ + { + name: "Balance", + value: pluralise(profile.money, "Mon", "s") + } + ] + }; + } else { + return { + embeds: [ + { + color: ECO_EMBED_COLOR, + author: { + name: user.username, + icon_url: user.displayAvatarURL({ + format: "png", + dynamic: true + }) + }, + fields: [ + { + name: "Balance", + value: pluralise(profile.money, "Mon", "s") + } + ] + } + ] + }; + } +} + +export function getSendEmbed(sender: User, receiver: User, amount: number): object { return { embeds: [ { color: ECO_EMBED_COLOR, author: { - name: user.username, - icon_url: user.displayAvatarURL({ + name: sender.username, + icon_url: sender.displayAvatarURL({ format: "png", dynamic: true }) }, + title: "Transaction", + description: `${sender.toString()} has sent ${pluralise( + amount, + "Mon", + "s" + )} to ${receiver.toString()}!`, fields: [ { - name: "Balance", - value: pluralise(profile.money, "Mon", "s") + name: `Sender: ${sender.tag}`, + value: pluralise(Storage.getUser(sender.id).money, "Mon", "s") + }, + { + name: `Receiver: ${receiver.tag}`, + value: pluralise(Storage.getUser(receiver.id).money, "Mon", "s") } - ] + ], + footer: { + text: receiver.username, + icon_url: receiver.displayAvatarURL({ + format: "png", + dynamic: true + }) + } } ] }; } -export function getSendEmbed(sender: User, receiver: User, amount: number): object { - return { - embed: { - color: ECO_EMBED_COLOR, - author: { - name: sender.username, - icon_url: sender.displayAvatarURL({ - format: "png", - dynamic: true - }) - }, - title: "Transaction", - description: `${sender.toString()} has sent ${pluralise(amount, "Mon", "s")} to ${receiver.toString()}!`, - fields: [ - { - name: `Sender: ${sender.tag}`, - value: pluralise(Storage.getUser(sender.id).money, "Mon", "s") - }, - { - name: `Receiver: ${receiver.tag}`, - value: pluralise(Storage.getUser(receiver.id).money, "Mon", "s") - } - ], - footer: { - text: receiver.username, - icon_url: receiver.displayAvatarURL({ - format: "png", - dynamic: true - }) - } - } - }; -} - export function isAuthorized(guild: Guild | null, channel: TextBasedChannels): boolean { if (IS_DEV_MODE) { return true;