Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀release: v2.0.12 #94

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "thirdweb-support-discord-bot",
"version": "2.0.11",
"version": "2.0.12",
"description": "A self-hosted dedicated forum-based support Discord bot for the thirdweb community.",
"main": "src/bot.ts",
"author": "Waren Gonzaga",
Expand Down
64 changes: 51 additions & 13 deletions src/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ const { version } = require("../package.json");
require("dotenv").config();

// discord bot tokens
const {
DISCORD_BOT_TOKEN,
DISCORD_SUPPORT_ROLE_ID,
CONTEXT_ID,
const {
DISCORD_BOT_TOKEN,
DISCORD_SUPPORT_ROLE_ID,
CONTEXT_ID,
ASKAI_CHANNEL } = process.env;

const token = DISCORD_BOT_TOKEN;
Expand Down Expand Up @@ -107,7 +107,7 @@ client.on("messageCreate", async (message) => {
},
onError: async (error) => {
console.error(error);

// send a message indicates unseccesful response from the AI
await message.channel.messages.fetch(aiMessageLoading.id).then((msg) =>
msg.edit({
Expand Down Expand Up @@ -575,7 +575,9 @@ client.on("messageCreate", async (message) => {
if (mentioned.roles.cache.hasAny(...roleIDs) && !member.roles.cache.hasAny(...roleIDs)) {
message.reply({
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.`)],
});
}).then(msg => {
setTimeout(() => msg.delete(), 60000)
})
}
}

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

// send message upon creating of new ticket
post.send({
embeds: [sendEmbedMessage(config.reminder_newpost)],
components: [CloseButtonComponent()],
});
// post.send({
// embeds: [sendEmbedMessage(config.reminder_newpost)],
// components: [CloseButtonComponent()],
// });

// log any new posts
console.log(
Expand All @@ -662,7 +664,7 @@ client.on("threadCreate", async (post) => {
botId: CONTEXT_ID,
query: question,
onComplete: async (query) => {

await post.messages.fetch(aiMessageLoading.id).then((msg) =>
msg.edit({
content: "",
Expand All @@ -672,7 +674,7 @@ client.on("threadCreate", async (post) => {
components: [FeedbackButtonComponent()],
})
);

},
onError: (error) => {
console.error(error);
Expand All @@ -692,8 +694,20 @@ client.on("interactionCreate", async (interaction) => {
const closeTag = post.availableTags.filter((item) => {
return item.name == config.tag_name_close;
});
const resolutionTag = post.availableTags.filter((item) => {
return item.name == config.tag_name_resolve;
});
const escalateTag = post.availableTags.filter((item) => {
return item.name == config.tag_name_escalate;
});
let initialTags = [closeTag[0].id, ...postTags];
let tags = [...new Set(initialTags)];
let initialTagsResolution = [resolutionTag[0].id, ...postTags].filter(
(item) => {
return item != escalateTag[0].id;
}
);
let tagsResolution = [...new Set(initialTagsResolution)];
const question = post.name;
if (interaction.channel.ownerId != interaction.user.id) return;
if (interaction.customId === "close") {
Expand Down Expand Up @@ -733,6 +747,28 @@ client.on("interactionCreate", async (interaction) => {
ephemeral: true,
});
await interaction.message.edit({ components: [] });

// send embed message upon executing the resolve command
await interaction.channel.send({
embeds: [sendEmbedMessage(`${config.reminder_resolve}`)],
content: `🔔 <@${interaction.channel.ownerId}>`,
});

// then archive / close it
await interaction.channel.edit({
appliedTags: tagsResolution,
archived: false,
});
sendData(
{
post_id: interaction.channel.id,
resolution_time: statusTime,
resolved_by: "Thirdweb Assistant",
},
config.datasheet_resolve
);


} else if (interaction.customId === "not-helpful") {
sendData(
{
Expand All @@ -742,11 +778,13 @@ client.on("interactionCreate", async (interaction) => {
config.datasheet_feedback
);
await interaction.reply({
embeds: [sendEmbedMessage(`Thank you so much for your feedback!`)],
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.`)],
content: `🔔 <@${interaction.channel.ownerId}>`,
ephemeral: true,
components: [CloseButtonComponent()],
});
await interaction.message.edit({ components: [] });

}
}
});
Expand Down
10 changes: 2 additions & 8 deletions src/utils/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,15 @@ const sendEmbedMessage = (message) => {
* @param {string} message
* @returns pre-defined embed style
*/
const CloseButtonComponent = () => {
const close = new ButtonBuilder()
.setCustomId('close')
.setLabel('Close')
.setEmoji('⚒️')
.setStyle(ButtonStyle.Danger);

const CloseButtonComponent = () => {
const support = new ButtonBuilder()
.setLabel('Submit a Ticket')
.setEmoji('💬')
.setURL('https://thirdweb.com/support')
.setStyle(ButtonStyle.Link);

const row = new ActionRowBuilder()
.addComponents(close, support);
.addComponents(support);
return row
}

Expand Down
Loading