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 Command from "../../core/command";
|
||||||
import {isAuthorized, getMoneyEmbed} from "./subcommands/eco-utils";
|
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";
|
import {BuyCommand, ShopCommand} from "./subcommands/eco-shop";
|
||||||
|
|
||||||
export default new Command({
|
export default new Command({
|
||||||
|
@ -12,6 +12,7 @@ export default new Command({
|
||||||
daily: DailyCommand,
|
daily: DailyCommand,
|
||||||
pay: PayCommand,
|
pay: PayCommand,
|
||||||
guild: GuildCommand,
|
guild: GuildCommand,
|
||||||
|
leaderboard: LeaderboardCommand,
|
||||||
buy: BuyCommand,
|
buy: BuyCommand,
|
||||||
shop: ShopCommand
|
shop: ShopCommand
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Command from "../../../core/command";
|
import Command from "../../../core/command";
|
||||||
import $ from "../../../core/lib";
|
import $ from "../../../core/lib";
|
||||||
import {Storage} from "../../../core/structures";
|
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({
|
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.",
|
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: {
|
embed: {
|
||||||
title: "Daily Reward",
|
title: "Daily Reward",
|
||||||
description: "You received 1 Mon!",
|
description: "You received 1 Mon!",
|
||||||
color: 0xf1c40f
|
color: ECO_EMBED_COLOR
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else
|
} else
|
||||||
channel.send({
|
channel.send({
|
||||||
embed: {
|
embed: {
|
||||||
title: "Daily Reward",
|
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) /
|
(user.lastReceived + 79200000 - now) /
|
||||||
3600000
|
3600000
|
||||||
).toFixed(1)} hours to go.`,
|
).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({
|
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.",
|
description: "See the richest players.",
|
||||||
async run({guild, channel, client}) {
|
async run({guild, channel, client}) {
|
||||||
if (isAuthorized(guild, channel)) {
|
if (isAuthorized(guild, channel)) {
|
||||||
|
@ -51,15 +88,18 @@ export const GuildCommand = new Command({
|
||||||
|
|
||||||
fields.push({
|
fields.push({
|
||||||
name: `#${i + 1}. ${user.username}#${user.discriminator}`,
|
name: `#${i + 1}. ${user.username}#${user.discriminator}`,
|
||||||
value: $(users[id].money).pluralise("credit", "s")
|
value: $(users[id].money).pluralise("Mon", "s")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
channel.send({
|
channel.send({
|
||||||
embed: {
|
embed: {
|
||||||
title: "Top 10 Richest Players",
|
title: "Top 10 Richest Players",
|
||||||
color: "#ffff00",
|
color: ECO_EMBED_COLOR,
|
||||||
fields: fields
|
fields: fields,
|
||||||
|
thumbnail: {
|
||||||
|
url: guild?.iconURL() ?? ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -109,7 +149,7 @@ export const PayCommand = new Command({
|
||||||
const amount = Math.floor(last);
|
const amount = Math.floor(last);
|
||||||
const sender = Storage.getUser(author.id);
|
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)
|
else if (sender.money < amount)
|
||||||
return channel.send("You don't have enough money to do that!", getMoneyEmbed(author));
|
return channel.send("You don't have enough money to do that!", getMoneyEmbed(author));
|
||||||
else if (!guild)
|
else if (!guild)
|
||||||
|
@ -136,12 +176,12 @@ export const PayCommand = new Command({
|
||||||
return prompt(
|
return prompt(
|
||||||
await channel.send(
|
await channel.send(
|
||||||
`Are you sure you want to send ${$(amount).pluralise(
|
`Are you sure you want to send ${$(amount).pluralise(
|
||||||
"credit",
|
"Mon",
|
||||||
"s"
|
"s"
|
||||||
)} to this person?\n*(This message will automatically be deleted after 10 seconds.)*`,
|
)} to this person?\n*(This message will automatically be deleted after 10 seconds.)*`,
|
||||||
{
|
{
|
||||||
embed: {
|
embed: {
|
||||||
color: "#ffff00",
|
color: ECO_EMBED_COLOR,
|
||||||
author: {
|
author: {
|
||||||
name: `${target.username}#${target.discriminator}`,
|
name: `${target.username}#${target.discriminator}`,
|
||||||
icon_url: target.displayAvatarURL({
|
icon_url: target.displayAvatarURL({
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Command from "../../../core/command";
|
import Command from "../../../core/command";
|
||||||
import $ from "../../../core/lib";
|
import $ from "../../../core/lib";
|
||||||
import {Storage, getPrefix} from "../../../core/structures";
|
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 {ShopItems, ShopItem} from "./eco-shop-items";
|
||||||
import {EmbedField} from "discord.js";
|
import {EmbedField} from "discord.js";
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ export const ShopCommand = new Command({
|
||||||
|
|
||||||
return {
|
return {
|
||||||
embed: {
|
embed: {
|
||||||
color: 0xf1c40f,
|
color: ECO_EMBED_COLOR,
|
||||||
title: title,
|
title: title,
|
||||||
fields: fields,
|
fields: fields,
|
||||||
footer: {
|
footer: {
|
||||||
|
|
|
@ -2,12 +2,14 @@ import $ from "../../../core/lib";
|
||||||
import {Storage} from "../../../core/structures";
|
import {Storage} from "../../../core/structures";
|
||||||
import {User, Guild, TextChannel, DMChannel, NewsChannel} from "discord.js";
|
import {User, Guild, TextChannel, DMChannel, NewsChannel} from "discord.js";
|
||||||
|
|
||||||
|
export const ECO_EMBED_COLOR = 0xf1c40f;
|
||||||
|
|
||||||
export function getMoneyEmbed(user: User): object {
|
export function getMoneyEmbed(user: User): object {
|
||||||
const profile = Storage.getUser(user.id);
|
const profile = Storage.getUser(user.id);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
embed: {
|
embed: {
|
||||||
color: 0xffff00,
|
color: ECO_EMBED_COLOR,
|
||||||
author: {
|
author: {
|
||||||
name: user.username,
|
name: user.username,
|
||||||
icon_url: user.displayAvatarURL({
|
icon_url: user.displayAvatarURL({
|
||||||
|
@ -18,7 +20,7 @@ export function getMoneyEmbed(user: User): object {
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: "Balance",
|
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 {
|
export function getSendEmbed(sender: User, receiver: User, amount: number): object {
|
||||||
return {
|
return {
|
||||||
embed: {
|
embed: {
|
||||||
color: 0xffff00,
|
color: ECO_EMBED_COLOR,
|
||||||
author: {
|
author: {
|
||||||
name: sender.username,
|
name: sender.username,
|
||||||
icon_url: sender.displayAvatarURL({
|
icon_url: sender.displayAvatarURL({
|
||||||
|
@ -37,18 +39,15 @@ export function getSendEmbed(sender: User, receiver: User, amount: number): obje
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
title: "Transaction",
|
title: "Transaction",
|
||||||
description: `${sender.toString()} has sent ${$(amount).pluralise(
|
description: `${sender.toString()} has sent ${$(amount).pluralise("Mon", "s")} to ${receiver.toString()}!`,
|
||||||
"credit",
|
|
||||||
"s"
|
|
||||||
)} to ${receiver.toString()}!`,
|
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: `Sender: ${sender.username}#${sender.discriminator}`,
|
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}`,
|
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: {
|
footer: {
|
||||||
|
|
Loading…
Reference in a new issue