reset cmd/improve money cmd/fix settings cmd options
This commit is contained in:
5 files changed
+176
-102
No files matched your search
@@ -540,7 +540,7 @@ module.exports = {
|
|||||||
|
|
||||||
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||||
|
|
||||||
client.on("interactionCreate", ButtonInteraction => {
|
client.once("interactionCreate", ButtonInteraction => {
|
||||||
if(!ButtonInteraction.isButton()) return;
|
if(!ButtonInteraction.isButton()) return;
|
||||||
const queryString = ButtonInteraction.customId;
|
const queryString = ButtonInteraction.customId;
|
||||||
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
||||||
|
|||||||
+16
-61
@@ -12,17 +12,14 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: "add",
|
name: "add_or_remove",
|
||||||
description: "Add money to user",
|
description: "Add or remove money from a user",
|
||||||
value: "add",
|
value: "add_or_remove",
|
||||||
type: 1,
|
type: 3,
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: "user",
|
|
||||||
description: "User to give money",
|
|
||||||
value: "user",
|
|
||||||
type: 6,
|
|
||||||
required: true,
|
required: true,
|
||||||
|
choices: [
|
||||||
|
{ name: "add", value: "add" }, { name: "remove", value: "remove" },
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "amount",
|
name: "amount",
|
||||||
@@ -31,32 +28,14 @@ module.exports = {
|
|||||||
type: 5,
|
type: 5,
|
||||||
min_value: 0.01,
|
min_value: 0.01,
|
||||||
required: true,
|
required: true,
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "remove",
|
name: "from",
|
||||||
description: "Remove money from user",
|
description: "User to alter balance",
|
||||||
value: "remove",
|
value: "from",
|
||||||
type: 1,
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: "user",
|
|
||||||
description: "User to remove money from",
|
|
||||||
value: "user",
|
|
||||||
type: 6,
|
type: 6,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "amount",
|
|
||||||
description: "The amount to add to balance",
|
|
||||||
value: "amount",
|
|
||||||
type: 5,
|
|
||||||
min_value: 0.01,
|
|
||||||
required: true,
|
|
||||||
}
|
|
||||||
],
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
SlashCommand: {
|
SlashCommand: {
|
||||||
/**
|
/**
|
||||||
@@ -78,7 +57,7 @@ module.exports = {
|
|||||||
if (client.exists(GuildDB.botAdmin) && interaction.member.roles.includes(GuildDB.botAdmin)) 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.');
|
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);
|
let banking = await client.dbo.collection("banks").findOne({"account.userID": targetUserID}).then(banking => banking);
|
||||||
|
|
||||||
if (!banking) {
|
if (!banking) {
|
||||||
@@ -123,10 +102,9 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].name == "add") {
|
const newBalance = args[0] == 'add'
|
||||||
// add money to user
|
? banking.guilds[GuildDB.serverID].account.balance + args[1].value
|
||||||
|
: banking.guilds[GuildDB.serverID].account.balance - args[1].value;
|
||||||
let newBalance = banking.guilds[GuildDB.serverID].account.balance + args[0].options[1].value;
|
|
||||||
|
|
||||||
client.dbo.collection("banks").updateOne({"account.userID":targetUserID},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance}}, function(err, res) {
|
client.dbo.collection("banks").updateOne({"account.userID":targetUserID},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance}}, function(err, res) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -139,34 +117,11 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const successEmbed = new EmbedBuilder()
|
||||||
let 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`)
|
||||||
.setDescription(`Successfully added $${args[0].options[1].value.toFixed(2)} to <@${targetUserID}>'s balance`)
|
|
||||||
.setColor('GREEN');
|
.setColor('GREEN');
|
||||||
|
|
||||||
return interaction.send({ embeds: [successEmbed] });
|
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;
|
|
||||||
|
|
||||||
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');
|
|
||||||
|
|
||||||
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) });
|
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||||
|
|
||||||
client.on("interactionCreate", ButtonInteraction => {
|
client.once("interactionCreate", ButtonInteraction => {
|
||||||
if(!ButtonInteraction.isButton()) return;
|
if(!ButtonInteraction.isButton()) return;
|
||||||
const queryString = ButtonInteraction.customId;
|
const queryString = ButtonInteraction.customId;
|
||||||
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
||||||
@@ -491,7 +491,7 @@ module.exports = {
|
|||||||
|
|
||||||
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||||
|
|
||||||
client.on("interactionCreate", ButtonInteraction => {
|
client.once("interactionCreate", ButtonInteraction => {
|
||||||
if(!ButtonInteraction.isButton()) return;
|
if(!ButtonInteraction.isButton()) return;
|
||||||
const queryString = ButtonInteraction.customId;
|
const queryString = ButtonInteraction.customId;
|
||||||
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
||||||
@@ -569,7 +569,7 @@ module.exports = {
|
|||||||
|
|
||||||
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||||
|
|
||||||
client.on("interactionCreate", ButtonInteraction => {
|
client.once("interactionCreate", ButtonInteraction => {
|
||||||
if(!ButtonInteraction.isButton()) return;
|
if(!ButtonInteraction.isButton()) return;
|
||||||
const queryString = ButtonInteraction.customId;
|
const queryString = ButtonInteraction.customId;
|
||||||
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
||||||
@@ -647,7 +647,7 @@ module.exports = {
|
|||||||
|
|
||||||
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||||
|
|
||||||
client.on("interactionCreate", ButtonInteraction => {
|
client.once("interactionCreate", ButtonInteraction => {
|
||||||
if(!ButtonInteraction.isButton()) return;
|
if(!ButtonInteraction.isButton()) return;
|
||||||
const queryString = ButtonInteraction.customId;
|
const queryString = ButtonInteraction.customId;
|
||||||
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
||||||
@@ -726,7 +726,7 @@ module.exports = {
|
|||||||
|
|
||||||
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||||
|
|
||||||
client.on("interactionCreate", ButtonInteraction => {
|
client.once("interactionCreate", ButtonInteraction => {
|
||||||
if(!ButtonInteraction.isButton()) return;
|
if(!ButtonInteraction.isButton()) return;
|
||||||
const queryString = ButtonInteraction.customId;
|
const queryString = ButtonInteraction.customId;
|
||||||
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
||||||
@@ -854,7 +854,7 @@ module.exports = {
|
|||||||
|
|
||||||
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||||
|
|
||||||
client.on("interactionCreate", ButtonInteraction => {
|
client.once("interactionCreate", ButtonInteraction => {
|
||||||
if(!ButtonInteraction.isButton()) return;
|
if(!ButtonInteraction.isButton()) return;
|
||||||
const queryString = ButtonInteraction.customId;
|
const queryString = ButtonInteraction.customId;
|
||||||
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
||||||
@@ -928,7 +928,7 @@ module.exports = {
|
|||||||
|
|
||||||
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||||
|
|
||||||
client.on("interactionCreate", ButtonInteraction => {
|
client.once("interactionCreate", ButtonInteraction => {
|
||||||
if(!ButtonInteraction.isButton()) return;
|
if(!ButtonInteraction.isButton()) return;
|
||||||
const queryString = ButtonInteraction.customId;
|
const queryString = ButtonInteraction.customId;
|
||||||
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
||||||
@@ -1002,7 +1002,7 @@ module.exports = {
|
|||||||
|
|
||||||
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||||
|
|
||||||
client.on("interactionCreate", ButtonInteraction => {
|
client.once("interactionCreate", ButtonInteraction => {
|
||||||
if(!ButtonInteraction.isButton()) return;
|
if(!ButtonInteraction.isButton()) return;
|
||||||
const queryString = ButtonInteraction.customId;
|
const queryString = ButtonInteraction.customId;
|
||||||
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
||||||
@@ -1076,7 +1076,7 @@ module.exports = {
|
|||||||
|
|
||||||
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||||
|
|
||||||
client.on("interactionCreate", ButtonInteraction => {
|
client.once("interactionCreate", ButtonInteraction => {
|
||||||
if(!ButtonInteraction.isButton()) return;
|
if(!ButtonInteraction.isButton()) return;
|
||||||
const queryString = ButtonInteraction.customId;
|
const queryString = ButtonInteraction.customId;
|
||||||
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
||||||
@@ -1150,7 +1150,7 @@ module.exports = {
|
|||||||
|
|
||||||
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||||
|
|
||||||
client.on("interactionCreate", ButtonInteraction => {
|
client.once("interactionCreate", ButtonInteraction => {
|
||||||
if(!ButtonInteraction.isButton()) return;
|
if(!ButtonInteraction.isButton()) return;
|
||||||
const queryString = ButtonInteraction.customId;
|
const queryString = ButtonInteraction.customId;
|
||||||
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
|
||||||
|
|||||||
+24
-30
@@ -1,5 +1,21 @@
|
|||||||
const mongoose = require('mongoose');
|
const mongoose = require('mongoose');
|
||||||
|
|
||||||
|
const defaultGuildData = {
|
||||||
|
items: [{
|
||||||
|
name: 'Wallet',
|
||||||
|
type: 'wallet',
|
||||||
|
description: '`/wallet view` to view wallet',
|
||||||
|
cash: 0.00,
|
||||||
|
ID: {
|
||||||
|
firstname: '',
|
||||||
|
lastname: '',
|
||||||
|
dob: '',
|
||||||
|
addr: '',
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
lastWork: new Date('2000-01-01T00:00:00') // garantee's they can work right after inventory create,
|
||||||
|
}
|
||||||
|
|
||||||
let inventorySchema = mongoose.Schema({
|
let inventorySchema = mongoose.Schema({
|
||||||
inventory: {
|
inventory: {
|
||||||
userID: String,
|
userID: String,
|
||||||
@@ -9,45 +25,23 @@ let inventorySchema = mongoose.Schema({
|
|||||||
|
|
||||||
inventorySchema.methods.createInventory = function (userID, guildID) {
|
inventorySchema.methods.createInventory = function (userID, guildID) {
|
||||||
this.inventory.userID = userID;
|
this.inventory.userID = userID;
|
||||||
const newGuild = {
|
|
||||||
items: [{
|
|
||||||
name: 'Wallet',
|
|
||||||
type: 'wallet',
|
|
||||||
description: '`/wallet view` to view wallet',
|
|
||||||
cash: 0.00,
|
|
||||||
ID: {
|
|
||||||
firstname: '',
|
|
||||||
lastname: '',
|
|
||||||
dob: ''
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
lastWork: new Date('2000-01-01T00:00:00') // garantee's they can work right after inventory create,
|
|
||||||
};
|
|
||||||
this.inventory.guilds = {};
|
this.inventory.guilds = {};
|
||||||
this.inventory.guilds[guildID] = newGuild
|
this.inventory.guilds[guildID] = defaultGuildData;
|
||||||
};
|
};
|
||||||
|
|
||||||
inventorySchema.methods.addItem = function (guildID, item) {
|
inventorySchema.methods.addItem = function (guildID, item) {
|
||||||
this.inventory.guilds[guildID].items.push(item);
|
this.inventory.guilds[guildID].items.push(item);
|
||||||
};
|
};
|
||||||
|
|
||||||
// This function is to add a new guild specific inventory to an already existing
|
/*
|
||||||
// inventory document
|
This function is to add a new guild specific inventory to an already existing
|
||||||
|
inventory document
|
||||||
|
or
|
||||||
|
can be used to reset a data back to default
|
||||||
|
*/
|
||||||
function addInventory(guilds, guildID, userID, client) {
|
function addInventory(guilds, guildID, userID, client) {
|
||||||
let updatedGuilds = guilds;
|
let updatedGuilds = guilds;
|
||||||
updatedGuilds[guildID] = {
|
updatedGuilds[guildID] = defaultGuildData;
|
||||||
items: [{
|
|
||||||
name: 'Wallet',
|
|
||||||
type: 'wallet',
|
|
||||||
description: '`/wallet view` to view wallet',
|
|
||||||
cash: 0.00,
|
|
||||||
ID: {
|
|
||||||
firstname: '',
|
|
||||||
lastname: '',
|
|
||||||
dob: ''
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
}
|
|
||||||
|
|
||||||
client.dbo.collection("inventories").updateOne({"inventory.userID":userID}, {$set: {"inventory.guilds": updatedGuilds}}, function(err, res) {
|
client.dbo.collection("inventories").updateOne({"inventory.userID":userID}, {$set: {"inventory.guilds": updatedGuilds}}, function(err, res) {
|
||||||
if (err) return false
|
if (err) return false
|
||||||
|
|||||||
Reference in new issue
Block a user