Skip to content

Commit 2d33507

Browse files
authored
🚀 release: v2.0.8
Merge pull request #88 from thirdweb-dev/v2
2 parents fde7a6f + 64f01b1 commit 2d33507

File tree

2 files changed

+32
-28
lines changed

2 files changed

+32
-28
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.7",
3+
"version": "2.0.8",
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: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -70,34 +70,38 @@ client.on("messageCreate", async (message) => {
7070
});
7171
console.log(`[log]: responded to version command in version ${version}`);
7272
}
73-
if (message.channel.id === ASKAI_CHANNEL && message.content.startsWith('!askai') || message.channel.id === ASKAI_CHANNEL && message.content.startsWith('!ask')) {
74-
let question = message.content.startsWith('!askai') ? message.content.slice(6) : message.content.slice(4)
75-
let aiMessageLoading = await message.channel.send({
76-
embeds: [
77-
sendEmbedMessage("**🤖 Beep Boop Boop Beep:** " + `<a:load:1210497921158619136> thinking...`),
78-
],
79-
});
80-
await context.query({
81-
botId: CONTEXT_ID,
82-
query: question,
83-
onComplete: async (query) => {
84-
// console.log(query.output.toString())
85-
await message.channel.messages.fetch(aiMessageLoading.id).then((msg) =>
86-
msg.edit({
87-
content: `Hey <@${message.author.id}> 👇`,
88-
embeds: [
89-
sendEmbedMessage(`**Response:**\n${query.output.toString()}`),
90-
],
91-
92-
})
93-
);
94-
95-
},
96-
onError: (error) => {
97-
console.error(error);
98-
},
99-
});
73+
// respond to ask command
74+
if ((message.content.startsWith('!askai') || message.content.startsWith('!ask'))) {
75+
let question = message.content.startsWith('!askai') ? message.content.slice(6) : message.content.slice(4);
76+
if (message.channel.id === ASKAI_CHANNEL) {
77+
let aiMessageLoading = await message.channel.send({
78+
embeds: [
79+
sendEmbedMessage("**🤖 Beep Boop Boop Beep:** " + `<a:load:1210497921158619136> thinking...`),
80+
],
81+
});
10082

83+
try {
84+
const query = await context.query({
85+
botId: CONTEXT_ID,
86+
query: question
87+
});
88+
89+
const msg = await message.channel.messages.fetch(aiMessageLoading.id);
90+
await msg.edit({
91+
content: `Hey <@${message.author.id}> 👇`,
92+
embeds: [
93+
sendEmbedMessage(`**Response:**\n${query.output.toString()}`),
94+
],
95+
});
96+
} catch (error) {
97+
console.error(error);
98+
}
99+
} else {
100+
message.reply({
101+
content: `Hey <@${message.author.id}> 👇`,
102+
embeds: [sendEmbedMessage(`You can ask me all things thirdweb in the <#${ASKAI_CHANNEL}> channel. Just type your question after the command \`!askai\` or \`!ask\` to get started.`)],
103+
});
104+
}
101105
}
102106
// respond to user if the bot mentioned specifically not with everyone
103107
if (message.mentions.has(client.user) && !message.mentions.everyone) {

0 commit comments

Comments
 (0)