nyx/commands/Economy/give.js

41 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-06-12 12:53:51 +02:00
const { Client, Message, MessageEmbed } = require("discord.js");
module.exports = {
name: "give",
aliases: ["share"],
timeout: 5000,
usage: "(User) (Number)",
description: "Give money to an user",
category: "Economy",
run: async (client, message, args) => {
const user =
message.mentions.users.first() ||
message.guild.members.cache.find(
r => r.user.username.toLowerCase() === args[0].toLocaleLowerCase()
) ||
message.guild.members.cache.find(
r => r.displayName.toLowerCase() === args[0].toLocaleLowerCase()
);
if (!user) return client.err(message, "Economy", "give", 1);
const parsed = parseInt(args[1]);
if (!args[1]) return client.err(message, "Economy", "give", 5);
if (isNaN(parsed)) return client.err(message, "Economy", "give", 7);
if (user.id === message.author.id)
return client.err(message, "Economy", "give", 2);
2021-07-13 05:17:39 +02:00
if (parsed > (await client.bal(message.author.id))) {
2021-06-12 12:53:51 +02:00
return client.err(message, "Economy", "give", 20);
}
2021-07-13 05:17:39 +02:00
await client.rmv(message.author.id, parsed);
await client.add(user.id, parsed, message);
2021-06-12 12:53:51 +02:00
message.channel.send(
new MessageEmbed()
.setColor(client.color)
.setTimestamp()
.setDescription(
`**${message.author.username}** has given **${
user.username
2021-07-13 05:17:39 +02:00
}** **${parsed.toLocaleString()}**${client.currency}`
2021-06-12 12:53:51 +02:00
)
);
},
};