add fine command

This commit is contained in:
SowinskiBraeden committed 2022-08-04 13:31:05 -07:00
1 parent a21d54ccc0
commit 4f44b77eb1
2 files changed
+104 -6

No files matched your search

+103
View File
@@ -0,0 +1,103 @@
const { MessageEmbed } = require('discord.js');
module.exports = {
name: "fine",
debug: false,
description: "Fine a user for an offense",
usage: "[user] [amount]",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
SlashCommand: {
options: [
{
name: "user",
description: "The user to fine",
value: "user",
type: 6,
required: true,
},
{
name: "amount",
description: "Amount the fine totals to",
value: "amount",
type: 10,
min_value: 0.01,
required: true,
}
],
/**
*
* @param {require("../structures/QuarksBot")} client
* @param {import("discord.js").MessageCreate} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, interaction, args, { GuildDB }) => {
if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) {
return interaction.send(`You are not allowed to use the bot in this channel.`);
}
if (!GuildDB.officerRole) {
const embed = MessageEmbed()
.setColor("RED")
.setDescription("**Notice:** The admins have not set an officer role.")
return interaction.send({ embeds: [embed] });
}
if (!interaction.member.roles.includes(GuildDB.officerRole)) {
const embed = MessageEmbed()
.setColor("RED")
.setDescription(`**Notice: You require the <@&${GuildDB.officerRole}>**`)
return interaction.send({ embeds: [embed] });
}
const targetUserID = args[0].options[0].value.replace('<@!', '').replace('>', '');
let targetUserBanking = await client.dbo.collection("banking").findOne({"account.userID": targetUserID}).then(banking => banking);
if (!targetUserBanking) {
targetUserBanking = {
account: {
userID: targetUserID,
balance: (GuildDB.startingBalance - args[0].options[1].value),
cash: 0.00,
}
}
client.dbo.collection("banking").insertOne(targetUserBanking, function(err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor("RED")
return interaction.send({ embeds: [embed] });
}
});
} else {
const newTargetBalance = targetUserBanking.account.balance - args[0].options[1].value;
client.dbo.collection("banking").updateOne({"account.userID":targetUserID},{$set:{"account.balance":newTargetBalance}}, function(err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor("RED")
return interaction.send({ embeds: [embed] });
}
});
}
const successEmbed = new MessageEmbed()
.setTitle('Bank Notice:')
.setDescription(`Successfully fined <@${targetUserID}> $${args[0].options[1].value.toFixed(2)}`)
.setColor('GREEN');
return interaction.send({ embeds: [successEmbed] });
},
},
}
+1 -6
View File
@@ -28,13 +28,8 @@ module.exports = (client, guild) => {
try {
await GuildAPI.commands.post({ data: dataStuff });
} catch (e) {
if (client.config.Dev == 'DEV') console.log(e);
if (client.config.Dev == 'DEV.') console.log(e);
client.log('Error: API missing permissions, re-invite the bot');
// Forces bot to leave server
let guildID = client.guilds.cache.get(guild);
if (guildID) guildID.leave();
client.log(`Server stats is now down to ${client.guilds.cache.size}`);
}
});
});