Botpack / modules /commands /copilot.js
Jonell01's picture
Upload 64 files
2821330 verified
const axios = require("axios");
module.exports.config = {
name: "copilot",
hasPermission: 0,
version: "1.0.0",
commandCategory: "AI",
description: "Interact with the Copilot AI API",
usePrefix: false,
credits: "Jonell Magallanes",
cooldowns: 10
};
module.exports.run = async function ({ api, event, args }) {
const query = args.join(" ");
if (!query) {
return api.sendMessage("❌ Please provide a query!", event.threadID, event.messageID);
}
const l = await api.sendMessage("Loading....", event.threadID, event.messageID);
try {
const response = await axios.get(`https://ccprojectapis.ddns.net/api/copilot?ask=${encodeURIComponent(query)}`);
const data = response.data;
if (data.reply) {
api.editMessage(`π—–π—Όπ—½π—Άπ—Ήπ—Όπ˜ π—”π—œ\n━━━━━━━━━━━━━━━━━━\n${data.reply}`, l.messageID, event.threadID, event.messageID);
} else {
api.editMessage("There no response from copilot GitHub", l.messageID, event.threadID, event.messageID);
}
} catch (error) {
api.sendMessage(`${error.message}`, event.threadID, event.messageID);
}
};