Skip to content

Commit 80a55a8

Browse files
authored
🚀release: v2.0.12
Merge pull request #94 from thirdweb-dev/v2
2 parents fb27be4 + 25d58f9 commit 80a55a8

File tree

3 files changed

+54
-22
lines changed

3 files changed

+54
-22
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "thirdweb-support-discord-bot",
3-
"version": "2.0.11",
3+
"version": "2.0.12",
44
"description": "A self-hosted dedicated forum-based support Discord bot for the thirdweb community.",
55
"main": "src/bot.ts",
66
"author": "Waren Gonzaga",

src/bot.js

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ const { version } = require("../package.json");
3030
require("dotenv").config();
3131

3232
// 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,
3737
ASKAI_CHANNEL } = process.env;
3838

3939
const token = DISCORD_BOT_TOKEN;
@@ -107,7 +107,7 @@ client.on("messageCreate", async (message) => {
107107
},
108108
onError: async (error) => {
109109
console.error(error);
110-
110+
111111
// send a message indicates unseccesful response from the AI
112112
await message.channel.messages.fetch(aiMessageLoading.id).then((msg) =>
113113
msg.edit({
@@ -575,7 +575,9 @@ client.on("messageCreate", async (message) => {
575575
if (mentioned.roles.cache.hasAny(...roleIDs) && !member.roles.cache.hasAny(...roleIDs)) {
576576
message.reply({
577577
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+
})
579581
}
580582
}
581583

@@ -642,10 +644,10 @@ client.on("threadCreate", async (post) => {
642644
);
643645

644646
// 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+
// });
649651

650652
// log any new posts
651653
console.log(
@@ -662,7 +664,7 @@ client.on("threadCreate", async (post) => {
662664
botId: CONTEXT_ID,
663665
query: question,
664666
onComplete: async (query) => {
665-
667+
666668
await post.messages.fetch(aiMessageLoading.id).then((msg) =>
667669
msg.edit({
668670
content: "",
@@ -672,7 +674,7 @@ client.on("threadCreate", async (post) => {
672674
components: [FeedbackButtonComponent()],
673675
})
674676
);
675-
677+
676678
},
677679
onError: (error) => {
678680
console.error(error);
@@ -692,8 +694,20 @@ client.on("interactionCreate", async (interaction) => {
692694
const closeTag = post.availableTags.filter((item) => {
693695
return item.name == config.tag_name_close;
694696
});
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+
});
695703
let initialTags = [closeTag[0].id, ...postTags];
696704
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)];
697711
const question = post.name;
698712
if (interaction.channel.ownerId != interaction.user.id) return;
699713
if (interaction.customId === "close") {
@@ -733,6 +747,28 @@ client.on("interactionCreate", async (interaction) => {
733747
ephemeral: true,
734748
});
735749
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+
736772
} else if (interaction.customId === "not-helpful") {
737773
sendData(
738774
{
@@ -742,11 +778,13 @@ client.on("interactionCreate", async (interaction) => {
742778
config.datasheet_feedback
743779
);
744780
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.`)],
746782
content: `🔔 <@${interaction.channel.ownerId}>`,
747783
ephemeral: true,
784+
components: [CloseButtonComponent()],
748785
});
749786
await interaction.message.edit({ components: [] });
787+
750788
}
751789
}
752790
});

src/utils/core.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,15 @@ const sendEmbedMessage = (message) => {
2424
* @param {string} message
2525
* @returns pre-defined embed style
2626
*/
27-
const CloseButtonComponent = () => {
28-
const close = new ButtonBuilder()
29-
.setCustomId('close')
30-
.setLabel('Close')
31-
.setEmoji('⚒️')
32-
.setStyle(ButtonStyle.Danger);
33-
27+
const CloseButtonComponent = () => {
3428
const support = new ButtonBuilder()
3529
.setLabel('Submit a Ticket')
3630
.setEmoji('💬')
3731
.setURL('https://thirdweb.com/support')
3832
.setStyle(ButtonStyle.Link);
3933

4034
const row = new ActionRowBuilder()
41-
.addComponents(close, support);
35+
.addComponents(support);
4236
return row
4337
}
4438

0 commit comments

Comments
 (0)