I'm trying to make a clearinventory command so it deletes a players inventory via mention or if there is no mention it deletes your own inventory but I keep getting an error called RangeError: Too many parameter values were provided this is the code :
const db = require('quick.db');
const Discord = require('discord.js');
module.exports = {
name: "clearinventory",
descrition: "clear a players inventory",
async run(client, message, run) {
let target = message.mentions.users.first() || message.author;
let items = await db.fetch(target.id, {
items: []
});
if (!message.member.hasPermission("ADMINISTRATOR")) return message.channel.send('You can\'t use that!')
db.delete(items);
message.channel.send(`${target}\'s inventory was successfully cleared!`)
}
}
I've tried to specify the items in the variable items and I also tried to specify items in the db.delete(items, 'car')
but that didn't work
I'm looking at this without any context on which line is causing the issue.
db.delete
takes a string for the first parameter, this string being the key of the data you set (the target's user ID). In this case, you're passingitems
which is actually an object with the format{ items: [/* items */] }
and not a string. I assume you're trying to delete the items of a player's inventory, and in that case you can do either of the two:items
to an empty array. This takes advantage of quick.db's ability to use the dot notation.