Skip to content

Commit

Permalink
🚀 release: v2.0.8
Browse files Browse the repository at this point in the history
Merge pull request #88 from thirdweb-dev/v2
  • Loading branch information
warengonzaga authored Mar 9, 2024
2 parents fde7a6f + 64f01b1 commit 2d33507
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 28 deletions.
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.7",
"version": "2.0.8",
"description": "A self-hosted dedicated forum-based support Discord bot for the thirdweb community.",
"main": "src/bot.ts",
"author": "Waren Gonzaga",
Expand Down
58 changes: 31 additions & 27 deletions src/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,34 +70,38 @@ client.on("messageCreate", async (message) => {
});
console.log(`[log]: responded to version command in version ${version}`);
}
if (message.channel.id === ASKAI_CHANNEL && message.content.startsWith('!askai') || message.channel.id === ASKAI_CHANNEL && message.content.startsWith('!ask')) {
let question = message.content.startsWith('!askai') ? message.content.slice(6) : message.content.slice(4)
let aiMessageLoading = await message.channel.send({
embeds: [
sendEmbedMessage("**🤖 Beep Boop Boop Beep:** " + `<a:load:1210497921158619136> thinking...`),
],
});
await context.query({
botId: CONTEXT_ID,
query: question,
onComplete: async (query) => {
// console.log(query.output.toString())
await message.channel.messages.fetch(aiMessageLoading.id).then((msg) =>
msg.edit({
content: `Hey <@${message.author.id}> 👇`,
embeds: [
sendEmbedMessage(`**Response:**\n${query.output.toString()}`),
],

})
);

},
onError: (error) => {
console.error(error);
},
});
// respond to ask command
if ((message.content.startsWith('!askai') || message.content.startsWith('!ask'))) {
let question = message.content.startsWith('!askai') ? message.content.slice(6) : message.content.slice(4);
if (message.channel.id === ASKAI_CHANNEL) {
let aiMessageLoading = await message.channel.send({
embeds: [
sendEmbedMessage("**🤖 Beep Boop Boop Beep:** " + `<a:load:1210497921158619136> thinking...`),
],
});

try {
const query = await context.query({
botId: CONTEXT_ID,
query: question
});

const msg = await message.channel.messages.fetch(aiMessageLoading.id);
await msg.edit({
content: `Hey <@${message.author.id}> 👇`,
embeds: [
sendEmbedMessage(`**Response:**\n${query.output.toString()}`),
],
});
} catch (error) {
console.error(error);
}
} else {
message.reply({
content: `Hey <@${message.author.id}> 👇`,
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.`)],
});
}
}
// respond to user if the bot mentioned specifically not with everyone
if (message.mentions.has(client.user) && !message.mentions.everyone) {
Expand Down

0 comments on commit 2d33507

Please sign in to comment.