mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-21 18:23:57 +00:00
34 lines
746 B
JavaScript
34 lines
746 B
JavaScript
export default {
|
|
name: 'aiResponse',
|
|
once: false,
|
|
async execute(client, config, aiRes) {
|
|
const response = config.responses.find(
|
|
(res) => res.label === aiRes.predictions[0].label
|
|
);
|
|
if (!response) return;
|
|
|
|
if (Number(aiRes.predictions[0].score) >= response.threshold) {
|
|
if (!response.text) return;
|
|
|
|
const ids = aiRes.id.split('/');
|
|
let channel = client.channels.cache.get(ids[0]);
|
|
|
|
if (!channel) {
|
|
await client.channels.fetch(ids[0]);
|
|
channel = client.channels.cache.get(ids[0]);
|
|
}
|
|
|
|
let message = channel.messages.cache.get(ids[1]);
|
|
|
|
if (!message) {
|
|
await channel.messages.fetch(ids[1]);
|
|
message = channel.messages.cache.get(ids[1]);
|
|
}
|
|
|
|
message.reply(response.text);
|
|
|
|
return;
|
|
}
|
|
}
|
|
};
|