commit
This commit is contained in:
parent
375cf667e0
commit
4d944dd64a
1 changed files with 338 additions and 299 deletions
|
@ -4,33 +4,7 @@ const { addToLogs } = require('../libs/botTools');
|
||||||
const { generateImage, answerQuestion, sendConv } = require('../libs/openAi');
|
const { generateImage, answerQuestion, sendConv } = require('../libs/openAi');
|
||||||
const { incrementQuota, addConv, delConv, getConvs, addMessage, getMessages, isNewUser } = require('../libs/mysql');
|
const { incrementQuota, addConv, delConv, getConvs, addMessage, getMessages, isNewUser } = require('../libs/mysql');
|
||||||
|
|
||||||
module.exports = {
|
async function gptrequest(interaction) {
|
||||||
newMessage : (client) => {
|
|
||||||
client.on('messageCreate', async msg => {
|
|
||||||
if (msg.content.startsWith('/g')) {
|
|
||||||
generateImage(msg.content.slice(+3)).then((res) => {
|
|
||||||
console.log('[Discord] Sent image to : ' + msg.content.slice(+3));
|
|
||||||
addToLogs('[Discord] Sent image to : ' + msg.content.slice(+3));
|
|
||||||
msg.channel.send(res.data.data[0].url);
|
|
||||||
}).catch((err) => {
|
|
||||||
console.log(err);
|
|
||||||
addToLogs(err);
|
|
||||||
msg.reply("Something went wrong");
|
|
||||||
})
|
|
||||||
|
|
||||||
console.log('[Discord] Generating image to : ' + msg.content.slice(+3));
|
|
||||||
addToLogs('[Discord] Generating image to : ' + msg.content.slice(+3));
|
|
||||||
msg.reply('Generating the image...');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
newInteraction : (client) => {
|
|
||||||
client.on('interactionCreate', async interaction => {
|
|
||||||
if (!interaction.isCommand()) return;
|
|
||||||
|
|
||||||
if (interaction.commandName === 'gptrequest') {
|
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
|
|
||||||
quota = isNewUser(interaction.member.user.id, interaction.member.user.username).catch((err) => {
|
quota = isNewUser(interaction.member.user.id, interaction.member.user.username).catch((err) => {
|
||||||
|
@ -95,11 +69,8 @@ module.exports = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (interaction.commandName === 'info') {
|
|
||||||
console.log(interaction)
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (interaction.commandName === 'addconv') {
|
async function addconv(interaction) {
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
convs = await getConvs().catch((err) => {
|
convs = await getConvs().catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
@ -131,7 +102,8 @@ module.exports = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (interaction.commandName === 'delconv') {
|
|
||||||
|
async function delconv(interaction) {
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
|
|
||||||
convs = await getConvs().catch((err) => {
|
convs = await getConvs().catch((err) => {
|
||||||
|
@ -164,7 +136,8 @@ module.exports = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (interaction.commandName === 'listconvs') {
|
|
||||||
|
async function listconvs(interaction) {
|
||||||
convs = await getConvs().catch((err) => {
|
convs = await getConvs().catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
addToLogs(err);
|
addToLogs(err);
|
||||||
|
@ -190,7 +163,8 @@ module.exports = {
|
||||||
console.log('[Discord] Sent conversations list');
|
console.log('[Discord] Sent conversations list');
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (interaction.commandName === 'addmsg') {
|
|
||||||
|
async function addmsg(interaction) {
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
|
|
||||||
quota = isNewUser(interaction.member.user.id, interaction.member.user.username).catch((err) => {
|
quota = isNewUser(interaction.member.user.id, interaction.member.user.username).catch((err) => {
|
||||||
|
@ -247,7 +221,8 @@ module.exports = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (interaction.commandName === 'displayconv') {
|
|
||||||
|
async function displayconv(interaction) {
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
|
|
||||||
if (interaction.options.get('name').value.includes(" ")) {
|
if (interaction.options.get('name').value.includes(" ")) {
|
||||||
|
@ -311,7 +286,8 @@ module.exports = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (interaction.commandName === 'getmyguota') {
|
|
||||||
|
async function getmyguota(interaction) {
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
|
|
||||||
quota = (await isNewUser(interaction.member.user.id, interaction.member.user.username).catch((error) => {
|
quota = (await isNewUser(interaction.member.user.id, interaction.member.user.username).catch((error) => {
|
||||||
|
@ -331,7 +307,8 @@ module.exports = {
|
||||||
console.log('[Discord] Quota requested by ' + interaction.member.user.username);
|
console.log('[Discord] Quota requested by ' + interaction.member.user.username);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (interaction.commandName === 'github') {
|
|
||||||
|
async function github(interation) {
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
|
|
||||||
const embed = new discord.EmbedBuilder()
|
const embed = new discord.EmbedBuilder()
|
||||||
|
@ -345,6 +322,68 @@ module.exports = {
|
||||||
addToLogs('[Discord] Github requested by ' + interaction.member.user.username);
|
addToLogs('[Discord] Github requested by ' + interaction.member.user.username);
|
||||||
console.log('[Discord] Github requested by ' + interaction.member.user.username);
|
console.log('[Discord] Github requested by ' + interaction.member.user.username);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
newMessage: (client) => {
|
||||||
|
client.on('messageCreate', async msg => {
|
||||||
|
if (msg.content.startsWith('/g')) {
|
||||||
|
generateImage(msg.content.slice(+3)).then((res) => {
|
||||||
|
console.log('[Discord] Sent image to : ' + msg.content.slice(+3));
|
||||||
|
addToLogs('[Discord] Sent image to : ' + msg.content.slice(+3));
|
||||||
|
msg.channel.send(res.data.data[0].url);
|
||||||
|
}).catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
addToLogs(err);
|
||||||
|
msg.reply("Something went wrong");
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log('[Discord] Generating image to : ' + msg.content.slice(+3));
|
||||||
|
addToLogs('[Discord] Generating image to : ' + msg.content.slice(+3));
|
||||||
|
msg.reply('Generating the image...');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
newInteraction: (client) => {
|
||||||
|
client.on('interactionCreate', async interaction => {
|
||||||
|
if (!interaction.isCommand()) return;
|
||||||
|
|
||||||
|
if (interaction.commandName === 'gptrequest') {
|
||||||
|
gptrequest(interaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (interaction.commandName === 'info') {
|
||||||
|
console.log(interaction)
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (interaction.commandName === 'addconv') {
|
||||||
|
addconv(interaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (interaction.commandName === 'delconv') {
|
||||||
|
delconv(interaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (interaction.commandName === 'listconvs') {
|
||||||
|
listconvs(interaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (interaction.commandName === 'addmsg') {
|
||||||
|
addmsg(interaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (interaction.commandName === 'displayconv') {
|
||||||
|
displayconv(interaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (interaction.commandName === 'getmyguota') {
|
||||||
|
getmyguota(interaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (interaction.commandName === 'github') {
|
||||||
|
github(interaction);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue