fie file-sending bugs

This commit is contained in:
kdh8219 2023-04-29 01:08:03 +09:00
parent 5a7658a34f
commit 8014b881e3
3 changed files with 17 additions and 13 deletions

View file

@ -35,22 +35,23 @@ export default {
}); });
let text = ""; let text = "";
blacklist_data.forEach(async (minecraft_uuids, discord_id) => { for (const member of blacklist_data) {
let discord_tag: string; let discord_tag: string;
try { try {
discord_tag = (await interaction.client.users.fetch(discord_id)).tag; discord_tag = (await interaction.client.users.fetch(member[0])).tag;
} catch (e) { } catch (e) {
discord_tag = `Deleted User#0000`; discord_tag = `Deleted User#0000`;
} }
text += discord_tag; text += discord_tag;
text += `(${discord_id})`;
text += " : "; text += " : ";
minecraft_uuids.forEach(async (minecraft_uuid) => { for (const minecraft_uuid of member[1]) {
text += await mojangAPI.getIdFromUUID(minecraft_uuid); text += await mojangAPI.getIdFromUUID(minecraft_uuid);
text += ", "; text += ", ";
}); }
text = text.slice(0, text.length - 2); text = text.slice(0, text.length - 2);
}); }
const buffer_file = { const buffer_file = {
attachment: Buffer.from(text), attachment: Buffer.from(text),

View file

@ -34,10 +34,10 @@ export default {
}); });
let text = ""; let text = "";
member_data.forEach(async (minecraft_uuids, discord_id) => { for (const member of member_data) {
let discord_tag: string; let discord_tag: string;
try { try {
discord_tag = (await interaction.client.users.fetch(discord_id)).tag; discord_tag = (await interaction.client.users.fetch(member[0])).tag;
} catch (e) { } catch (e) {
discord_tag = `Deleted User#0000`; discord_tag = `Deleted User#0000`;
} }
@ -45,12 +45,12 @@ export default {
text += `(${discord_id})`; text += `(${discord_id})`;
text += " : "; text += " : ";
minecraft_uuids.forEach(async (minecraft_uuid) => { for (const minecraft_uuid of member[1]) {
text += await mojangAPI.getIdFromUUID(minecraft_uuid); text += await mojangAPI.getIdFromUUID(minecraft_uuid);
text += ", "; text += ", ";
}); }
text = text.slice(0, text.length - 2); text = text.slice(0, text.length - 2);
}); }
const buffer_file = { const buffer_file = {
attachment: Buffer.from(text), attachment: Buffer.from(text),

View file

@ -50,10 +50,13 @@ export default {
} }
}); });
const file_like = {
blacklist: Object.fromEntries(blacklist_data),
members: Object.fromEntries(member_data),
};
const buffer_file = { const buffer_file = {
attachment: Buffer.from( attachment: Buffer.from(JSON.stringify(file_like)),
JSON.stringify({ blacklist: blacklist_data, members: member_data })
),
name: "raw_file.txt", name: "raw_file.txt",
}; };
await interaction.editReply({ files: [buffer_file] }); await interaction.editReply({ files: [buffer_file] });