27 lines
1.1 KiB
JavaScript
27 lines
1.1 KiB
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.get("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 });
|
|
} else {
|
|
interaction.editReply({ content: "Somehow... the list is empty", ephemeral: true });
|
|
}
|
|
});
|
|
}
|
|
module.exports = { execute }; |