mirror of
https://github.com/keanuplayz/TravBot-v3.git
synced 2024-08-15 02:33:12 +00:00
Ported the old eco guild command
This commit is contained in:
parent
5665a91af4
commit
4752adc7b4
4 changed files with 62 additions and 22 deletions
|
@ -1,6 +1,6 @@
|
|||
import Command from "../../core/command";
|
||||
import {isAuthorized, getMoneyEmbed} from "./subcommands/eco-utils";
|
||||
import {DailyCommand, PayCommand, GuildCommand} from "./subcommands/eco-core";
|
||||
import {DailyCommand, PayCommand, GuildCommand, LeaderboardCommand} from "./subcommands/eco-core";
|
||||
import {BuyCommand, ShopCommand} from "./subcommands/eco-shop";
|
||||
|
||||
export default new Command({
|
||||
|
@ -12,6 +12,7 @@ export default new Command({
|
|||
daily: DailyCommand,
|
||||
pay: PayCommand,
|
||||
guild: GuildCommand,
|
||||
leaderboard: LeaderboardCommand,
|
||||
buy: BuyCommand,
|
||||
shop: ShopCommand
|
||||
},
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import Command from "../../../core/command";
|
||||
import $ from "../../../core/lib";
|
||||
import {Storage} from "../../../core/structures";
|
||||
import {isAuthorized, getMoneyEmbed, getSendEmbed} from "./eco-utils";
|
||||
import {isAuthorized, getMoneyEmbed, getSendEmbed, ECO_EMBED_COLOR} from "./eco-utils";
|
||||
|
||||
export const DailyCommand = new Command({
|
||||
description: "Pick up your daily Mons. The cooldown is per user and every 22 hours to allow for some leeway.",
|
||||
|
@ -18,18 +18,18 @@ export const DailyCommand = new Command({
|
|||
embed: {
|
||||
title: "Daily Reward",
|
||||
description: "You received 1 Mon!",
|
||||
color: 0xf1c40f
|
||||
color: ECO_EMBED_COLOR
|
||||
}
|
||||
});
|
||||
} else
|
||||
channel.send({
|
||||
embed: {
|
||||
title: "Daily Reward",
|
||||
description: `It's too soon to pick up your daily credits. You have about ${(
|
||||
description: `It's too soon to pick up your daily Mons. You have about ${(
|
||||
(user.lastReceived + 79200000 - now) /
|
||||
3600000
|
||||
).toFixed(1)} hours to go.`,
|
||||
color: 0xf1c40f
|
||||
color: ECO_EMBED_COLOR
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -37,6 +37,43 @@ export const DailyCommand = new Command({
|
|||
});
|
||||
|
||||
export const GuildCommand = new Command({
|
||||
description: "Get info on the guild's economy as a whole.",
|
||||
async run({guild, channel}) {
|
||||
if (isAuthorized(guild, channel)) {
|
||||
const users = Storage.users;
|
||||
let totalAmount = 0;
|
||||
|
||||
for (const ID in users) {
|
||||
const user = users[ID];
|
||||
totalAmount += user.money;
|
||||
}
|
||||
|
||||
channel.send({
|
||||
embed: {
|
||||
title: `The Bank of ${guild!.name}`,
|
||||
color: ECO_EMBED_COLOR,
|
||||
fields: [
|
||||
{
|
||||
name: "Accounts",
|
||||
value: Object.keys(users).length,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: "Total Mons",
|
||||
value: totalAmount,
|
||||
inline: true
|
||||
}
|
||||
],
|
||||
thumbnail: {
|
||||
url: guild?.iconURL() ?? ""
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export const LeaderboardCommand = new Command({
|
||||
description: "See the richest players.",
|
||||
async run({guild, channel, client}) {
|
||||
if (isAuthorized(guild, channel)) {
|
||||
|
@ -51,15 +88,18 @@ export const GuildCommand = new Command({
|
|||
|
||||
fields.push({
|
||||
name: `#${i + 1}. ${user.username}#${user.discriminator}`,
|
||||
value: $(users[id].money).pluralise("credit", "s")
|
||||
value: $(users[id].money).pluralise("Mon", "s")
|
||||
});
|
||||
}
|
||||
|
||||
channel.send({
|
||||
embed: {
|
||||
title: "Top 10 Richest Players",
|
||||
color: "#ffff00",
|
||||
fields: fields
|
||||
color: ECO_EMBED_COLOR,
|
||||
fields: fields,
|
||||
thumbnail: {
|
||||
url: guild?.iconURL() ?? ""
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -109,7 +149,7 @@ export const PayCommand = new Command({
|
|||
const amount = Math.floor(last);
|
||||
const sender = Storage.getUser(author.id);
|
||||
|
||||
if (amount <= 0) return channel.send("You must send at least one credit!");
|
||||
if (amount <= 0) return channel.send("You must send at least one Mon!");
|
||||
else if (sender.money < amount)
|
||||
return channel.send("You don't have enough money to do that!", getMoneyEmbed(author));
|
||||
else if (!guild)
|
||||
|
@ -136,12 +176,12 @@ export const PayCommand = new Command({
|
|||
return prompt(
|
||||
await channel.send(
|
||||
`Are you sure you want to send ${$(amount).pluralise(
|
||||
"credit",
|
||||
"Mon",
|
||||
"s"
|
||||
)} to this person?\n*(This message will automatically be deleted after 10 seconds.)*`,
|
||||
{
|
||||
embed: {
|
||||
color: "#ffff00",
|
||||
color: ECO_EMBED_COLOR,
|
||||
author: {
|
||||
name: `${target.username}#${target.discriminator}`,
|
||||
icon_url: target.displayAvatarURL({
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import Command from "../../../core/command";
|
||||
import $ from "../../../core/lib";
|
||||
import {Storage, getPrefix} from "../../../core/structures";
|
||||
import {isAuthorized} from "./eco-utils";
|
||||
import {isAuthorized, ECO_EMBED_COLOR} from "./eco-utils";
|
||||
import {ShopItems, ShopItem} from "./eco-shop-items";
|
||||
import {EmbedField} from "discord.js";
|
||||
|
||||
|
@ -21,7 +21,7 @@ export const ShopCommand = new Command({
|
|||
|
||||
return {
|
||||
embed: {
|
||||
color: 0xf1c40f,
|
||||
color: ECO_EMBED_COLOR,
|
||||
title: title,
|
||||
fields: fields,
|
||||
footer: {
|
||||
|
|
|
@ -2,12 +2,14 @@ import $ from "../../../core/lib";
|
|||
import {Storage} from "../../../core/structures";
|
||||
import {User, Guild, TextChannel, DMChannel, NewsChannel} from "discord.js";
|
||||
|
||||
export const ECO_EMBED_COLOR = 0xf1c40f;
|
||||
|
||||
export function getMoneyEmbed(user: User): object {
|
||||
const profile = Storage.getUser(user.id);
|
||||
|
||||
return {
|
||||
embed: {
|
||||
color: 0xffff00,
|
||||
color: ECO_EMBED_COLOR,
|
||||
author: {
|
||||
name: user.username,
|
||||
icon_url: user.displayAvatarURL({
|
||||
|
@ -18,7 +20,7 @@ export function getMoneyEmbed(user: User): object {
|
|||
fields: [
|
||||
{
|
||||
name: "Balance",
|
||||
value: $(profile.money).pluralise("credit", "s")
|
||||
value: $(profile.money).pluralise("Mon", "s")
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -28,7 +30,7 @@ export function getMoneyEmbed(user: User): object {
|
|||
export function getSendEmbed(sender: User, receiver: User, amount: number): object {
|
||||
return {
|
||||
embed: {
|
||||
color: 0xffff00,
|
||||
color: ECO_EMBED_COLOR,
|
||||
author: {
|
||||
name: sender.username,
|
||||
icon_url: sender.displayAvatarURL({
|
||||
|
@ -37,18 +39,15 @@ export function getSendEmbed(sender: User, receiver: User, amount: number): obje
|
|||
})
|
||||
},
|
||||
title: "Transaction",
|
||||
description: `${sender.toString()} has sent ${$(amount).pluralise(
|
||||
"credit",
|
||||
"s"
|
||||
)} to ${receiver.toString()}!`,
|
||||
description: `${sender.toString()} has sent ${$(amount).pluralise("Mon", "s")} to ${receiver.toString()}!`,
|
||||
fields: [
|
||||
{
|
||||
name: `Sender: ${sender.username}#${sender.discriminator}`,
|
||||
value: $(Storage.getUser(sender.id).money).pluralise("credit", "s")
|
||||
value: $(Storage.getUser(sender.id).money).pluralise("Mon", "s")
|
||||
},
|
||||
{
|
||||
name: `Receiver: ${receiver.username}#${receiver.discriminator}`,
|
||||
value: $(Storage.getUser(receiver.id).money).pluralise("credit", "s")
|
||||
value: $(Storage.getUser(receiver.id).money).pluralise("Mon", "s")
|
||||
}
|
||||
],
|
||||
footer: {
|
||||
|
|
Loading…
Reference in a new issue