23 lines
978 B
JavaScript
23 lines
978 B
JavaScript
const Discord = require('discord.js');
|
|
const path = require('path');
|
|
|
|
const execute = async (interaction, db, client) => {
|
|
if (!interaction.isCommand()) return;
|
|
await interaction.deferReply({ flags: Discord.MessageFlags.Ephemeral }).catch(console.error);
|
|
|
|
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()}.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 });
|
|
}
|
|
});
|
|
}
|
|
module.exports = { execute }; |