2022-10-21 17:22:01 +00:00
import CommandCategory from "../model/command-category" ;
import * as CommandPermission from '../model/command-permission' ;
2021-12-06 02:56:02 -05:00
2022-10-21 17:22:01 +00:00
import axios from "axios" ;
import { APIMessage , GatewayMessageCreateDispatchData } from "discord-api-types/v10" ;
import { restClient } from "../bot" ;
2021-12-06 02:56:02 -05:00
2022-10-21 17:22:01 +00:00
export default {
aliases : [ 'ticket' ] ,
2021-12-06 02:56:02 -05:00
category : CommandCategory.MODERATION ,
isAllowedForContext : CommandPermission.isMemberModOrHelper ,
2022-10-21 17:22:01 +00:00
process : async ( message : GatewayMessageCreateDispatchData , args : string [ ] ) = > {
if ( message . message_reference == null )
return restClient . createMessage ( message . channel_id , ` <@ ${ message . author . id } >, missing reply ` ) ;
2021-12-06 02:56:02 -05:00
2022-10-21 17:22:01 +00:00
let reply : APIMessage = await restClient . fetchMessage ( message . channel_id , message . message_reference . message_id ! ) ;
2021-12-06 02:56:02 -05:00
let user = null ;
2022-10-21 17:22:01 +00:00
if ( reply . webhook_id != null ) {
2021-12-06 02:56:02 -05:00
let pkmsg = await axios ( ` https://api.pluralkit.me/v2/messages/ ${ reply . id } ` ) ;
user = pkmsg . data . sender ;
} else {
user = reply . author . id ;
}
2022-10-21 17:22:01 +00:00
restClient . deleteMessage ( message . channel_id , message . id ) . catch ( ( ) = > { } ) ;
restClient . createMessage ( message . channel_id , {
2021-12-06 02:56:02 -05:00
content : ` <@ ${ user } >: Please send us a support ticket for your specific issue using this link: <https://apparyllis.atlassian.net/servicedesk/customer/portal/3> \ n `
+ ` You can also click the button below this message. \ n \ n `
+ ` Select the support type that best fits your issue. Make sure to fill out any information that is requested. \ n \ n `
+ ` Once you fill out the ticket, you will receive an email with a confirmation. \ nWhen the developer answers the ticket, you will get another email, `
+ ` so please watch your email (and spam folder) for a reply. ` ,
2022-10-21 17:22:01 +00:00
messageReference : { messageId : reply.id } ,
2021-12-06 02:56:02 -05:00
components : [ { type : 1 , components : [ { type : 2 , style : 5 , label : "Submit ticket" , url : "https://apparyllis.atlassian.net/servicedesk/customer/portals" } ] } ]
2022-10-21 17:22:01 +00:00
} ) ;
2021-12-06 02:56:02 -05:00
}
} ;