🚑 top command was sorting "top 10 documents"

This commit is contained in:
Axel Olausson Holtenäs 2022-03-03 20:52:38 +01:00
parent 9910b2577a
commit 0fb3aa168a
No known key found for this signature in database
GPG key ID: E3AE7E194AE017ED

View file

@ -1,13 +1,13 @@
const credits = require('../../../helpers/database/models/creditSchema');
const debug = require('../../../handlers/debug');
module.exports = async (interaction) => {
credits.find().then(async (data) => {
const topTen = data.slice(0, 10);
const sorted = topTen.sort((a, b) => (a.balance > b.balance ? -1 : 1));
await credits.find().then(async (data) => {
const sorted = data.sort((a, b) => (a.balance > b.balance ? -1 : 1));
const topTen = sorted.slice(0, 10);
const embed = {
title: 'Balance Top',
description: `Below are the top ten.\n${sorted
description: `Below are the top ten.\n${topTen
.map(
(x, index) =>
`**Top ${index + 1}** - <@${x.userId}> ${