import { AllowedMentions , Embed } from 'slash-commands/dist/src/structures' ; import { apiPrefix } from '..' ; type _Message = { content ? : string ; tts ? : boolean ; embeds ? : Embed [ ] ; allowed_mentions ? : AllowedMentions ; } ; type _EmbedMessage = _Message & { embeds : Embed [ ] ; } ; type _TextMessage = _Message & { content : string ; } ; type Message = _TextMessage | _EmbedMessage ; export async function createOriginal ( req , msg ) { if ( ! req . context . haveResponded ) { req . context . haveResponded = true ; req . context . originalResp ( msg ) ; } else if ( 'data' in msg && msg . data ) { await fetch ( `${ apiPrefix [ req . from ] }/${ req . application_id }/${ req . token }/messages/@original` , { method : 'PATCH' , headers : { 'Content-Type' : 'application/json' , } , body : JSON . stringify ( { content : msg . data . content , embeds : msg . data . embeds , allowed_mentions : msg . data . allowedMentions , } ) , } ) ; } } type FollowupID = string ; export async function followup ( req , msg ) { const blah = await fetch ( `${ apiPrefix [ req . from ] }/${ req . application_id }/${ req . token }` , { method : 'POST' , headers : { 'Content-Type' : 'application/json' , } , body : JSON . stringify ( msg ) , } ) ; return ( await blah . json ( ) ) . id ; } export async function editFollowup ( req , id , msg ) { await fetch ( `${ apiPrefix [ req . from ] }/${ req . application_id }/${ req . token }/messages/${ id }` , { method : 'PATCH' , headers : { 'Content-Type' : 'application/json' , } , body : JSON . stringify ( msg ) , } ) ; } export async function deleteFollowup ( req , id ) { await fetch ( `${ apiPrefix [ req . from ] }/${ req . application_id }/${ req . token }/messages/${ id }` , { method : 'DELETE' , } ) ; }