feat: add wit.ai support

This commit is contained in:
GramingFoxTeam
2023-03-19 22:24:29 +03:00
parent 84a290933f
commit 1909e2c421
8 changed files with 42 additions and 54 deletions

View File

@@ -5,7 +5,6 @@ export default {
once: false,
execute(helper, _, msg) {
if (!msg.content || msg.author.bot) return;
if (!msg.mentions.has(msg.client.user)) return;
helper.scanText(msg.content.toLowerCase().replace(/<.*?>/g, ''), `${msg.channelId}/${msg.id}`);
}
};

View File

@@ -1,8 +1,11 @@
import { EmbedBuilder } from 'discord.js';
export default {
name: 'aiResponse',
once: false,
async execute(client, config, aiRes) {
if (!aiRes.response) return;
if (!aiRes.response[0]) return;
try {
const ids = aiRes.id.split('/');
@@ -20,10 +23,19 @@ export default {
message = channel.messages.cache.get(ids[1]);
}
message.reply(aiRes.response);
const intent = aiRes.response.reduce((a, b) => a.confidence > b.confidence ? a : b);
const response = config.responses.find((res) => res.label === intent.name);
if (response.threshold > intent.confidence) return;
const embed = new EmbedBuilder()
.setTitle('You have asked a Frequently Asked Question')
.setDescription(response.text)
.setFooter({ text: `Confidence: ${intent.confidence}` });
message.reply({ embeds: [embed]});
return;
} catch (e) {}
} catch (e) {console.log(e)}
}
};