(selectInteraction, rootInteraction, state)
| 1013 | } |
| 1014 | |
| 1015 | async function handleJsonExport(selectInteraction, rootInteraction, state) { |
| 1016 | await selectInteraction.deferUpdate(); |
| 1017 | |
| 1018 | const previewEmbed = buildPreviewEmbed(state); |
| 1019 | const json = JSON.stringify(previewEmbed.toJSON(), null, 2); |
| 1020 | |
| 1021 | if (json.length <= 3980) { |
| 1022 | await selectInteraction.followUp({ |
| 1023 | embeds: [ |
| 1024 | new EmbedBuilder() |
| 1025 | .setTitle('Embed JSON') |
| 1026 | .setDescription(`\`\`\`json\n${json}\n\`\`\``) |
| 1027 | .setColor(getColor('info')), |
| 1028 | ], |
| 1029 | flags: MessageFlags.Ephemeral, |
| 1030 | }); |
| 1031 | } else { |
| 1032 | await selectInteraction.followUp({ |
| 1033 | embeds: [ |
| 1034 | new EmbedBuilder() |
| 1035 | .setTitle('Embed JSON') |
| 1036 | .setDescription('The JSON is too long to display inline — see the attached file.') |
| 1037 | .setColor(getColor('info')), |
| 1038 | ], |
| 1039 | files: [ |
| 1040 | { |
| 1041 | attachment: Buffer.from(json, 'utf-8'), |
| 1042 | name: 'embed.json', |
| 1043 | }, |
| 1044 | ], |
| 1045 | flags: MessageFlags.Ephemeral, |
| 1046 | }); |
| 1047 | } |
| 1048 | } |
| 1049 | |
| 1050 | export default { |
| 1051 | slashOnly: true, |
no test coverage detected