MCPcopy Create free account
hub / github.com/codebymitch/TitanBot / handleJsonExport

Function handleJsonExport

src/commands/Tools/embedbuilder.js:1015–1048  ·  view source on GitHub ↗
(selectInteraction, rootInteraction, state)

Source from the content-addressed store, hash-verified

1013}
1014
1015async 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
1050export default {
1051 slashOnly: true,

Callers 1

executeFunction · 0.85

Calls 3

getColorFunction · 0.90
buildPreviewEmbedFunction · 0.85
followUpMethod · 0.80

Tested by

no test coverage detected