const { EmbedBuilder } = require('discord.js'); const { Bank, addBank } = require('../structures/bank'); module.exports = { name: "fine", debug: false, global: false, description: "Fine a user for an offense", usage: "[user] [amount]", permissions: { channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"], member: [], }, 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, } ], SlashCommand: { /** * * @param {require("../structures/QuarksBot")} client * @param {import("discord.js").Message} 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 = EmbedBuilder() .setColor(client.config.Colors.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 = EmbedBuilder() .setColor(client.config.Colors.Red) .setDescription(`**Notice: You require the <@&${GuildDB.officerRole}>**`) return interaction.send({ embeds: [embed] }); } const targetUserID = args[0].options[0].value.replace('<@!', '').replace('>', ''); let banking = await client.dbo.collection("banks").findOne({"banking.userID": targetUserID}).then(banking => banking); if (!banking) { banking = { userID: targetUserID, guidls: { [guildID]: { account: { balance: GuildDB.startingBalance, cash: 0.00, } } } } // Register inventory for user let newBank = new Bank(); newBank.createBank(targetUserID, GuildDB.serverID, GuildDB.startingBalance); newBank.save() .catch(err => { if (err) { client.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); } else banking = banking.banking; if (!client.exists(banking.guilds[GuildDB.serverID])) { const success = addBank(banking.guilds, GuildDB.serverID, targetUserID, client, GuildDB.startingBalance); if (!success) { client.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } } const newTargetBalance = banking.guilds[GuildDB.serverID].account.balance - args[0].options[1].value; client.dbo.collection("banks").updateOne({"banking.userID":targetUserID},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newTargetBalance}}, function(err, res) { if (err) { client.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); const successEmbed = new EmbedBuilder() .setTitle('Bank Notice:') .setDescription(`Successfully fined <@${targetUserID}> $${args[0].options[1].value.toFixed(2)}`) .setColor('GREEN'); return interaction.send({ embeds: [successEmbed] }); }, }, }