reset cmd/improve money cmd/fix settings cmd options
This commit is contained in:
5 files changed
+200
-126
No files matched your search
@@ -540,7 +540,7 @@ module.exports = {
|
||||
|
||||
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||
|
||||
client.on("interactionCreate", ButtonInteraction => {
|
||||
client.once("interactionCreate", ButtonInteraction => {
|
||||
if(!ButtonInteraction.isButton()) return;
|
||||
const queryString = ButtonInteraction.customId;
|
||||
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
||||
|
||||
+40
-85
@@ -12,51 +12,30 @@ module.exports = {
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: "add",
|
||||
description: "Add money to user",
|
||||
value: "add",
|
||||
type: 1,
|
||||
options: [
|
||||
{
|
||||
name: "user",
|
||||
description: "User to give money",
|
||||
value: "user",
|
||||
type: 6,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: "amount",
|
||||
description: "The amount to add to balance",
|
||||
value: "amount",
|
||||
type: 5,
|
||||
min_value: 0.01,
|
||||
required: true,
|
||||
}
|
||||
],
|
||||
name: "add_or_remove",
|
||||
description: "Add or remove money from a user",
|
||||
value: "add_or_remove",
|
||||
type: 3,
|
||||
required: true,
|
||||
choices: [
|
||||
{ name: "add", value: "add" }, { name: "remove", value: "remove" },
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "remove",
|
||||
description: "Remove money from user",
|
||||
value: "remove",
|
||||
type: 1,
|
||||
options: [
|
||||
{
|
||||
name: "user",
|
||||
description: "User to remove money from",
|
||||
value: "user",
|
||||
type: 6,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: "amount",
|
||||
description: "The amount to add to balance",
|
||||
value: "amount",
|
||||
type: 5,
|
||||
min_value: 0.01,
|
||||
required: true,
|
||||
}
|
||||
],
|
||||
}
|
||||
name: "amount",
|
||||
description: "The amount to add to balance",
|
||||
value: "amount",
|
||||
type: 5,
|
||||
min_value: 0.01,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: "from",
|
||||
description: "User to alter balance",
|
||||
value: "from",
|
||||
type: 6,
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
SlashCommand: {
|
||||
/**
|
||||
@@ -78,7 +57,7 @@ module.exports = {
|
||||
if (client.exists(GuildDB.botAdmin) && interaction.member.roles.includes(GuildDB.botAdmin)) canUseCommand = true;
|
||||
if (!canUseCommand) return interaction.send('You don\'t have the permissions to use this command.');
|
||||
|
||||
let targetUserID = args[0].options[0].value.replace('<@!', '').replace('>', '');
|
||||
const targetUserID = args[2].value.replace('<@!', '').replace('>', '');
|
||||
let banking = await client.dbo.collection("banks").findOne({"account.userID": targetUserID}).then(banking => banking);
|
||||
|
||||
if (!banking) {
|
||||
@@ -122,51 +101,27 @@ module.exports = {
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
}
|
||||
|
||||
if (args[0].name == "add") {
|
||||
// add money to user
|
||||
|
||||
let newBalance = banking.guilds[GuildDB.serverID].account.balance + args[0].options[1].value;
|
||||
|
||||
const newBalance = args[0] == 'add'
|
||||
? banking.guilds[GuildDB.serverID].account.balance + args[1].value
|
||||
: banking.guilds[GuildDB.serverID].account.balance - args[1].value;
|
||||
|
||||
client.dbo.collection("banks").updateOne({"account.userID":targetUserID},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance}}, function(err, res) {
|
||||
if (err) {
|
||||
client.log(err);
|
||||
const embed = new EmbedBuilder()
|
||||
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
||||
.setColor(client.config.Colors.Red)
|
||||
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
});
|
||||
|
||||
client.dbo.collection("banks").updateOne({"account.userID":targetUserID},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance}}, function(err, res) {
|
||||
if (err) {
|
||||
client.log(err);
|
||||
const embed = new EmbedBuilder()
|
||||
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
||||
.setColor(client.config.Colors.Red)
|
||||
|
||||
let successEmbed = new EmbedBuilder()
|
||||
.setDescription(`Successfully added $${args[0].options[1].value.toFixed(2)} to <@${targetUserID}>'s balance`)
|
||||
.setColor('GREEN');
|
||||
|
||||
return interaction.send({ embeds: [successEmbed] });
|
||||
} else if (args[0].name == "remove") {
|
||||
// remove money from user
|
||||
|
||||
let newBalance = banking.guilds[GuildDB.serverID].account.balance - args[0].options[1].value;
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
});
|
||||
|
||||
client.dbo.collection("banks").updateOne({"account.userID":targetUserID},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance}}, function(err, res) {
|
||||
if (err) {
|
||||
client.log(err);
|
||||
const embed = new EmbedBuilder()
|
||||
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
||||
.setColor(client.config.Colors.Red)
|
||||
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
});
|
||||
|
||||
let successEmbed = new EmbedBuilder()
|
||||
.setDescription(`Successfully removed $${args[0].options[1].value.toFixed(2)} from <@${targetUserID}>'s balance`)
|
||||
.setColor('GREEN');
|
||||
const successEmbed = new EmbedBuilder()
|
||||
.setDescription(`Successfully ${args[0] == 'add' ? 'added' : 'removed'} $${args[0].options[1].value.toFixed(2)} ${args[0] == 'add' ? 'to' : 'from'} <@${targetUserID}>'s balance`)
|
||||
.setColor('GREEN');
|
||||
|
||||
return interaction.send({ embeds: [successEmbed] });
|
||||
}
|
||||
return interaction.send({ embeds: [successEmbed] });
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
const { addInventory } = require('../structures/inventory');
|
||||
const { addBank } = require('../structures/bank');
|
||||
|
||||
module.exports = {
|
||||
name: "",
|
||||
debug: false,
|
||||
description: "",
|
||||
usage: "",
|
||||
permissions: {
|
||||
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
|
||||
member: [],
|
||||
},
|
||||
options: [{
|
||||
name: "user",
|
||||
description: "User to reset",
|
||||
value: "user",
|
||||
type: 6,
|
||||
required: true,
|
||||
}],
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @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.`);
|
||||
}
|
||||
|
||||
const permissions = bitfieldCalculator.permissions(interaction.member.permissions);
|
||||
let canUseCommand = false;
|
||||
|
||||
if (permissions.includes("MANAGE_GUILD")) canUseCommand = true;
|
||||
if (client.exists(GuildDB.botAdmin) && interaction.member.roles.includes(GuildDB.botAdmin)) canUseCommand = true;
|
||||
if (!canUseCommand) return interaction.send('You don\'t have the permissions to use this command.');
|
||||
|
||||
const targetUserID = args[0].value.replace('<@!', '').replace('>', '');
|
||||
|
||||
const prompt = new EmbedBuilder()
|
||||
.setTitle(`Are you sure you want to reset this user?`)
|
||||
.setDescription('**Notice:** This will reset this users, cash, balance, and invnetory back to defaults.')
|
||||
.setColor(client.config.Colors.Yellow)
|
||||
|
||||
const opt = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`yes-${interaction.member.user.id}`)
|
||||
.setLabel("Yes")
|
||||
.setStyle(ButtonStyle.Danger),
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`no-${interaction.member.user.id}`)
|
||||
.setLabel("No")
|
||||
.setStyle(ButtonStyle.Success)
|
||||
)
|
||||
|
||||
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||
|
||||
client.once("interactionCreate", ButtonInteraction => {
|
||||
if(!ButtonInteraction.isButton()) return;
|
||||
const queryString = ButtonInteraction.customId;
|
||||
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
||||
return ButtonInteraction.reply({
|
||||
content: "This button is not for you",
|
||||
flags: (1 << 6)
|
||||
})
|
||||
}
|
||||
if (queryString==`yes-${interaction.member.user.id}`) {
|
||||
const successEmbed = new EmbedBuilder()
|
||||
.setColor(client.config.Colors.Green)
|
||||
.setTitle('Successfully reset user\'s data')
|
||||
|
||||
let inventory = await client.dbo.collection("inventories").findOne({"inventory.userID": interaction.member.user.id}).then(inventory => inventory);
|
||||
let banking = await client.dbo.collection("banks").findOne({"account.userID": interaction.member.user.id}).then(banking => banking);
|
||||
|
||||
let inventoryReset = false;
|
||||
let bankingReset = false;
|
||||
if (!inventory) inventoryReset = true
|
||||
else inventory = inventory.inventory
|
||||
if (!banking) bankingReset = true
|
||||
else banking = banking.banking
|
||||
|
||||
if (inventoryReset && bankingReset) return ButtonInteraction.update({ embeds: [successEmbed], components: [] });
|
||||
|
||||
if (!inventoryReset) {
|
||||
const success = addInventory(inventory.guilds, GuildDB.serverID, targetUserID, client);
|
||||
if (!success) {
|
||||
client.log(err);
|
||||
const embed = new EmbedBuilder()
|
||||
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
||||
.setColor(client.config.Colors.Red)
|
||||
|
||||
return ButtonInteraction.update({ embeds: [embed], components: [] });
|
||||
}
|
||||
}
|
||||
|
||||
if (!bankingReset) {
|
||||
const success = addBank(banking.guilds, GuildDB.serverID, targetUserID, client);
|
||||
if (!success) {
|
||||
client.log(err);
|
||||
const embed = new EmbedBuilder()
|
||||
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
||||
.setColor(client.config.Colors.Red)
|
||||
|
||||
return ButtonInteraction.update({ embeds: [embed], components: [] });
|
||||
}
|
||||
}
|
||||
|
||||
return ButtonInteraction.update({ embeds: [successEmbed], components: [] });
|
||||
|
||||
} else if (queryString==`no-${interaction.member.user.id}`) {
|
||||
const successEmbed = new EmbedBuilder()
|
||||
.setColor(client.config.Colors.Green)
|
||||
.setTitle(`The User was not reset`);
|
||||
|
||||
return ButtonInteraction.update({ embeds: [successEmbed], components: [] });
|
||||
}
|
||||
});
|
||||
return;
|
||||
},
|
||||
},
|
||||
}
|
||||
+10
-10
@@ -413,7 +413,7 @@ module.exports = {
|
||||
|
||||
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||
|
||||
client.on("interactionCreate", ButtonInteraction => {
|
||||
client.once("interactionCreate", ButtonInteraction => {
|
||||
if(!ButtonInteraction.isButton()) return;
|
||||
const queryString = ButtonInteraction.customId;
|
||||
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
||||
@@ -491,7 +491,7 @@ module.exports = {
|
||||
|
||||
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||
|
||||
client.on("interactionCreate", ButtonInteraction => {
|
||||
client.once("interactionCreate", ButtonInteraction => {
|
||||
if(!ButtonInteraction.isButton()) return;
|
||||
const queryString = ButtonInteraction.customId;
|
||||
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
||||
@@ -569,7 +569,7 @@ module.exports = {
|
||||
|
||||
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||
|
||||
client.on("interactionCreate", ButtonInteraction => {
|
||||
client.once("interactionCreate", ButtonInteraction => {
|
||||
if(!ButtonInteraction.isButton()) return;
|
||||
const queryString = ButtonInteraction.customId;
|
||||
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
||||
@@ -647,7 +647,7 @@ module.exports = {
|
||||
|
||||
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||
|
||||
client.on("interactionCreate", ButtonInteraction => {
|
||||
client.once("interactionCreate", ButtonInteraction => {
|
||||
if(!ButtonInteraction.isButton()) return;
|
||||
const queryString = ButtonInteraction.customId;
|
||||
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
||||
@@ -726,7 +726,7 @@ module.exports = {
|
||||
|
||||
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||
|
||||
client.on("interactionCreate", ButtonInteraction => {
|
||||
client.once("interactionCreate", ButtonInteraction => {
|
||||
if(!ButtonInteraction.isButton()) return;
|
||||
const queryString = ButtonInteraction.customId;
|
||||
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
||||
@@ -854,7 +854,7 @@ module.exports = {
|
||||
|
||||
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||
|
||||
client.on("interactionCreate", ButtonInteraction => {
|
||||
client.once("interactionCreate", ButtonInteraction => {
|
||||
if(!ButtonInteraction.isButton()) return;
|
||||
const queryString = ButtonInteraction.customId;
|
||||
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
||||
@@ -928,7 +928,7 @@ module.exports = {
|
||||
|
||||
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||
|
||||
client.on("interactionCreate", ButtonInteraction => {
|
||||
client.once("interactionCreate", ButtonInteraction => {
|
||||
if(!ButtonInteraction.isButton()) return;
|
||||
const queryString = ButtonInteraction.customId;
|
||||
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
||||
@@ -1002,7 +1002,7 @@ module.exports = {
|
||||
|
||||
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||
|
||||
client.on("interactionCreate", ButtonInteraction => {
|
||||
client.once("interactionCreate", ButtonInteraction => {
|
||||
if(!ButtonInteraction.isButton()) return;
|
||||
const queryString = ButtonInteraction.customId;
|
||||
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
||||
@@ -1076,7 +1076,7 @@ module.exports = {
|
||||
|
||||
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||
|
||||
client.on("interactionCreate", ButtonInteraction => {
|
||||
client.once("interactionCreate", ButtonInteraction => {
|
||||
if(!ButtonInteraction.isButton()) return;
|
||||
const queryString = ButtonInteraction.customId;
|
||||
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
||||
@@ -1150,7 +1150,7 @@ module.exports = {
|
||||
|
||||
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||
|
||||
client.on("interactionCreate", ButtonInteraction => {
|
||||
client.once("interactionCreate", ButtonInteraction => {
|
||||
if(!ButtonInteraction.isButton()) return;
|
||||
const queryString = ButtonInteraction.customId;
|
||||
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
||||
|
||||
Reference in new issue
Block a user