2021-04-05 04:35:12 +00:00
|
|
|
import {pluralise} from "../../../lib";
|
|
|
|
import {Storage} from "../../../structures";
|
2021-10-29 12:52:46 +00:00
|
|
|
import {User, Guild, TextChannel, DMChannel, NewsChannel, Channel, TextBasedChannels} from "discord.js";
|
2020-11-04 08:04:07 +00:00
|
|
|
|
2020-12-15 11:15:28 +00:00
|
|
|
export const ECO_EMBED_COLOR = 0xf1c40f;
|
|
|
|
|
2020-11-04 08:04:07 +00:00
|
|
|
export function getMoneyEmbed(user: User): object {
|
2020-12-15 01:44:28 +00:00
|
|
|
const profile = Storage.getUser(user.id);
|
2021-10-31 16:59:29 +00:00
|
|
|
console.log(profile);
|
2020-11-04 08:04:07 +00:00
|
|
|
|
2020-12-15 01:44:28 +00:00
|
|
|
return {
|
2021-10-31 16:59:29 +00:00
|
|
|
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")
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
2020-12-15 01:44:28 +00:00
|
|
|
};
|
2020-11-04 08:04:07 +00:00
|
|
|
}
|
|
|
|
|
2020-12-15 07:56:09 +00:00
|
|
|
export function getSendEmbed(sender: User, receiver: User, amount: number): object {
|
2020-12-15 01:44:28 +00:00
|
|
|
return {
|
|
|
|
embed: {
|
2020-12-15 11:15:28 +00:00
|
|
|
color: ECO_EMBED_COLOR,
|
2020-12-15 01:44:28 +00:00
|
|
|
author: {
|
|
|
|
name: sender.username,
|
|
|
|
icon_url: sender.displayAvatarURL({
|
|
|
|
format: "png",
|
|
|
|
dynamic: true
|
|
|
|
})
|
|
|
|
},
|
|
|
|
title: "Transaction",
|
2021-03-30 10:25:07 +00:00
|
|
|
description: `${sender.toString()} has sent ${pluralise(amount, "Mon", "s")} to ${receiver.toString()}!`,
|
2020-12-15 01:44:28 +00:00
|
|
|
fields: [
|
|
|
|
{
|
2021-04-11 08:02:56 +00:00
|
|
|
name: `Sender: ${sender.tag}`,
|
2021-03-30 10:25:07 +00:00
|
|
|
value: pluralise(Storage.getUser(sender.id).money, "Mon", "s")
|
2020-12-15 01:44:28 +00:00
|
|
|
},
|
|
|
|
{
|
2021-04-11 08:02:56 +00:00
|
|
|
name: `Receiver: ${receiver.tag}`,
|
2021-03-30 10:25:07 +00:00
|
|
|
value: pluralise(Storage.getUser(receiver.id).money, "Mon", "s")
|
2020-12-15 01:44:28 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
footer: {
|
|
|
|
text: receiver.username,
|
|
|
|
icon_url: receiver.displayAvatarURL({
|
|
|
|
format: "png",
|
|
|
|
dynamic: true
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2020-11-04 08:04:07 +00:00
|
|
|
}
|
|
|
|
|
2021-10-29 12:52:46 +00:00
|
|
|
export function isAuthorized(guild: Guild | null, channel: TextBasedChannels): boolean {
|
2021-10-30 10:50:57 +00:00
|
|
|
if (IS_DEV_MODE) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (guild?.id !== "637512823676600330") {
|
|
|
|
channel.send("Sorry, this command can only be used in Monika's emote server.");
|
|
|
|
return false;
|
|
|
|
} else if (channel?.id !== "669464416420364288") {
|
|
|
|
channel.send("Sorry, this command can only be used in <#669464416420364288>.");
|
|
|
|
return false;
|
|
|
|
} else {
|
2020-12-15 01:44:28 +00:00
|
|
|
return false;
|
|
|
|
}
|
2020-11-04 08:04:07 +00:00
|
|
|
}
|