1+ import {
2+ ActionRowBuilder ,
3+ ChannelSelectMenuBuilder ,
4+ ChannelType , ContainerBuilder ,
5+ EmbedBuilder , LabelBuilder ,
6+ MessageFlags , ModalBuilder ,
7+ ModalSubmitInteraction , StringSelectMenuBuilder , TextChannel , TextDisplayBuilder , TextInputBuilder , TextInputStyle
8+ } from "discord.js" ;
9+ import { ExtendedClient } from "../../../types/ExtendedClient.js" ;
10+ import { convertToEmojiToPng } from "../../../helper/emojis.js" ;
11+ import { database } from "../../../main/database.js" ;
12+ import { randomUUID } from "crypto" ;
13+ import { showComponentFollowModal , updateComponentsWithPositions } from "../../../helper/messageHelper.js" ;
14+ import { Channel } from "diagnostics_channel" ;
15+
16+ export default {
17+ id : "component-editor-create-import-modal" ,
18+
19+ /**
20+ *
21+ * @param {ModalSubmitInteraction } interaction
22+ * @param {ExtendedClient } client
23+ */
24+
25+ async execute ( interaction : ModalSubmitInteraction , client : ExtendedClient ) {
26+ const messageId = interaction . customId . split ( ":" ) [ 1 ]
27+
28+ const message = await ( interaction . channel as TextChannel ) . messages . fetch ( messageId )
29+
30+
31+ const data = interaction . fields . getUploadedFiles ( "file" )
32+ const url = data . first ( ) . url
33+ const blob = await fetch ( url )
34+ const json = await blob . blob ( )
35+ const buffer = Buffer . from ( await json . arrayBuffer ( ) )
36+ console . log ( buffer . toString ( "utf-8" ) )
37+
38+ await updateComponentsWithPositions (
39+ message ,
40+ JSON . parse ( buffer . toString ( "utf-8" ) ) ,
41+ null ,
42+ )
43+
44+ await interaction . deferUpdate ( )
45+ }
46+ }
0 commit comments