Add the ledger
This commit is contained in:
parent
fdbf586284
commit
9866210ecb
|
@ -73,5 +73,10 @@
|
||||||
"required": false
|
"required": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ledger",
|
||||||
|
"description": "Check the balance of every user",
|
||||||
|
"type": 1
|
||||||
}
|
}
|
||||||
]
|
]
|
29
index.js
29
index.js
|
@ -243,6 +243,35 @@ client.on("interactionCreate", async interaction => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
case "ledger": // Allows a user to see the balance of every user in the database
|
||||||
|
db.all(`SELECT * FROM points`, async (err, rows) => {
|
||||||
|
if (err) {
|
||||||
|
console.error(err);
|
||||||
|
return interaction.reply({
|
||||||
|
content: "An error occurred.",
|
||||||
|
ephemeral: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!rows) return interaction.reply({
|
||||||
|
content: "It's quiet here...",
|
||||||
|
ephemeral: true
|
||||||
|
});
|
||||||
|
if (rows) {
|
||||||
|
let ledger = [];
|
||||||
|
for (let i = 0; i < rows.length; i++) {
|
||||||
|
let user = await client.users.fetch(rows[i].id);
|
||||||
|
ledger.push(`${user.username} - ${config.discord.coin}${rows[i].points}`);
|
||||||
|
}
|
||||||
|
interaction.reply({
|
||||||
|
embeds: [{
|
||||||
|
title: "Ledger",
|
||||||
|
description: ledger.join("\n"),
|
||||||
|
color: 0x00ff00
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue