Fixed .eco embeds.
This commit is contained in:
parent
3751d01756
commit
8093224c46
|
@ -39,11 +39,14 @@ export const BetCommand = new NamedCommand({
|
||||||
// handle invalid amount
|
// handle invalid amount
|
||||||
if (amount <= 0) return send("You must bet at least one Mon!");
|
if (amount <= 0) return send("You must bet at least one Mon!");
|
||||||
else if (sender.money < amount)
|
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)
|
else if (receiver.money < amount)
|
||||||
return send({
|
return send({
|
||||||
content: "They don't have enough Mons for that.",
|
content: "They don't have enough Mons for that.",
|
||||||
embeds: [getMoneyEmbed(target)]
|
embeds: [getMoneyEmbed(target, true)]
|
||||||
});
|
});
|
||||||
|
|
||||||
return send("How long until the bet ends?");
|
return send("How long until the bet ends?");
|
||||||
|
@ -72,12 +75,12 @@ export const BetCommand = new NamedCommand({
|
||||||
else if (sender.money < amount)
|
else if (sender.money < amount)
|
||||||
return send({
|
return send({
|
||||||
content: "You don't have enough Mons for that.",
|
content: "You don't have enough Mons for that.",
|
||||||
embeds: [getMoneyEmbed(author)]
|
embeds: [getMoneyEmbed(author, true)]
|
||||||
});
|
});
|
||||||
else if (receiver.money < amount)
|
else if (receiver.money < amount)
|
||||||
return send({
|
return send({
|
||||||
content: "They don't have enough Mons for that.",
|
content: "They don't have enough Mons for that.",
|
||||||
embeds: [getMoneyEmbed(target)]
|
embeds: [getMoneyEmbed(target, true)]
|
||||||
});
|
});
|
||||||
|
|
||||||
// handle invalid duration
|
// handle invalid duration
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import {TextChannel} from "discord.js";
|
|
||||||
import {Command, getUserByNickname, NamedCommand, confirm, RestCommand} from "onion-lasers";
|
import {Command, getUserByNickname, NamedCommand, confirm, RestCommand} from "onion-lasers";
|
||||||
import {pluralise} from "../../../lib";
|
import {pluralise} from "../../../lib";
|
||||||
import {Storage} from "../../../structures";
|
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!");
|
if (amount <= 0) return send("You must send at least one Mon!");
|
||||||
else if (sender.money < amount)
|
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.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!");
|
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!");
|
if (amount <= 0) return send("You must send at least one Mon!");
|
||||||
else if (sender.money < amount)
|
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)
|
else if (!guild)
|
||||||
return send("You have to use this in a server if you want to send Mons with a username!");
|
return send("You have to use this in a server if you want to send Mons with a username!");
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ export const MondayCommand = new NamedCommand({
|
||||||
user.money++;
|
user.money++;
|
||||||
user.lastMonday = now.getTime();
|
user.lastMonday = now.getTime();
|
||||||
Storage.save();
|
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 send("You've already claimed your **Mon**day reward for this week.");
|
||||||
} else {
|
} else {
|
||||||
const weekdayName = WEEKDAY[weekday];
|
const weekdayName = WEEKDAY[weekday];
|
||||||
|
@ -47,7 +47,7 @@ export const AwardCommand = new NamedCommand({
|
||||||
const user = Storage.getUser(target.id);
|
const user = Storage.getUser(target.id);
|
||||||
user.money++;
|
user.money++;
|
||||||
Storage.save();
|
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 {
|
} else {
|
||||||
send("This command is restricted to the bean.");
|
send("This command is restricted to the bean.");
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ export const AwardCommand = new NamedCommand({
|
||||||
Storage.save();
|
Storage.save();
|
||||||
send({
|
send({
|
||||||
content: `${pluralise(amount, "Mon", "s")} given to ${target.username}.`,
|
content: `${pluralise(amount, "Mon", "s")} given to ${target.username}.`,
|
||||||
embeds: [getMoneyEmbed(target)]
|
embeds: [getMoneyEmbed(target, true)]
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
send("You need to enter a number greater than 0.");
|
send("You need to enter a number greater than 0.");
|
||||||
|
|
|
@ -4,66 +4,91 @@ import {User, Guild, TextChannel, DMChannel, NewsChannel, Channel, TextBasedChan
|
||||||
|
|
||||||
export const ECO_EMBED_COLOR = 0xf1c40f;
|
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);
|
const profile = Storage.getUser(user.id);
|
||||||
console.log(profile);
|
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 {
|
return {
|
||||||
embeds: [
|
embeds: [
|
||||||
{
|
{
|
||||||
color: ECO_EMBED_COLOR,
|
color: ECO_EMBED_COLOR,
|
||||||
author: {
|
author: {
|
||||||
name: user.username,
|
name: sender.username,
|
||||||
icon_url: user.displayAvatarURL({
|
icon_url: sender.displayAvatarURL({
|
||||||
format: "png",
|
format: "png",
|
||||||
dynamic: true
|
dynamic: true
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
title: "Transaction",
|
||||||
|
description: `${sender.toString()} has sent ${pluralise(
|
||||||
|
amount,
|
||||||
|
"Mon",
|
||||||
|
"s"
|
||||||
|
)} to ${receiver.toString()}!`,
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: "Balance",
|
name: `Sender: ${sender.tag}`,
|
||||||
value: pluralise(profile.money, "Mon", "s")
|
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 {
|
export function isAuthorized(guild: Guild | null, channel: TextBasedChannels): boolean {
|
||||||
if (IS_DEV_MODE) {
|
if (IS_DEV_MODE) {
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue