Make /export work

This commit is contained in:
Christopher Cookman 2025-06-21 06:15:55 -06:00
parent c6663e49ee
commit 8d2d351c82

View file

@ -5,20 +5,16 @@ const execute = async (interaction, db, client) => {
if (!interaction.isCommand()) return;
await interaction.deferReply({ flags: Discord.MessageFlags.Ephemeral }).catch(console.error);
db.get("SELECT * FROM badActors", async (err, row) => {
db.all("SELECT * FROM badActors", async (err, row) => {
if (row) {
const now = new Date();
const pad = (n) => n.toString().padStart(2, '0');
const filename = `badActors-${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}-utc${pad(now.getUTCHours())}-${pad(now.getUTCMinutes())}.json`;
let attachments = [
{
id: Discord.SnowflakeUtil.generate().toString(),
name: filename,
attachment: Buffer.from(JSON.stringify(row, null, 2), 'utf8')
}
];
interaction.editReply({ attachments, flags: Discord.MessageFlags.Ephemeral });
const filename = `badActors-${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}.json`;
const jsonBuffer = Buffer.from(JSON.stringify(row, null, 2), 'utf8');
interaction.editReply({
files: [{ attachment: jsonBuffer, name: filename }],
flags: Discord.MessageFlags.Ephemeral
});
} else {
interaction.editReply({ content: "Somehow... the list is empty", ephemeral: true });
}