fix attachment looking in fs instead of sending buffer

This commit is contained in:
Matthieu Jolimaitre 2024-08-13 19:58:33 +02:00
parent cbfed03f66
commit d0aa721b81

View file

@ -19,6 +19,7 @@ import {
import { RuleSet } from "./rules.ts"; import { RuleSet } from "./rules.ts";
import { channel, log_from, SimpleResult, split_promise, try_ } from "./utils.ts"; import { channel, log_from, SimpleResult, split_promise, try_ } from "./utils.ts";
import { StoredUser } from "./state.ts"; import { StoredUser } from "./state.ts";
import { Buffer } from "node:buffer";
const log = log_from(import.meta.url); const log = log_from(import.meta.url);
/** /**
@ -376,7 +377,9 @@ function message_command_response_export_success(count: number, csv: string) {
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
.setTitle("`✅`| Export") .setTitle("`✅`| Export")
.setDescription(`\`${count}\` associations exportées.`); .setDescription(`\`${count}\` associations exportées.`);
const attachment = new AttachmentBuilder(csv).setName(`export-${Date.now()}.csv`); const buffer = Buffer.from(csv);
const attachment = new AttachmentBuilder(buffer)
.setName(`export-${Date.now()}.csv`);
return { embeds: [embed], files: [attachment] }; return { embeds: [embed], files: [attachment] };
} }