Reputation: 11
I want a leaderboard of users on my server but here is error in db.startsWith :(( maybe in a new version quick.db ?
const Discord = require("discord.js");
const db = require("quick.db");
module.exports.run = async (bot, message, args) => {
let money = db.startsWith(`money_${message.guild.id}`, { sort: '.data'})
let content = "";
for (let i = 0; i < money.length; i++) {
let user = bot.users.get(money[i].ID.split('_')[2]).username
content += `${i+1}. ${user} ~ ${money[i].data} монет\n`
}
const embed = new Discord.MessageEmbed()
.setAuthor(`${message.guild.name} - Leaderboard`, message.guild.iconURL)
.setDescription(content)
.setColor("RANDOM")
message.channel.send(embed)
}
Upvotes: 1
Views: 2670
Reputation: 396
By exploring the quick.db
package with unpkg.com, I have found that the startsWith
function - along with some other deprecated functions - was removed in version 7.0.0-b22
. This is supported by information in an answer from support.glitch.com:
When I do a
console.log(db)
afterrequire
ing that package, I get a version of7.0.0b22
and indeed it seems like that version doesn’t export a startsWith function, while7.0.0b21
does. If you remove the “^” from the beginning of thequick.db
version specifier I think your current code will work, but it seems as though that function is being deprecated and I’d probably find a different solution to that instead.
and the official documentation.
Looking at said documentation, I can find no workaround other than to get all entries in the database via the all
method and manually filter the returned array to the entries that you want. As the documentation does not tell the structure of the array returned from all
, I cannot help you with that—perhaps some experimentation of your own may reveal the structure to you?
Upvotes: 1