I am trying to pull users and catches from a Sqlite database through Sequelize and display in a message reply a leaderboard ranked by the amount of catches.
My Sequelize Sqlite database looks like this
const Tags = sequelize.define('tags', {
user: {
type: Sequelize.STRING,
unique: true,
},
catches: {
type: Sequelize.INTEGER,
defaultValue: 0,
allowNull: false,
},
I attempted to push the top 10 values in the database into an array and use the leaderboard method suggested by the discord.js guide but it returns an empty message
if (commandName === 'leaderboard') {
let board = Tags.findAll({ limit: 10, attributes: ['user', 'catches']});
lead = []
lead.push(board)
console.log(lead)
await interaction.reply(
codeBlock(
lead.sort((a, b) => b.balance - a.balance)
.filter(user => client.users.cache.has(user.user_id))
.map((user, position) => `(${position + 1}) ${(user.tag)}: ${user.balance}`)
.join("\n"),
),
);