Make /export work
This commit is contained in:
parent
c6663e49ee
commit
8d2d351c82
|
@ -5,20 +5,16 @@ const execute = async (interaction, db, client) => {
|
||||||
if (!interaction.isCommand()) return;
|
if (!interaction.isCommand()) return;
|
||||||
await interaction.deferReply({ flags: Discord.MessageFlags.Ephemeral }).catch(console.error);
|
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) {
|
if (row) {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const pad = (n) => n.toString().padStart(2, '0');
|
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`;
|
const filename = `badActors-${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}.json`;
|
||||||
let attachments = [
|
const jsonBuffer = Buffer.from(JSON.stringify(row, null, 2), 'utf8');
|
||||||
{
|
interaction.editReply({
|
||||||
id: Discord.SnowflakeUtil.generate().toString(),
|
files: [{ attachment: jsonBuffer, name: filename }],
|
||||||
name: filename,
|
flags: Discord.MessageFlags.Ephemeral
|
||||||
attachment: Buffer.from(JSON.stringify(row, null, 2), 'utf8')
|
});
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
interaction.editReply({ attachments, flags: Discord.MessageFlags.Ephemeral });
|
|
||||||
} else {
|
} else {
|
||||||
interaction.editReply({ content: "Somehow... the list is empty", ephemeral: true });
|
interaction.editReply({ content: "Somehow... the list is empty", ephemeral: true });
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue