From 8014b881e31f9f33ad2336e619d2f9273c79d733 Mon Sep 17 00:00:00 2001 From: kdh8219 <65698239+kdh8219@users.noreply.github.com> Date: Sat, 29 Apr 2023 01:08:03 +0900 Subject: [PATCH] fie file-sending bugs --- src/command/commands/get_blacklist.ts | 11 ++++++----- src/command/commands/get_members.ts | 10 +++++----- src/command/commands/get_raw_file.ts | 9 ++++++--- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/command/commands/get_blacklist.ts b/src/command/commands/get_blacklist.ts index 8e33403..6aa09b8 100755 --- a/src/command/commands/get_blacklist.ts +++ b/src/command/commands/get_blacklist.ts @@ -35,22 +35,23 @@ export default { }); let text = ""; - blacklist_data.forEach(async (minecraft_uuids, discord_id) => { + for (const member of blacklist_data) { let discord_tag: string; try { - discord_tag = (await interaction.client.users.fetch(discord_id)).tag; + discord_tag = (await interaction.client.users.fetch(member[0])).tag; } catch (e) { discord_tag = `Deleted User#0000`; } text += discord_tag; + text += `(${discord_id})`; text += " : "; - minecraft_uuids.forEach(async (minecraft_uuid) => { + for (const minecraft_uuid of member[1]) { text += await mojangAPI.getIdFromUUID(minecraft_uuid); text += ", "; - }); + } text = text.slice(0, text.length - 2); - }); + } const buffer_file = { attachment: Buffer.from(text), diff --git a/src/command/commands/get_members.ts b/src/command/commands/get_members.ts index a5a8b72..ab3790b 100755 --- a/src/command/commands/get_members.ts +++ b/src/command/commands/get_members.ts @@ -34,10 +34,10 @@ export default { }); let text = ""; - member_data.forEach(async (minecraft_uuids, discord_id) => { + for (const member of member_data) { let discord_tag: string; try { - discord_tag = (await interaction.client.users.fetch(discord_id)).tag; + discord_tag = (await interaction.client.users.fetch(member[0])).tag; } catch (e) { discord_tag = `Deleted User#0000`; } @@ -45,12 +45,12 @@ export default { text += `(${discord_id})`; text += " : "; - minecraft_uuids.forEach(async (minecraft_uuid) => { + for (const minecraft_uuid of member[1]) { text += await mojangAPI.getIdFromUUID(minecraft_uuid); text += ", "; - }); + } text = text.slice(0, text.length - 2); - }); + } const buffer_file = { attachment: Buffer.from(text), diff --git a/src/command/commands/get_raw_file.ts b/src/command/commands/get_raw_file.ts index 1c7b96c..0157d91 100755 --- a/src/command/commands/get_raw_file.ts +++ b/src/command/commands/get_raw_file.ts @@ -50,10 +50,13 @@ export default { } }); + const file_like = { + blacklist: Object.fromEntries(blacklist_data), + members: Object.fromEntries(member_data), + }; + const buffer_file = { - attachment: Buffer.from( - JSON.stringify({ blacklist: blacklist_data, members: member_data }) - ), + attachment: Buffer.from(JSON.stringify(file_like)), name: "raw_file.txt", }; await interaction.editReply({ files: [buffer_file] });