@@ -30,10 +30,10 @@ const { version } = require("../package.json");
30
30
require ( "dotenv" ) . config ( ) ;
31
31
32
32
// discord bot tokens
33
- const {
34
- DISCORD_BOT_TOKEN ,
35
- DISCORD_SUPPORT_ROLE_ID ,
36
- CONTEXT_ID ,
33
+ const {
34
+ DISCORD_BOT_TOKEN ,
35
+ DISCORD_SUPPORT_ROLE_ID ,
36
+ CONTEXT_ID ,
37
37
ASKAI_CHANNEL } = process . env ;
38
38
39
39
const token = DISCORD_BOT_TOKEN ;
@@ -107,7 +107,7 @@ client.on("messageCreate", async (message) => {
107
107
} ,
108
108
onError : async ( error ) => {
109
109
console . error ( error ) ;
110
-
110
+
111
111
// send a message indicates unseccesful response from the AI
112
112
await message . channel . messages . fetch ( aiMessageLoading . id ) . then ( ( msg ) =>
113
113
msg . edit ( {
@@ -575,7 +575,9 @@ client.on("messageCreate", async (message) => {
575
575
if ( mentioned . roles . cache . hasAny ( ...roleIDs ) && ! member . roles . cache . hasAny ( ...roleIDs ) ) {
576
576
message . reply ( {
577
577
embeds : [ sendEmbedMessage ( `We have moved to a community driven discord support model.\n\nYou can ask me all things thirdweb in the <#${ ASKAI_CHANNEL } > channel. Use the command \`!askai\` or \`!ask\` followed by your question to get started.` ) ] ,
578
- } ) ;
578
+ } ) . then ( msg => {
579
+ setTimeout ( ( ) => msg . delete ( ) , 60000 )
580
+ } )
579
581
}
580
582
}
581
583
@@ -642,10 +644,10 @@ client.on("threadCreate", async (post) => {
642
644
) ;
643
645
644
646
// send message upon creating of new ticket
645
- post . send ( {
646
- embeds : [ sendEmbedMessage ( config . reminder_newpost ) ] ,
647
- components : [ CloseButtonComponent ( ) ] ,
648
- } ) ;
647
+ // post.send({
648
+ // embeds: [sendEmbedMessage(config.reminder_newpost)],
649
+ // components: [CloseButtonComponent()],
650
+ // });
649
651
650
652
// log any new posts
651
653
console . log (
@@ -662,7 +664,7 @@ client.on("threadCreate", async (post) => {
662
664
botId : CONTEXT_ID ,
663
665
query : question ,
664
666
onComplete : async ( query ) => {
665
-
667
+
666
668
await post . messages . fetch ( aiMessageLoading . id ) . then ( ( msg ) =>
667
669
msg . edit ( {
668
670
content : "" ,
@@ -672,7 +674,7 @@ client.on("threadCreate", async (post) => {
672
674
components : [ FeedbackButtonComponent ( ) ] ,
673
675
} )
674
676
) ;
675
-
677
+
676
678
} ,
677
679
onError : ( error ) => {
678
680
console . error ( error ) ;
@@ -692,8 +694,20 @@ client.on("interactionCreate", async (interaction) => {
692
694
const closeTag = post . availableTags . filter ( ( item ) => {
693
695
return item . name == config . tag_name_close ;
694
696
} ) ;
697
+ const resolutionTag = post . availableTags . filter ( ( item ) => {
698
+ return item . name == config . tag_name_resolve ;
699
+ } ) ;
700
+ const escalateTag = post . availableTags . filter ( ( item ) => {
701
+ return item . name == config . tag_name_escalate ;
702
+ } ) ;
695
703
let initialTags = [ closeTag [ 0 ] . id , ...postTags ] ;
696
704
let tags = [ ...new Set ( initialTags ) ] ;
705
+ let initialTagsResolution = [ resolutionTag [ 0 ] . id , ...postTags ] . filter (
706
+ ( item ) => {
707
+ return item != escalateTag [ 0 ] . id ;
708
+ }
709
+ ) ;
710
+ let tagsResolution = [ ...new Set ( initialTagsResolution ) ] ;
697
711
const question = post . name ;
698
712
if ( interaction . channel . ownerId != interaction . user . id ) return ;
699
713
if ( interaction . customId === "close" ) {
@@ -733,6 +747,28 @@ client.on("interactionCreate", async (interaction) => {
733
747
ephemeral : true ,
734
748
} ) ;
735
749
await interaction . message . edit ( { components : [ ] } ) ;
750
+
751
+ // send embed message upon executing the resolve command
752
+ await interaction . channel . send ( {
753
+ embeds : [ sendEmbedMessage ( `${ config . reminder_resolve } ` ) ] ,
754
+ content : `🔔 <@${ interaction . channel . ownerId } >` ,
755
+ } ) ;
756
+
757
+ // then archive / close it
758
+ await interaction . channel . edit ( {
759
+ appliedTags : tagsResolution ,
760
+ archived : false ,
761
+ } ) ;
762
+ sendData (
763
+ {
764
+ post_id : interaction . channel . id ,
765
+ resolution_time : statusTime ,
766
+ resolved_by : "Thirdweb Assistant" ,
767
+ } ,
768
+ config . datasheet_resolve
769
+ ) ;
770
+
771
+
736
772
} else if ( interaction . customId === "not-helpful" ) {
737
773
sendData (
738
774
{
@@ -742,11 +778,13 @@ client.on("interactionCreate", async (interaction) => {
742
778
config . datasheet_feedback
743
779
) ;
744
780
await interaction . reply ( {
745
- embeds : [ sendEmbedMessage ( `Thank you so much for your feedback! ` ) ] ,
781
+ embeds : [ sendEmbedMessage ( `Thank you for your valuable feedback, this will help us improve the responses of our AI assistant.\n\nIn the meantime, would you like to contact a human customer success agent? Just click the link or the button below to submit a ticket. ` ) ] ,
746
782
content : `🔔 <@${ interaction . channel . ownerId } >` ,
747
783
ephemeral : true ,
784
+ components : [ CloseButtonComponent ( ) ] ,
748
785
} ) ;
749
786
await interaction . message . edit ( { components : [ ] } ) ;
787
+
750
788
}
751
789
}
752
790
} ) ;
0 commit comments