Compare commits
10 Commits
Author | SHA1 | Date |
---|---|---|
Skylar Grant | 9d24745e46 | |
Skylar Grant | 6f7f3df001 | |
Skylar Grant | 050d927908 | |
Skylar Grant | fcbe25687f | |
Skylar Grant | 26e94e71b2 | |
Skylar Grant | b1ffd2d22b | |
Skylar Grant | 06f9758bc2 | |
Skylar Grant | c46d183608 | |
Skylar Grant | ae95349b9b | |
Skylar Grant | d15ccf6a5b |
|
@ -1,7 +1,7 @@
|
||||||
name: NodBot Production Dockerization
|
name: NodBot Production Dockerization
|
||||||
|
|
||||||
on:
|
on:
|
||||||
commit:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- pe
|
- pe
|
||||||
|
|
||||||
|
|
|
@ -114,4 +114,3 @@ dist
|
||||||
|
|
||||||
# TernJS port file
|
# TernJS port file
|
||||||
.tern-port
|
.tern-port
|
||||||
.DS_Store
|
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
module.exports = {
|
|
||||||
GifData: class {
|
|
||||||
constructor() {
|
|
||||||
this.id = 0;
|
|
||||||
this.name = "";
|
|
||||||
this.url = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initial GifData configuration
|
|
||||||
// Can also be used to update the data piecemeal
|
|
||||||
setInfo(name, url, id) {
|
|
||||||
// Check for existing or incoming name
|
|
||||||
if ((this.name === "") && (typeof name !== 'string')) throw `Error: This Gif doesn't have existing name, and no name is going to be set.`;
|
|
||||||
// Check for existing content or incoming content
|
|
||||||
if ((this.url === "") && (typeof url !== 'string')) throw `Error: This Gif doesn't have existing url, and no url is going to be set.`;
|
|
||||||
|
|
||||||
// Property is set if the variable is the right type,
|
|
||||||
// otherwise it keeps the existing property
|
|
||||||
this.id = typeof id === 'number' ? id : this.id;
|
|
||||||
this.name = typeof name === 'string' ? name : this.name;
|
|
||||||
this.url = typeof url === 'string' ? url : this.url;
|
|
||||||
|
|
||||||
return this; // For chaining
|
|
||||||
}
|
|
||||||
},
|
|
||||||
PastaData: class {
|
|
||||||
constructor() {
|
|
||||||
this.id = 0;
|
|
||||||
this.name = "";
|
|
||||||
this.content = "";
|
|
||||||
this.iconUrl = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initial PastaData configuration
|
|
||||||
// Can also be used to update the data piecemeal
|
|
||||||
setInfo(name, content, iconUrl, id) {
|
|
||||||
// Check for existing or incoming name
|
|
||||||
if ((this.name === "") && (typeof name !== 'string')) throw `Error: This Pasta doesn't have existing name, and no name is going to be set.`;
|
|
||||||
// Check for existing content or incoming content
|
|
||||||
if ((this.content === "") && (typeof content !== 'string')) throw `Error: This Pasta doesn't have existing content, and no content is going to be set.`;
|
|
||||||
|
|
||||||
// Property is set if the variable is the right type,
|
|
||||||
// otherwise it keeps the existing property
|
|
||||||
this.id = typeof id === 'number' ? id : this.id;
|
|
||||||
this.name = typeof name === 'string' ? name : this.name;
|
|
||||||
this.content = typeof content === 'string' ? content : this.content;
|
|
||||||
this.iconUrl = typeof iconUrl === 'string' ? iconUrl : this.iconUrl;
|
|
||||||
|
|
||||||
return this; // For chaining
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,5 +5,4 @@ WORKDIR /usr/src/app
|
||||||
COPY package.json ./
|
COPY package.json ./
|
||||||
RUN npm install
|
RUN npm install
|
||||||
COPY . .
|
COPY . .
|
||||||
# CMD ["/bin/sh", "-c", "node main.js 2> /logs/nodbot.error 1> /logs/nodbot.log"]
|
CMD ["/bin/sh", "-c", "node main.js 2> /logs/nodbot.error 1> /logs/nodbot.log"]
|
||||||
CMD ["/bin/sh", "-c", "node main.js 2> /logs/$(date +%Y-%m-%d_%H-%M-%S)-error.txt 1> /logs/$(date +%Y-%m-%d_%H-%M-%S)-status.txt"]
|
|
|
@ -1,5 +1,4 @@
|
||||||
{
|
{
|
||||||
"guildId": "868542949737246730",
|
"guildId": "868542949737246730",
|
||||||
"validCommands": [],
|
"validCommands": []
|
||||||
"roaches": []
|
|
||||||
}
|
}
|
|
@ -13,7 +13,7 @@ module.exports = {
|
||||||
async execute(message, commandData) {
|
async execute(message, commandData) {
|
||||||
// if (message.deletable) message.delete();
|
// if (message.deletable) message.delete();
|
||||||
const client = message.client;
|
const client = message.client;
|
||||||
if (!client.gifs.has(commandData.args.toLowerCase())) {
|
if (!client.gifs.has(commandData.args)) {
|
||||||
if (process.env.isDev) console.log('https://tenor.googleapis.com/v2/search?' + `&q=${commandData.args}` + `&key=${process.env.tenorAPIKey}` + '&limit=1&contentfilter=off');
|
if (process.env.isDev) console.log('https://tenor.googleapis.com/v2/search?' + `&q=${commandData.args}` + `&key=${process.env.tenorAPIKey}` + '&limit=1&contentfilter=off');
|
||||||
const q = await axios.get(
|
const q = await axios.get(
|
||||||
'https://tenor.googleapis.com/v2/search?' +
|
'https://tenor.googleapis.com/v2/search?' +
|
||||||
|
@ -43,11 +43,11 @@ module.exports = {
|
||||||
// }).catch(err => console.error(err));
|
// }).catch(err => console.error(err));
|
||||||
} else {
|
} else {
|
||||||
// message.reply(commandData.args + ' requested by ' + message.author.username + '\n' + client.gifs.get(commandData.args).embed_url);
|
// message.reply(commandData.args + ' requested by ' + message.author.username + '\n' + client.gifs.get(commandData.args).embed_url);
|
||||||
const gifData = client.gifs.get(commandData.args.toLowerCase());
|
commandData.embed_url = client.gifs.get(commandData.args).embed_url;
|
||||||
// message.reply(fn.embeds.gif(commandData));
|
// message.reply(fn.embeds.gif(commandData));
|
||||||
// message.channel.send(`> ${commandData.author} - ${commandData.args}.gif`);
|
// message.channel.send(`> ${commandData.author} - ${commandData.args}.gif`);
|
||||||
// message.channel.send(commandData.embed_url);
|
// message.channel.send(commandData.embed_url);
|
||||||
message.reply(gifData.url);
|
message.reply(commandData.embed_url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,33 +5,12 @@ module.exports = {
|
||||||
name: 'joint',
|
name: 'joint',
|
||||||
description: 'Send a random weed-themed phrase.',
|
description: 'Send a random weed-themed phrase.',
|
||||||
usage: '.joint',
|
usage: '.joint',
|
||||||
alias: ['bong', 'blunt', 'bowl', 'pipe', 'dab', 'vape', 'dabs', 'shatter', 'edible', 'edibles', 'doobie', 'spliff', 'gummy', 'gummies', 'hash', 'toke', 'big doinks'],
|
|
||||||
execute(message, commandData) {
|
execute(message, commandData) {
|
||||||
let joints = [];
|
let joints = [];
|
||||||
// Create a simple array of the joint texts
|
|
||||||
for (const entry of message.client.joints.map(joint => joint.content)) {
|
for (const entry of message.client.joints.map(joint => joint.content)) {
|
||||||
joints.push(entry);
|
joints.push(entry);
|
||||||
}
|
}
|
||||||
// Generate a random number between 0 and the length of the joints array
|
const randIndex = Math.floor(Math.random() * joints.length);
|
||||||
let randIndex = Math.floor(Math.random() * joints.length);
|
|
||||||
// Grab the joint text from the array
|
|
||||||
let joint = joints[randIndex];
|
|
||||||
|
|
||||||
// Check if the joint has already been smoked
|
|
||||||
while (message.client.roaches.has(joint)) {
|
|
||||||
// Regenerate a random number and recheck
|
|
||||||
randIndex = Math.floor(Math.random() * joints.length);
|
|
||||||
joint = joints[randIndex];
|
|
||||||
}
|
|
||||||
// Send the joint
|
|
||||||
message.reply(`${joints[randIndex]} ${emoji.joint}`);
|
message.reply(`${joints[randIndex]} ${emoji.joint}`);
|
||||||
// Check how full the roach collection is
|
|
||||||
if (message.client.roaches.size / joints.length >= 0.85) {
|
|
||||||
// If the roach collection is 85% of the joints collection
|
|
||||||
// Empty it out
|
|
||||||
message.client.roaches.clear();
|
|
||||||
}
|
|
||||||
// Add the joint to the roach collection
|
|
||||||
message.client.roaches.set(joint, "baked");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,14 +6,14 @@ module.exports = {
|
||||||
usage: '<Copypasta Name>.pasta',
|
usage: '<Copypasta Name>.pasta',
|
||||||
execute(message, commandData) {
|
execute(message, commandData) {
|
||||||
const client = message.client;
|
const client = message.client;
|
||||||
let pastaData;
|
let replyBody = '';
|
||||||
|
let iconUrl;
|
||||||
if (!client.pastas.has(commandData.args)) {
|
if (!client.pastas.has(commandData.args)) {
|
||||||
pastaData = {
|
commandData.content = 'Sorry I couldn\'t find that pasta.';
|
||||||
content: "Sorry, I couldn't find that pasta."
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
pastaData = client.pastas.get(commandData.args);
|
commandData.content = client.pastas.get(commandData.args).content;
|
||||||
|
commandData.iconUrl = client.pastas.get(commandData.args).iconUrl;
|
||||||
}
|
}
|
||||||
message.reply(fn.embeds.pasta(commandData, pastaData));
|
message.reply(fn.embeds.pasta(commandData));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ module.exports = {
|
||||||
execute(message, commandData) {
|
execute(message, commandData) {
|
||||||
const request = commandData.args;
|
const request = commandData.args;
|
||||||
commandData.content = `Your request has been submitted!\nRequest: ${request}`;
|
commandData.content = `Your request has been submitted!\nRequest: ${request}`;
|
||||||
|
commandData.requestUrl = message.url;
|
||||||
message.reply(fn.embeds.text(commandData));
|
message.reply(fn.embeds.text(commandData));
|
||||||
commandData.content = `A new request has been submitted by ${message.author.tag}:\n${commandData.args}`;
|
commandData.content = `A new request has been submitted by ${message.author.tag}:\n${commandData.args}`;
|
||||||
message.client.users.fetch(process.env.ownerID).then(user => {
|
message.client.users.fetch(process.env.ownerID).then(user => {
|
||||||
|
|
|
@ -10,33 +10,20 @@ module.exports = {
|
||||||
// message.reply(fn.spongebob(commandData)).then(() => {
|
// message.reply(fn.spongebob(commandData)).then(() => {
|
||||||
// message.delete();
|
// message.delete();
|
||||||
// });
|
// });
|
||||||
if (message.reference != undefined) { // message.reference is undefined if the message isn't a reply to another message
|
if (message.reference != undefined) {
|
||||||
if (commandData.args !== "") { // If the replying message isn't just .sb
|
const repliedMessageId = message.reference.messageId;
|
||||||
const repliedMessageId = message.reference.messageId; // grab the message Id of the replied-to msg
|
message.channel.messages.fetch(repliedMessageId)
|
||||||
message.channel.messages.fetch(repliedMessageId) // Fetch the message because with our luck it isn't in the cache
|
.then(repliedMessage => {
|
||||||
.then(repliedMessage => {
|
repliedMessage.reply(fn.spongebob({ args: repliedMessage.content })).then(() => {
|
||||||
repliedMessage.reply(fn.spongebob({ args: commandData.args })).then(() => { // Use the pre-command text of the replying message to sb-ify
|
if (message.deletable) message.delete();
|
||||||
if (message.deletable) message.delete(); // If the initiating message is deletable, delete it.
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.error(err);
|
|
||||||
});
|
});
|
||||||
} else { // We're working with a basic ".sb" and can proceed as we did before...
|
})
|
||||||
const repliedMessageId = message.reference.messageId; // grab the message Id of the replied-to msg
|
.catch(err => {
|
||||||
message.channel.messages.fetch(repliedMessageId) // Fetch the message because with our luck it isn't in the cache
|
console.error(err);
|
||||||
.then(repliedMessage => {
|
});
|
||||||
repliedMessage.reply(fn.spongebob({ args: repliedMessage.content })).then(() => {
|
} else {
|
||||||
if (message.deletable) message.delete();
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.error(err);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else { // The message isn't a reply, so just sb it like we did from the very beginning
|
|
||||||
message.channel.send(fn.spongebob(commandData)).then(() => {
|
message.channel.send(fn.spongebob(commandData)).then(() => {
|
||||||
if (message.deletable) message.delete(); // If the initiating message is deletable, delete it.
|
if (message.deletable) message.delete();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
304
functions.js
304
functions.js
|
@ -21,10 +21,6 @@ const Discord = require('discord.js');
|
||||||
// Fuzzy text matching for db lookups
|
// Fuzzy text matching for db lookups
|
||||||
const FuzzySearch = require('fuzzy-search');
|
const FuzzySearch = require('fuzzy-search');
|
||||||
|
|
||||||
// OpenAI
|
|
||||||
// const OpenAI = require("openai");
|
|
||||||
// const openai = new OpenAI();
|
|
||||||
|
|
||||||
// Various imports from other files
|
// Various imports from other files
|
||||||
const config = require('./config.json');
|
const config = require('./config.json');
|
||||||
const strings = require('./strings.json');
|
const strings = require('./strings.json');
|
||||||
|
@ -33,7 +29,6 @@ const dotCommandFiles = fs.readdirSync('./dot-commands/').filter(file => file.en
|
||||||
|
|
||||||
// MySQL database connection
|
// MySQL database connection
|
||||||
const mysql = require('mysql');
|
const mysql = require('mysql');
|
||||||
const { GifData, PastaData } = require('./CustomModules/NodBot');
|
|
||||||
const db = new mysql.createPool({
|
const db = new mysql.createPool({
|
||||||
connectionLimit: 10,
|
connectionLimit: 10,
|
||||||
host: dbHost,
|
host: dbHost,
|
||||||
|
@ -91,13 +86,12 @@ const functions = {
|
||||||
if (!client.gifs) client.gifs = new Discord.Collection();
|
if (!client.gifs) client.gifs = new Discord.Collection();
|
||||||
client.gifs.clear();
|
client.gifs.clear();
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
// const gif = {
|
const gif = {
|
||||||
// id: row.id,
|
id: row.id,
|
||||||
// name: row.name,
|
name: row.name,
|
||||||
// embed_url: row.embed_url
|
embed_url: row.embed_url
|
||||||
// };
|
};
|
||||||
const gifData = new GifData().setInfo(row.name, row.embed_url);
|
client.gifs.set(gif.name, gif);
|
||||||
client.gifs.set(gifData.name, gifData);
|
|
||||||
}
|
}
|
||||||
if (isDev) console.log('GIFs Collection Built');
|
if (isDev) console.log('GIFs Collection Built');
|
||||||
},
|
},
|
||||||
|
@ -117,8 +111,13 @@ const functions = {
|
||||||
if (!client.pastas) client.pastas = new Discord.Collection();
|
if (!client.pastas) client.pastas = new Discord.Collection();
|
||||||
client.pastas.clear();
|
client.pastas.clear();
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
const pastaData = new PastaData().setInfo(row.name, row.content, row.iconurl, row.id);
|
const pasta = {
|
||||||
client.pastas.set(pastaData.name, pastaData);
|
id: row.id,
|
||||||
|
name: row.name,
|
||||||
|
content: row.content,
|
||||||
|
iconUrl: row.iconurl,
|
||||||
|
};
|
||||||
|
client.pastas.set(pasta.name, pasta);
|
||||||
}
|
}
|
||||||
if (isDev) console.log('Pastas Collection Built');
|
if (isDev) console.log('Pastas Collection Built');
|
||||||
},
|
},
|
||||||
|
@ -149,7 +148,7 @@ const functions = {
|
||||||
if (isDev) console.log('Strains Collection Built');
|
if (isDev) console.log('Strains Collection Built');
|
||||||
},
|
},
|
||||||
medicalAdvice(rows, client) {
|
medicalAdvice(rows, client) {
|
||||||
if (!client.medicalAdviceColl) client.medicalAdviceColl = new Discord.Collection();
|
if (!client.medicalAdviceCol) client.medicalAdviceColl = new Discord.Collection();
|
||||||
client.medicalAdviceColl.clear();
|
client.medicalAdviceColl.clear();
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
const medicalAdvice = {
|
const medicalAdvice = {
|
||||||
|
@ -157,21 +156,16 @@ const functions = {
|
||||||
content: row.content
|
content: row.content
|
||||||
};
|
};
|
||||||
client.medicalAdviceColl.set(medicalAdvice.id, medicalAdvice);
|
client.medicalAdviceColl.set(medicalAdvice.id, medicalAdvice);
|
||||||
}
|
}
|
||||||
if (isDev) console.log('Medical Advice Collection Built');
|
if (isDev) console.log('Medical Advice Collection Built');
|
||||||
},
|
},
|
||||||
roaches(client) {
|
|
||||||
if (!client.roaches) client.roaches = new Discord.Collection();
|
|
||||||
client.roaches.clear();
|
|
||||||
if (isDev) console.log('Medical Advice Collection Built');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
dot: {
|
dot: {
|
||||||
getCommandData(message) {
|
getCommandData(message) {
|
||||||
const commandData = {};
|
const commandData = {};
|
||||||
// Split the message content at the final instance of a period
|
// Split the message content at the final instance of a period
|
||||||
const finalPeriod = message.content.lastIndexOf('.');
|
const finalPeriod = message.content.lastIndexOf('.');
|
||||||
// if(isDev) console.log(message.content);
|
if(isDev) console.log(message.content);
|
||||||
// If the final period is the last character, or doesn't exist
|
// If the final period is the last character, or doesn't exist
|
||||||
if (finalPeriod < 0) {
|
if (finalPeriod < 0) {
|
||||||
if (isDev) console.log(finalPeriod);
|
if (isDev) console.log(finalPeriod);
|
||||||
|
@ -182,8 +176,8 @@ const functions = {
|
||||||
// Get the first part of the message, everything leading up to the final period
|
// Get the first part of the message, everything leading up to the final period
|
||||||
commandData.args = message.content.slice(0,finalPeriod).toLowerCase();
|
commandData.args = message.content.slice(0,finalPeriod).toLowerCase();
|
||||||
// Get the last part of the message, everything after the final period
|
// Get the last part of the message, everything after the final period
|
||||||
commandData.command = message.content.slice(finalPeriod + 1).toLowerCase();
|
commandData.command = message.content.slice(finalPeriod).replace('.','').toLowerCase();
|
||||||
commandData.author = `${message.author.username}`;
|
commandData.author = `${message.author.username}#${message.author.discriminator}`;
|
||||||
return this.checkCommand(commandData);
|
return this.checkCommand(commandData);
|
||||||
},
|
},
|
||||||
checkCommand(commandData) {
|
checkCommand(commandData) {
|
||||||
|
@ -205,7 +199,7 @@ const functions = {
|
||||||
// Construct the Help Embed
|
// Construct the Help Embed
|
||||||
const helpEmbed = new Discord.MessageEmbed()
|
const helpEmbed = new Discord.MessageEmbed()
|
||||||
.setColor('BLUE')
|
.setColor('BLUE')
|
||||||
.setAuthor({name: 'Help Page'})
|
.setAuthor('Help Page')
|
||||||
.setDescription(strings.help.description)
|
.setDescription(strings.help.description)
|
||||||
.setThumbnail(strings.urls.avatar);
|
.setThumbnail(strings.urls.avatar);
|
||||||
|
|
||||||
|
@ -258,25 +252,25 @@ const functions = {
|
||||||
},
|
},
|
||||||
gif(commandData) {
|
gif(commandData) {
|
||||||
return { embeds: [new Discord.MessageEmbed()
|
return { embeds: [new Discord.MessageEmbed()
|
||||||
.setAuthor({name: `${commandData.args}.${commandData.command}`})
|
.setAuthor(`${commandData.args}.${commandData.command}`)
|
||||||
.setImage(commandData.embed_url)
|
.setImage(commandData.embed_url)
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setFooter({text: commandData.author})]};
|
.setFooter(commandData.author)]};
|
||||||
},
|
},
|
||||||
pasta(commandData, pastaData) {
|
pasta(commandData) {
|
||||||
return { embeds: [ new Discord.MessageEmbed()
|
return { embeds: [ new Discord.MessageEmbed()
|
||||||
.setAuthor({name: `${commandData.args}.${commandData.command}`})
|
.setAuthor(`${commandData.args}.${commandData.command}`)
|
||||||
.setDescription(pastaData.content)
|
.setDescription(commandData.content)
|
||||||
.setThumbnail("https://assets.vfsh.dev/shednod.png")
|
.setThumbnail(commandData.iconUrl)
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setFooter({text: commandData.author})]};
|
.setFooter(commandData.author)]};
|
||||||
},
|
},
|
||||||
pastas(commandData) {
|
pastas(commandData) {
|
||||||
const pastasArray = [];
|
const pastasArray = [];
|
||||||
const pastasEmbed = new Discord.MessageEmbed()
|
const pastasEmbed = new Discord.MessageEmbed()
|
||||||
.setAuthor({name: commandData.command})
|
.setAuthor(commandData.command)
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setFooter({text: commandData.author});
|
.setFooter(commandData.author);
|
||||||
|
|
||||||
for (const row of commandData.pastas) {
|
for (const row of commandData.pastas) {
|
||||||
pastasArray.push(`#${row.id} - ${row.name}.pasta`);
|
pastasArray.push(`#${row.id} - ${row.name}.pasta`);
|
||||||
|
@ -287,27 +281,34 @@ const functions = {
|
||||||
|
|
||||||
return { embeds: [pastasEmbed], ephemeral: true };
|
return { embeds: [pastasEmbed], ephemeral: true };
|
||||||
},
|
},
|
||||||
gifs(commandData, gifList) {
|
gifs(commandData) {
|
||||||
|
const gifsArray = [];
|
||||||
const gifsEmbed = new Discord.MessageEmbed()
|
const gifsEmbed = new Discord.MessageEmbed()
|
||||||
.setAuthor({name: commandData.command})
|
.setAuthor(commandData.command)
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setFooter({text: commandData.author})
|
.setFooter(commandData.author);
|
||||||
.setDescription(gifList.join('\n'));
|
|
||||||
|
for (const row of commandData.gifs) {
|
||||||
|
gifsArray.push(`#${row.id} - ${row.name}.gif`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const gifsString = gifsArray.join('\n');
|
||||||
|
gifsEmbed.setDescription(gifsString);
|
||||||
|
|
||||||
return { embeds: [gifsEmbed] };
|
return { embeds: [gifsEmbed] };
|
||||||
},
|
},
|
||||||
text(commandData) {
|
text(commandData) {
|
||||||
return { embeds: [new Discord.MessageEmbed()
|
return { embeds: [new Discord.MessageEmbed()
|
||||||
.setAuthor({name: commandData.command})
|
.setAuthor(commandData.command)
|
||||||
.setDescription(commandData.content)
|
.setDescription(commandData.content)
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setFooter({text: commandData.author})]};
|
.setFooter(commandData.author)]};
|
||||||
},
|
},
|
||||||
requests(commandData) {
|
requests(commandData) {
|
||||||
const requestsEmbed = new Discord.MessageEmbed()
|
const requestsEmbed = new Discord.MessageEmbed()
|
||||||
.setAuthor({name: commandData.command})
|
.setAuthor(commandData.command)
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setFooter({text: commandData.author});
|
.setFooter(commandData.author);
|
||||||
|
|
||||||
const requestsArray = [];
|
const requestsArray = [];
|
||||||
|
|
||||||
|
@ -322,9 +323,11 @@ const functions = {
|
||||||
|
|
||||||
return { embeds: [requestsEmbed], ephemeral: true };
|
return { embeds: [requestsEmbed], ephemeral: true };
|
||||||
},
|
},
|
||||||
strain(strainInfo, interaction) {
|
strain(commandData, message) {
|
||||||
const strainEmbed = new Discord.MessageEmbed()
|
const strainEmbed = new Discord.MessageEmbed()
|
||||||
.setTimestamp();
|
.setTimestamp()
|
||||||
|
.setFooter(commandData.author);
|
||||||
|
const { strainInfo } = commandData;
|
||||||
strainEmbed.addFields([
|
strainEmbed.addFields([
|
||||||
{
|
{
|
||||||
name: 'Strain Name',
|
name: 'Strain Name',
|
||||||
|
@ -348,7 +351,7 @@ const functions = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Rating',
|
name: 'Rating',
|
||||||
value: `⭐️${strainInfo.rating}`,
|
value: `${strainInfo.rating}⭐️s`,
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -358,33 +361,8 @@ const functions = {
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
interaction.reply({ embeds: [ strainEmbed ]});
|
message.reply({ embeds: [ strainEmbed ]});
|
||||||
},
|
},
|
||||||
dalle(prompt, imageUrl, size) {
|
|
||||||
const dalleEmbed = new Discord.MessageEmbed()
|
|
||||||
.setAuthor({ name: "NodBot powered by DALL-E", iconURL: "https://assets.vfsh.dev/openai-logos/PNGs/openai-logomark.png" })
|
|
||||||
.addFields(
|
|
||||||
{ name: "Prompt", value: prompt }
|
|
||||||
)
|
|
||||||
.setImage(imageUrl)
|
|
||||||
.setFooter({ text: `This ${size} image cost ${strings.costs.dalle[size]}¢ to generate.` })
|
|
||||||
return { embeds: [dalleEmbed] };
|
|
||||||
},
|
|
||||||
gpt(prompt, response, usage) {
|
|
||||||
const gptEmbed = new Discord.MessageEmbed()
|
|
||||||
.setAuthor({ name: "NodBot powered by GPT-3.5", iconURL: "https://assets.vfsh.dev/openai-logos/PNGs/openai-logomark.png" })
|
|
||||||
.setDescription(`**Prompt**\n${prompt}\n\n**Response**\n${response}`)
|
|
||||||
.setFooter({ text: `This prompt used ${usage.tokens} tokens for a cost of ${usage.usdc}¢. Generated using ${strings.ai.chatModel}` })
|
|
||||||
return { embeds: [gptEmbed] };
|
|
||||||
},
|
|
||||||
generatingResponse() {
|
|
||||||
const embed = new Discord.MessageEmbed()
|
|
||||||
.setAuthor({ name: "NodBot powered by OpenAI", iconURL: "https://assets.vfsh.dev/openai-logos/PNGs/openai-logomark.png" })
|
|
||||||
.setImage("https://media.tenor.com/aHMHzNGCb4kAAAAC/sucks.gif")
|
|
||||||
.setDescription("Generating a response, please stand by.")
|
|
||||||
.setFooter({ text: "Ligma balls" });
|
|
||||||
return { embeds: [embed] };
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
collect: {
|
collect: {
|
||||||
gifName(interaction) {
|
gifName(interaction) {
|
||||||
|
@ -394,19 +372,18 @@ const functions = {
|
||||||
},
|
},
|
||||||
upload: {
|
upload: {
|
||||||
request(commandData, client) {
|
request(commandData, client) {
|
||||||
const query = `INSERT INTO requests (author, request, status) VALUES (${db.escape(commandData.author)},${db.escape(commandData.args)},'Active')`;
|
const query = `INSERT INTO requests (author, request, status, url) VALUES (${db.escape(commandData.author)},${db.escape(commandData.args)},'Active',${db.escape(commandData.url)})`;
|
||||||
db.query(query, (err, rows, fields) => {
|
db.query(query, (err, rows, fields) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
functions.download.requests(client);
|
functions.download.requests(client);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async pasta(pastaData, client) {
|
pasta(pastaData, client) {
|
||||||
const query = `INSERT INTO pastas (name, content) VALUES (${db.escape(pastaData.name)},${db.escape(pastaData.content)}) ON DUPLICATE KEY UPDATE content=${db.escape(pastaData.content)}`;
|
const query = `INSERT INTO pastas (name, content) VALUES (${db.escape(pastaData.name)},${db.escape(pastaData.content)})`;
|
||||||
await db.query(query, (err, rows, fields) => {
|
db.query(query, (err, rows, fields) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
functions.download.pastas(client);
|
functions.download.pastas(client);
|
||||||
});
|
});
|
||||||
return;
|
|
||||||
},
|
},
|
||||||
joint(content, client) {
|
joint(content, client) {
|
||||||
const query = `INSERT INTO joints (content) VALUES (${db.escape(content)})`;
|
const query = `INSERT INTO joints (content) VALUES (${db.escape(content)})`;
|
||||||
|
@ -415,9 +392,9 @@ const functions = {
|
||||||
functions.download.joints(client);
|
functions.download.joints(client);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async gif(gifData, client) {
|
gif(gifData, client) {
|
||||||
const query = `INSERT INTO gifs (name, embed_url) VALUES (${db.escape(gifData.name)}, ${db.escape(gifData.url)}) ON DUPLICATE KEY UPDATE embed_url=${db.escape(gifData.url)}`;
|
const query = `INSERT INTO gifs (name, embed_url) VALUES (${db.escape(gifData.name)}, ${db.escape(gifData.embed_url)})`;
|
||||||
await db.query(query, (err, rows, fields) => {
|
db.query(query, (err, rows, fields) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
functions.download.gifs(client);
|
functions.download.gifs(client);
|
||||||
});
|
});
|
||||||
|
@ -456,36 +433,6 @@ const functions = {
|
||||||
} else {
|
} else {
|
||||||
return 'Sorry, you don\'t have permission to do that.';
|
return 'Sorry, you don\'t have permission to do that.';
|
||||||
}
|
}
|
||||||
},
|
|
||||||
medicalAdvice(content, client) {
|
|
||||||
const query = `INSERT INTO medical_advice (content) VALUES (${db.escape(content)})`;
|
|
||||||
db.query(query, (err, rows, fields) => {
|
|
||||||
if (err) throw err;
|
|
||||||
functions.download.medicalAdvice(client);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
strain(interaction) {
|
|
||||||
const strain = db.escape(interaction.options.getString('name'));
|
|
||||||
const type = db.escape(interaction.options.getString('type'));
|
|
||||||
const effects = db.escape(( interaction.options.getString('effects') || 'Unkown' ));
|
|
||||||
const description = db.escape(( interaction.options.getString('description') || 'Unknown' ));
|
|
||||||
const flavor = db.escape(( interaction.options.getString('flavor') || 'Unknown' ));
|
|
||||||
const rating = db.escape(( interaction.options.getString('rating') || '3' ));
|
|
||||||
const strainQuery = `INSERT INTO strains (strain, type, effects, description, flavor, rating) VALUES (${strain}, ${type}, ${effects}, ${description}, ${flavor}, ${rating}) ON DUPLICATE KEY UPDATE strain=${db.escape(strain)}, type=${db.escape(type)}, effects=${db.escape(effects)}, description=${db.escape(description)}, flavor=${db.escape(flavor)}, rating=${db.escape(rating)}`;
|
|
||||||
console.log(strainQuery);
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
db.query(strainQuery, (err, rows, fields) => {
|
|
||||||
if (err) reject(err);
|
|
||||||
functions.download.strains(interaction.client);
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
})
|
|
||||||
},
|
|
||||||
openai(user, prompt, engine, tokens, usdc) {
|
|
||||||
const query = `INSERT INTO openai (user, prompt, engine, tokens, usdc) VALUES (${db.escape(user)}, ${db.escape(prompt)}, ${db.escape(engine)}, ${db.escape(tokens)}, ${db.escape(usdc)})`;
|
|
||||||
db.query(query, (err) => {
|
|
||||||
if (err) throw err;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
download: {
|
download: {
|
||||||
|
@ -503,9 +450,9 @@ const functions = {
|
||||||
functions.collections.pastas(rows, client);
|
functions.collections.pastas(rows, client);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async gifs(client) {
|
gifs(client) {
|
||||||
const query = 'SELECT * FROM gifs ORDER BY id ASC';
|
const query = 'SELECT * FROM gifs ORDER BY id ASC';
|
||||||
await db.query(query, (err, rows, fields) => {
|
db.query(query, (err, rows, fields) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
functions.collections.gifs(rows, client);
|
functions.collections.gifs(rows, client);
|
||||||
});
|
});
|
||||||
|
@ -517,11 +464,12 @@ const functions = {
|
||||||
functions.collections.joints(rows, client);
|
functions.collections.joints(rows, client);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
strain(strainName, interaction) {
|
strain(commandData, message) {
|
||||||
|
const { strainName } = commandData;
|
||||||
const query = `SELECT id, strain, type, effects, description, flavor, rating FROM strains WHERE strain = ${db.escape(strainName)}`;
|
const query = `SELECT id, strain, type, effects, description, flavor, rating FROM strains WHERE strain = ${db.escape(strainName)}`;
|
||||||
db.query(query, (err, rows, fields) => {
|
db.query(query, (err, rows, fields) => {
|
||||||
if (rows != undefined) {
|
if (rows != undefined) {
|
||||||
const strainInfo = {
|
commandData.strainInfo = {
|
||||||
id: `${rows[0].id}`,
|
id: `${rows[0].id}`,
|
||||||
strain: `${rows[0].strain}`,
|
strain: `${rows[0].strain}`,
|
||||||
type: `${rows[0].type}`,
|
type: `${rows[0].type}`,
|
||||||
|
@ -530,7 +478,7 @@ const functions = {
|
||||||
flavor: `${rows[0].flavor}`,
|
flavor: `${rows[0].flavor}`,
|
||||||
rating: `${rows[0].rating}`,
|
rating: `${rows[0].rating}`,
|
||||||
};
|
};
|
||||||
functions.embeds.strain(strainInfo, interaction);
|
functions.embeds.strain(commandData, message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -553,7 +501,12 @@ const functions = {
|
||||||
strain: {
|
strain: {
|
||||||
lookup(strainName, client) {
|
lookup(strainName, client) {
|
||||||
const strainSearcher = new FuzzySearch(client.strains.map(e => e.name));
|
const strainSearcher = new FuzzySearch(client.strains.map(e => e.name));
|
||||||
return strainSearcher.search(strainName).slice(0,25);
|
const name = strainSearcher.search(strainName)[0];
|
||||||
|
if (name != undefined) {
|
||||||
|
return name;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
submit(strainName) {
|
submit(strainName) {
|
||||||
const query = ``
|
const query = ``
|
||||||
|
@ -561,48 +514,6 @@ const functions = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
openAI: {
|
|
||||||
chatPrompt(userPrompt) {
|
|
||||||
return new Promise(async (resolve, reject) => {
|
|
||||||
const response = await openai.chat.completions.create({
|
|
||||||
messages: [{
|
|
||||||
role: 'user',
|
|
||||||
content: userPrompt
|
|
||||||
}],
|
|
||||||
model: strings.ai.chatModel
|
|
||||||
}).catch(e => {
|
|
||||||
reject(e);
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
resolve(response);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
imagePrompt(userPrompt, size, userId) {
|
|
||||||
return new Promise(async (resolve, reject) => {
|
|
||||||
try {
|
|
||||||
const response = await openai.createImage({
|
|
||||||
prompt: userPrompt,
|
|
||||||
size: size,
|
|
||||||
user: userId
|
|
||||||
});
|
|
||||||
resolve(response.data.data[0].url);
|
|
||||||
} catch (e) {
|
|
||||||
reject(e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
search: {
|
|
||||||
gifs(query, client) {
|
|
||||||
const gifSearcher = new FuzzySearch(client.gifs.map(element => element.name));
|
|
||||||
return gifSearcher.search(query).slice(0,25);
|
|
||||||
},
|
|
||||||
pastas(query, client) {
|
|
||||||
const pastaSearcher = new FuzzySearch(client.pastas.map(element => element.name));
|
|
||||||
return pastaSearcher.search(query).slice(0,25);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// Parent-Level functions (miscellaneuous)
|
// Parent-Level functions (miscellaneuous)
|
||||||
closeRequest(requestId, interaction) {
|
closeRequest(requestId, interaction) {
|
||||||
if (interaction.user.id == ownerId) {
|
if (interaction.user.id == ownerId) {
|
||||||
|
@ -622,7 +533,6 @@ const functions = {
|
||||||
},
|
},
|
||||||
spongebob(commandData) {
|
spongebob(commandData) {
|
||||||
let newText = '';
|
let newText = '';
|
||||||
let lastIsUpper = 0;
|
|
||||||
for (const letter of commandData.args) {
|
for (const letter of commandData.args) {
|
||||||
if (letter == ' ') {
|
if (letter == ' ') {
|
||||||
newText += letter;
|
newText += letter;
|
||||||
|
@ -630,97 +540,21 @@ const functions = {
|
||||||
}
|
}
|
||||||
if (letter == 'i' || letter == 'I') {
|
if (letter == 'i' || letter == 'I') {
|
||||||
newText += 'i';
|
newText += 'i';
|
||||||
lastIsUpper = 0;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (letter == 'l' || letter == 'L') {
|
if (letter == 'l' || letter == 'L') {
|
||||||
newText += 'L';
|
newText += 'L';
|
||||||
lastIsUpper = 1;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (lastIsUpper === 0) {
|
if (Math.random() > 0.5) {
|
||||||
newText += letter.toUpperCase();
|
newText += letter.toUpperCase();
|
||||||
lastIsUpper = 1;
|
|
||||||
} else {
|
} else {
|
||||||
newText += letter.toLowerCase();
|
newText += letter.toLowerCase();
|
||||||
lastIsUpper = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return newText + ' <:spongebob:1053398825965985822>';
|
return newText + ' <:spongebob:1053398825965985822>';
|
||||||
},
|
},
|
||||||
autoresponses: { // Specific responses for certain keywords in sent messages
|
|
||||||
checkForAll(messageContent) {
|
|
||||||
let responses = [];
|
|
||||||
if (this.bigDoinks(messageContent)) responses.push("bigDoinks");
|
|
||||||
if (this.ligma(messageContent)) responses.push("ligma");
|
|
||||||
if (this.ong(messageContent)) responses.push("ong");
|
|
||||||
if (this.fuckYou(messageContent)) responses.push("fuckYou");
|
|
||||||
return responses;
|
|
||||||
},
|
|
||||||
bigDoinks(messageContent) {
|
|
||||||
let count = 0;
|
|
||||||
const { keywords } = strings.autoresponses.bigDoinks;
|
|
||||||
keywords.forEach(e => {
|
|
||||||
if (messageContent.includes(e)) count++;
|
|
||||||
});
|
|
||||||
if (count === keywords.length) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
ligma(messageContent) {
|
|
||||||
let count = 0;
|
|
||||||
const { keywords } = strings.autoresponses.ligma;
|
|
||||||
keywords.forEach(e => {
|
|
||||||
if (messageContent.includes(e)) count++;
|
|
||||||
});
|
|
||||||
if (count > 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
ong(messageContent) {
|
|
||||||
let count = 0;
|
|
||||||
const { keywords } = strings.autoresponses.ong;
|
|
||||||
keywords.forEach(e => {
|
|
||||||
if (messageContent.includes(e)) count++;
|
|
||||||
});
|
|
||||||
if (count > 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fuckYou(messageContent) {
|
|
||||||
let count = 0;
|
|
||||||
const { keywords } = strings.autoresponses.fuckYou;
|
|
||||||
keywords.forEach(e => {
|
|
||||||
if (messageContent.includes(e)) count++;
|
|
||||||
});
|
|
||||||
if (count === keywords.length) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
send(message, responseType) {
|
|
||||||
const { responses } = strings.autoresponses[responseType];
|
|
||||||
const randomIndex = Math.floor(Math.random() * responses.length);
|
|
||||||
const response = responses[randomIndex];
|
|
||||||
try {
|
|
||||||
message.reply(response);
|
|
||||||
} catch(e) {
|
|
||||||
console.log(new Error(e));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
generateErrorId() {
|
|
||||||
const digitCount = 10;
|
|
||||||
const digits = [];
|
|
||||||
for (let i = 0; i < digitCount; i++) {
|
|
||||||
const randBase = Math.random();
|
|
||||||
const randNumRaw = randBase * 10;
|
|
||||||
const randNumRound = Math.floor(randNumRaw);
|
|
||||||
digits.push(randNumRound);
|
|
||||||
}
|
|
||||||
const errorId = digits.join("");
|
|
||||||
return errorId;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = functions;
|
module.exports = functions;
|
74
main.js
74
main.js
|
@ -7,15 +7,8 @@ const token = process.env.TOKEN;
|
||||||
const statusChannelId = process.env.statusChannelId;
|
const statusChannelId = process.env.statusChannelId;
|
||||||
|
|
||||||
// Discord.JS
|
// Discord.JS
|
||||||
const { Client, Intents } = require('discord.js');
|
const { Client } = require('discord.js-selfbot-v13');
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
intents: [
|
|
||||||
'GUILDS',
|
|
||||||
'GUILD_MESSAGES',
|
|
||||||
'GUILD_MESSAGE_REACTIONS',
|
|
||||||
'DIRECT_MESSAGES',
|
|
||||||
'DIRECT_MESSAGE_REACTIONS',
|
|
||||||
],
|
|
||||||
partials: [
|
partials: [
|
||||||
'CHANNEL',
|
'CHANNEL',
|
||||||
'MESSAGE',
|
'MESSAGE',
|
||||||
|
@ -27,14 +20,12 @@ const { MessageActionRow, MessageButton } = require('discord.js');
|
||||||
const fn = require('./functions.js');
|
const fn = require('./functions.js');
|
||||||
const config = require('./config.json');
|
const config = require('./config.json');
|
||||||
const strings = require('./strings.json');
|
const strings = require('./strings.json');
|
||||||
const { GifData } = require('./CustomModules/NodBot.js');
|
|
||||||
const isDev = process.env.isDev;
|
const isDev = process.env.isDev;
|
||||||
|
|
||||||
client.once('ready', () => {
|
client.once('ready', () => {
|
||||||
fn.collections.slashCommands(client);
|
fn.collections.slashCommands(client);
|
||||||
fn.collections.dotCommands(client);
|
fn.collections.dotCommands(client);
|
||||||
fn.collections.setvalidCommands(client);
|
fn.collections.setvalidCommands(client);
|
||||||
fn.collections.roaches(client);
|
|
||||||
fn.download.gifs(client);
|
fn.download.gifs(client);
|
||||||
fn.download.pastas(client);
|
fn.download.pastas(client);
|
||||||
fn.download.joints(client);
|
fn.download.joints(client);
|
||||||
|
@ -110,11 +101,10 @@ client.on('interactionCreate', async interaction => {
|
||||||
interaction.update(strings.temp.gifs[newIndex].embed_url);
|
interaction.update(strings.temp.gifs[newIndex].embed_url);
|
||||||
break;
|
break;
|
||||||
case 'confirmGif':
|
case 'confirmGif':
|
||||||
// const gifData = {
|
const gifData = {
|
||||||
// name: strings.temp.gifName,
|
name: strings.temp.gifName,
|
||||||
// url: strings.temp.gifs[strings.temp.gifIndex].embed_url,
|
embed_url: strings.temp.gifs[strings.temp.gifIndex].embed_url,
|
||||||
// };
|
};
|
||||||
const gifData = new GifData().setInfo(strings.temp.gifName, strings.temp.gifs[strings.temp.gifIndex].embed_url);
|
|
||||||
fn.upload.gif(gifData, client);
|
fn.upload.gif(gifData, client);
|
||||||
interaction.update({ content: `I've saved the GIF as ${gifData.name}.gif`, components: [] });
|
interaction.update({ content: `I've saved the GIF as ${gifData.name}.gif`, components: [] });
|
||||||
fn.download.gifs(interaction.client);
|
fn.download.gifs(interaction.client);
|
||||||
|
@ -179,39 +169,14 @@ client.on('interactionCreate', async interaction => {
|
||||||
|
|
||||||
// Handle autocomplete requests
|
// Handle autocomplete requests
|
||||||
if (interaction.isAutocomplete()) {
|
if (interaction.isAutocomplete()) {
|
||||||
switch (interaction.commandName) {
|
if (interaction.commandName == 'strain') {
|
||||||
case 'strain':
|
const searchString = interaction.options.getFocused();
|
||||||
const searchString = interaction.options.getFocused();
|
const choices = fn.weed.strain.lookup(searchString, interaction.client);
|
||||||
const choices = fn.weed.strain.lookup(searchString, interaction.client);
|
await interaction.respond(
|
||||||
await interaction.respond(
|
choices.map(choice => ({ name: choice, value: choice }))
|
||||||
choices.map(choice => ({ name: choice, value: choice }))
|
)
|
||||||
);
|
} else {
|
||||||
break;
|
return;
|
||||||
case "edit":
|
|
||||||
//TODO
|
|
||||||
switch (interaction.options.getSubcommand()) {
|
|
||||||
case 'gif':
|
|
||||||
const gifQuery = interaction.options.getFocused();
|
|
||||||
const gifChoices = fn.search.gifs(gifQuery, interaction.client);
|
|
||||||
await interaction.respond(
|
|
||||||
gifChoices.map(choice => ({ name: choice, value: choice }))
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case 'pasta':
|
|
||||||
const pastaQuery = interaction.options.getFocused();
|
|
||||||
const pastaChoices = fn.search.pastas(pastaQuery, interaction.client);
|
|
||||||
await interaction.respond(
|
|
||||||
pastaChoices.map(choice => ({ name: choice, value: choice }))
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -220,13 +185,16 @@ client.on('interactionCreate', async interaction => {
|
||||||
client.on('messageCreate', message => {
|
client.on('messageCreate', message => {
|
||||||
// Some basic checking to prevent running unnecessary code
|
// Some basic checking to prevent running unnecessary code
|
||||||
if (message.author.bot) return;
|
if (message.author.bot) return;
|
||||||
|
if (message.author.id == client.user.id) return;
|
||||||
|
|
||||||
// Automatic Responses, will respond if any message contains the keyword(s), excluding self-messages
|
// Wildcard Responses, will respond if any message contains the trigger word(s), excluding self-messages
|
||||||
const lowerContent = message.content.toLowerCase();
|
const lowerContent = message.content.toLowerCase();
|
||||||
const autoresponses = fn.autoresponses.checkForAll(lowerContent);
|
if (lowerContent.includes('big') && lowerContent.includes('doinks')) message.reply('gang.');
|
||||||
autoresponses.forEach(e => {
|
if (lowerContent.includes('ligma')) message.reply('ligma balls, goteem');
|
||||||
fn.autoresponses.send(message, e);
|
if (lowerContent.includes('frfr') || lowerContent.includes('fr fr') || lowerContent.includes('bussin') || lowerContent.includes(' ong') || lowerContent.startsWith('ong')) {
|
||||||
});
|
const randIndex = Math.floor(Math.random() * strings.capbacks.length);
|
||||||
|
message.reply(strings.capbacks[randIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
// Break the message down into its components and analyze it
|
// Break the message down into its components and analyze it
|
||||||
const commandData = fn.dot.getCommandData(message);
|
const commandData = fn.dot.getCommandData(message);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "nodbot",
|
"name": "nodbot",
|
||||||
"version": "3.2.3",
|
"version": "3.1.0",
|
||||||
"description": "Nods and Nod Accessories, now with ChatGPT!",
|
"description": "Nods and Nod Accessories.",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/builders": "^0.16.0",
|
"@discordjs/builders": "^0.16.0",
|
||||||
|
@ -9,10 +9,10 @@
|
||||||
"axios": "^0.21.4",
|
"axios": "^0.21.4",
|
||||||
"discord-api-types": "^0.22.0",
|
"discord-api-types": "^0.22.0",
|
||||||
"discord.js": "^13.15.1",
|
"discord.js": "^13.15.1",
|
||||||
|
"discord.js-selfbot-v13": "^2.14.0",
|
||||||
"dotenv": "^10.0.0",
|
"dotenv": "^10.0.0",
|
||||||
"fuzzy-search": "^3.2.1",
|
"fuzzy-search": "^3.2.1",
|
||||||
"mysql": "^2.18.1",
|
"mysql": "^2.18.1",
|
||||||
"openai": "^4.12.0",
|
|
||||||
"tenorjs": "^1.0.10"
|
"tenorjs": "^1.0.10"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|
|
@ -1,110 +0,0 @@
|
||||||
const tenor = require('tenorjs').client({
|
|
||||||
'Key': process.env.tenorAPIKey, // https://tenor.com/developer/keyregistration
|
|
||||||
'Filter': 'off', // "off", "low", "medium", "high", not case sensitive
|
|
||||||
'Locale': 'en_US',
|
|
||||||
'MediaFilter': 'minimal',
|
|
||||||
'DateFormat': 'D/MM/YYYY - H:mm:ss A',
|
|
||||||
});
|
|
||||||
|
|
||||||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
|
||||||
const { MessageActionRow, MessageButton } = require('discord.js');
|
|
||||||
const { GifData, PastaData } = require('../CustomModules/NodBot');
|
|
||||||
const fn = require('../functions.js');
|
|
||||||
const strings = require('../strings.json');
|
|
||||||
const { emoji } = strings;
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
data: new SlashCommandBuilder()
|
|
||||||
.setName('edit')
|
|
||||||
.setDescription('Edit content in Nodbot\'s database.')
|
|
||||||
// GIF
|
|
||||||
.addSubcommand(subcommand =>
|
|
||||||
subcommand
|
|
||||||
.setName('gif')
|
|
||||||
.setDescription('Edit a GIF URL')
|
|
||||||
.addStringOption(option =>
|
|
||||||
option
|
|
||||||
.setName('name')
|
|
||||||
.setDescription('The name of the GIF to edit')
|
|
||||||
.setRequired(true)
|
|
||||||
.setAutocomplete(true)
|
|
||||||
)
|
|
||||||
.addStringOption(option =>
|
|
||||||
option
|
|
||||||
.setName('url')
|
|
||||||
.setDescription('The new URL')
|
|
||||||
.setRequired(true)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
// Pasta
|
|
||||||
.addSubcommand(subcommand =>
|
|
||||||
subcommand
|
|
||||||
.setName('pasta')
|
|
||||||
.setDescription('Edit a copypasta\'s content')
|
|
||||||
.addStringOption(option =>
|
|
||||||
option
|
|
||||||
.setName('name')
|
|
||||||
.setDescription('The name of the copypasta')
|
|
||||||
.setRequired(true)
|
|
||||||
.setAutocomplete(true)
|
|
||||||
)
|
|
||||||
.addStringOption(option =>
|
|
||||||
option
|
|
||||||
.setName('content')
|
|
||||||
.setDescription('The new content of the copypasta')
|
|
||||||
.setRequired(true)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
async execute(interaction) {
|
|
||||||
await interaction.deferReply({ ephemeral: true });
|
|
||||||
try {
|
|
||||||
// Code Here...
|
|
||||||
const subcommand = interaction.options.getSubcommand();
|
|
||||||
switch (subcommand) {
|
|
||||||
// GIF
|
|
||||||
case "gif":
|
|
||||||
//TODO
|
|
||||||
await this.editGif(interaction, interaction.options.getString('name'), interaction.options.getString('url'));
|
|
||||||
break;
|
|
||||||
// Joint
|
|
||||||
case "joint":
|
|
||||||
//TODO
|
|
||||||
break;
|
|
||||||
// MD
|
|
||||||
case "md":
|
|
||||||
//TODO
|
|
||||||
break;
|
|
||||||
// Pasta
|
|
||||||
case "pasta":
|
|
||||||
//TODO
|
|
||||||
await this.editPasta(interaction, interaction.options.getString('name'), interaction.options.getString('content'));
|
|
||||||
break;
|
|
||||||
// Strain
|
|
||||||
case "strain":
|
|
||||||
//TODO
|
|
||||||
break;
|
|
||||||
break;
|
|
||||||
// Default
|
|
||||||
default:
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
const errorId = fn.generateErrorId();
|
|
||||||
console.error(`${errorId}: err`);
|
|
||||||
await interaction.editReply(`Sorry, an error has occured. Error ID: ${errorId}`);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async editGif(interaction, name, url) {
|
|
||||||
const gifData = new GifData().setInfo(name, url);
|
|
||||||
await fn.upload.gif(gifData, interaction.client);
|
|
||||||
await fn.download.gifs(interaction.client);
|
|
||||||
await interaction.editReply(`I've updated ${gifData.name}.gif`);
|
|
||||||
},
|
|
||||||
async editPasta(interaction, name, content) {
|
|
||||||
const pastaData = new PastaData().setInfo(name, content);
|
|
||||||
await fn.upload.pasta(pastaData, interaction.client);
|
|
||||||
await fn.download.gifs(interaction.client);
|
|
||||||
await interaction.editReply(`I've updated ${name}.pasta`);
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -11,26 +11,23 @@ module.exports = {
|
||||||
interaction.reply('For some reason I don\'t have access to the collection of gifs. Sorry about that!');
|
interaction.reply('For some reason I don\'t have access to the collection of gifs. Sorry about that!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// const gifsMap = interaction.client.gifs.map(e => {e.name, e.url});
|
const gifsMap = interaction.client.gifs.map(e => {
|
||||||
// const commandData = {
|
return {
|
||||||
// gifs: [],
|
id: e.id,
|
||||||
// command: 'gifs',
|
name: e.name,
|
||||||
// author: interaction.user.tag,
|
};
|
||||||
// };
|
|
||||||
// for (const row of gifsMap) {
|
|
||||||
// commandData.gifs.push({
|
|
||||||
// id: row.id,
|
|
||||||
// name: row.name,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
let gifList = [];
|
|
||||||
interaction.client.gifs.forEach(element => {
|
|
||||||
gifList.push(`[${element.name}](${element.url})`);
|
|
||||||
});
|
});
|
||||||
const commandData = {
|
const commandData = {
|
||||||
command: "/gifs",
|
gifs: [],
|
||||||
author: interaction.member.displayName
|
command: 'gifs',
|
||||||
|
author: interaction.user.tag,
|
||||||
};
|
};
|
||||||
interaction.reply(fn.embeds.gifs(commandData, gifList));
|
for (const row of gifsMap) {
|
||||||
|
commandData.gifs.push({
|
||||||
|
id: row.id,
|
||||||
|
name: row.name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
interaction.reply(fn.embeds.gifs(commandData));
|
||||||
},
|
},
|
||||||
};
|
};
|
|
@ -1,240 +0,0 @@
|
||||||
const tenor = require('tenorjs').client({
|
|
||||||
'Key': process.env.tenorAPIKey, // https://tenor.com/developer/keyregistration
|
|
||||||
'Filter': 'off', // "off", "low", "medium", "high", not case sensitive
|
|
||||||
'Locale': 'en_US',
|
|
||||||
'MediaFilter': 'minimal',
|
|
||||||
'DateFormat': 'D/MM/YYYY - H:mm:ss A',
|
|
||||||
});
|
|
||||||
|
|
||||||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
|
||||||
const { MessageActionRow, MessageButton } = require('discord.js');
|
|
||||||
const fn = require('../functions.js');
|
|
||||||
const strings = require('../strings.json');
|
|
||||||
const { GifData } = require('../CustomModules/NodBot.js');
|
|
||||||
const { emoji } = strings;
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
data: new SlashCommandBuilder()
|
|
||||||
.setName('save')
|
|
||||||
.setDescription('Save content to Nodbot\'s database.')
|
|
||||||
// GIF Search
|
|
||||||
.addSubcommand(subcommand =>
|
|
||||||
subcommand
|
|
||||||
.setName('gifsearch')
|
|
||||||
.setDescription('Search Tenor for a GIF.')
|
|
||||||
.addStringOption(option =>
|
|
||||||
option
|
|
||||||
.setName('query')
|
|
||||||
.setDescription('Search Query')
|
|
||||||
.setRequired(true))
|
|
||||||
.addStringOption(option =>
|
|
||||||
option
|
|
||||||
.setName('name')
|
|
||||||
.setDescription('What to save the gif as')
|
|
||||||
.setRequired(true))
|
|
||||||
)
|
|
||||||
// GIF URL
|
|
||||||
.addSubcommand(subcommand =>
|
|
||||||
subcommand
|
|
||||||
.setName('gifurl')
|
|
||||||
.setDescription('Specify a URL to save.')
|
|
||||||
.addStringOption(option =>
|
|
||||||
option
|
|
||||||
.setName('url')
|
|
||||||
.setDescription('URL Link to the GIF')
|
|
||||||
.setRequired(true))
|
|
||||||
.addStringOption(option =>
|
|
||||||
option
|
|
||||||
.setName('name')
|
|
||||||
.setDescription('What to save the gif as')
|
|
||||||
.setRequired(true))
|
|
||||||
)
|
|
||||||
// Joint
|
|
||||||
.addSubcommand(subcommand =>
|
|
||||||
subcommand
|
|
||||||
.setName('joint')
|
|
||||||
.setDescription('Roll a joint and stash it in the database.')
|
|
||||||
.addStringOption(option =>
|
|
||||||
option
|
|
||||||
.setName('joint-content')
|
|
||||||
.setDescription('Phrase to save')
|
|
||||||
.setRequired(true)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
// MD
|
|
||||||
.addSubcommand(subcommand =>
|
|
||||||
subcommand
|
|
||||||
.setName('md')
|
|
||||||
.setDescription('Add medical advice to the database.')
|
|
||||||
.addStringOption(option =>
|
|
||||||
option
|
|
||||||
.setName('advice-content')
|
|
||||||
.setDescription('Advice to save')
|
|
||||||
.setRequired(true)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
// Pasta
|
|
||||||
.addSubcommand(subcommand =>
|
|
||||||
subcommand
|
|
||||||
.setName('pasta')
|
|
||||||
.setDescription('Save a copypasta to the database.')
|
|
||||||
.addStringOption(option =>
|
|
||||||
option
|
|
||||||
.setName('pasta-name')
|
|
||||||
.setDescription('Title of the copypasta')
|
|
||||||
.setRequired(true)
|
|
||||||
)
|
|
||||||
.addStringOption(option =>
|
|
||||||
option
|
|
||||||
.setName('pasta-content')
|
|
||||||
.setDescription('Content of the copypasta')
|
|
||||||
.setRequired(true)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
// Strain
|
|
||||||
.addSubcommand(subcommand =>
|
|
||||||
subcommand
|
|
||||||
.setName('strain')
|
|
||||||
.setDescription('Store a new Strain in the database!')
|
|
||||||
.addStringOption(option =>
|
|
||||||
option
|
|
||||||
.setName('name')
|
|
||||||
.setDescription('Name of the Strain')
|
|
||||||
.setRequired(true))
|
|
||||||
.addStringOption(option =>
|
|
||||||
option
|
|
||||||
.setName('type')
|
|
||||||
.setDescription('Indica/Sativa/Hybrid')
|
|
||||||
.setRequired(true)
|
|
||||||
.addChoices(
|
|
||||||
{ name: "Indica", value: "Indica" },
|
|
||||||
{ name: "Hybrid", value: "Hybrid" },
|
|
||||||
{ name: "Sativa", value: "Sativa" }
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.addStringOption(option =>
|
|
||||||
option
|
|
||||||
.setName('effects')
|
|
||||||
.setDescription('The effects given by the strain')
|
|
||||||
.setRequired(false))
|
|
||||||
.addStringOption(option =>
|
|
||||||
option
|
|
||||||
.setName('flavor')
|
|
||||||
.setDescription('Flavor notes')
|
|
||||||
.setRequired(false))
|
|
||||||
.addStringOption(option =>
|
|
||||||
option
|
|
||||||
.setName('rating')
|
|
||||||
.setDescription('Number of stars')
|
|
||||||
.setRequired(false))
|
|
||||||
.addStringOption(option =>
|
|
||||||
option
|
|
||||||
.setName('description')
|
|
||||||
.setDescription('Description of the strain')
|
|
||||||
.setRequired(false))
|
|
||||||
),
|
|
||||||
async execute(interaction) {
|
|
||||||
await interaction.deferReply({ ephemeral: true });
|
|
||||||
try {
|
|
||||||
// Code Here...
|
|
||||||
const subcommand = interaction.options.getSubcommand();
|
|
||||||
switch (subcommand) {
|
|
||||||
// GIF Search
|
|
||||||
case "gifsearch":
|
|
||||||
// TODO Check on option names
|
|
||||||
// Previous GIF button
|
|
||||||
const prevButton = new MessageButton().setCustomId('prevGif').setLabel('Previous GIF').setStyle('SECONDARY').setDisabled(true);
|
|
||||||
// Confirm GIF Button
|
|
||||||
const confirmButton = new MessageButton().setCustomId('confirmGif').setLabel('Confirm').setStyle('PRIMARY');
|
|
||||||
// Next GIF Button
|
|
||||||
const nextButton = new MessageButton().setCustomId('nextGif').setLabel('Next GIF').setStyle('SECONDARY');
|
|
||||||
// Cancel Button
|
|
||||||
const cancelButton = new MessageButton().setCustomId('cancelGif').setLabel('Cancel').setStyle('DANGER');
|
|
||||||
// Put all the above into an ActionRow to be sent as a component of the reply
|
|
||||||
const actionRow = new MessageActionRow().addComponents(prevButton, confirmButton, nextButton, cancelButton);
|
|
||||||
|
|
||||||
// Get the query
|
|
||||||
const query = interaction.options.getString('query');
|
|
||||||
strings.temp.gifName = interaction.options.getString('name').toLowerCase();
|
|
||||||
|
|
||||||
// Search Tenor for the GIF
|
|
||||||
tenor.Search.Query(query, '10').then(res => {
|
|
||||||
strings.temp.gifs = [];
|
|
||||||
strings.temp.gifIndex = 0;
|
|
||||||
strings.temp.gifLimit = res.length - 1;
|
|
||||||
strings.temp.gifUserId = interaction.user.id;
|
|
||||||
|
|
||||||
if (res[0] == undefined) {
|
|
||||||
interaction.editReply('Sorry I was unable to find a GIF of ' + query);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (const row of res) {
|
|
||||||
strings.temp.gifs.push({
|
|
||||||
embed_url: row.media_formats.gif.url,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
interaction.editReply({ content: strings.temp.gifs[0].embed_url, components: [actionRow], ephemeral: true });
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
// GIF URL
|
|
||||||
case "gifurl":
|
|
||||||
//TODO Check on option names
|
|
||||||
// const gifData = {
|
|
||||||
// name: interaction.options.getString('name').toLowerCase(),
|
|
||||||
// url: interaction.options.getString('url'),
|
|
||||||
// };
|
|
||||||
const gifData = new GifData().setInfo(interaction.options.getString('name').toLowerCase(), interaction.options.getString('url'));
|
|
||||||
fn.upload.gif(gifData, interaction.client);
|
|
||||||
interaction.editReply({ content: `I've saved the GIF as ${gifData.name}.gif`, ephemeral: true });
|
|
||||||
fn.download.gifs(interaction.client);
|
|
||||||
break;
|
|
||||||
// Joint
|
|
||||||
case "joint":
|
|
||||||
//TODO
|
|
||||||
fn.upload.joint(interaction.options.getString('joint-content'), interaction.client);
|
|
||||||
interaction.editReply({ content: `The joint has been rolled${emoji.joint}`, ephemeral: true });
|
|
||||||
break;
|
|
||||||
// MD
|
|
||||||
case "md":
|
|
||||||
//TODO
|
|
||||||
fn.upload.medicalAdvice(interaction.options.getString('advice-content'), interaction.client);
|
|
||||||
interaction.editReply({ content: `The advice has been saved!`, ephemeral: true });
|
|
||||||
break;
|
|
||||||
// Pasta
|
|
||||||
case "pasta":
|
|
||||||
//TODO
|
|
||||||
const pastaData = {
|
|
||||||
name: interaction.options.getString('pasta-name').toLowerCase(),
|
|
||||||
content: interaction.options.getString('pasta-content'),
|
|
||||||
};
|
|
||||||
await fn.upload.pasta(pastaData, interaction.client);
|
|
||||||
interaction.editReply({content: `The copypasta has been saved as ${pastaData.name}.pasta`, ephemeral: true });
|
|
||||||
break;
|
|
||||||
// Strain
|
|
||||||
case "strain":
|
|
||||||
//TODO
|
|
||||||
fn.upload.strain(interaction).then(res => {
|
|
||||||
interaction.editReply({
|
|
||||||
content: `The strain information has been saved. (${interaction.options.getString('name')})`,
|
|
||||||
ephemeral: true
|
|
||||||
});
|
|
||||||
}).catch(err => {
|
|
||||||
console.log(`E: ${err}`);
|
|
||||||
interaction.editReply({
|
|
||||||
content: 'There was a problem saving the strain.',
|
|
||||||
ephemeral: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
// Default
|
|
||||||
default:
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
const errorId = fn.generateErrorId();
|
|
||||||
console.error(`${errorId}: err`);
|
|
||||||
await interaction.editReply(`Sorry, an error has occured. Error ID: ${errorId}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
const tenor = require('tenorjs').client({
|
||||||
|
'Key': process.env.tenorAPIKey, // https://tenor.com/developer/keyregistration
|
||||||
|
'Filter': 'off', // "off", "low", "medium", "high", not case sensitive
|
||||||
|
'Locale': 'en_US',
|
||||||
|
'MediaFilter': 'minimal',
|
||||||
|
'DateFormat': 'D/MM/YYYY - H:mm:ss A',
|
||||||
|
});
|
||||||
|
|
||||||
|
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||||
|
const { MessageActionRow, MessageButton } = require('discord.js');
|
||||||
|
const fn = require('../functions.js');
|
||||||
|
const strings = require('../strings.json');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
data: new SlashCommandBuilder()
|
||||||
|
.setName('savegif')
|
||||||
|
.setDescription('Save a GIF to Nodbot\'s database.')
|
||||||
|
.addSubcommand(subcommand =>
|
||||||
|
subcommand
|
||||||
|
.setName('searchgif')
|
||||||
|
.setDescription('Search Tenor for a GIF.')
|
||||||
|
.addStringOption(option =>
|
||||||
|
option.setName('query')
|
||||||
|
.setDescription('Search Query')
|
||||||
|
.setRequired(true))
|
||||||
|
.addStringOption(option =>
|
||||||
|
option.setName('name')
|
||||||
|
.setDescription('What to save the gif as')
|
||||||
|
.setRequired(true))
|
||||||
|
)
|
||||||
|
.addSubcommand(subcommand =>
|
||||||
|
subcommand
|
||||||
|
.setName('enterurl')
|
||||||
|
.setDescription('Specify a URL to save.')
|
||||||
|
.addStringOption(option =>
|
||||||
|
option
|
||||||
|
.setName('url')
|
||||||
|
.setDescription('URL Link to the GIF')
|
||||||
|
.setRequired(true))
|
||||||
|
.addStringOption(option =>
|
||||||
|
option.setName('name')
|
||||||
|
.setDescription('What to save the gif as')
|
||||||
|
.setRequired(true))
|
||||||
|
),
|
||||||
|
async execute(interaction) {
|
||||||
|
if (interaction.options.getSubcommand() == 'searchgif') {
|
||||||
|
// Previous GIF button
|
||||||
|
const prevButton = new MessageButton().setCustomId('prevGif').setLabel('Previous GIF').setStyle('SECONDARY').setDisabled(true);
|
||||||
|
// Confirm GIF Button
|
||||||
|
const confirmButton = new MessageButton().setCustomId('confirmGif').setLabel('Confirm').setStyle('PRIMARY');
|
||||||
|
// Next GIF Button
|
||||||
|
const nextButton = new MessageButton().setCustomId('nextGif').setLabel('Next GIF').setStyle('SECONDARY');
|
||||||
|
// Cancel Button
|
||||||
|
const cancelButton = new MessageButton().setCustomId('cancelGif').setLabel('Cancel').setStyle('DANGER');
|
||||||
|
// Put all the above into an ActionRow to be sent as a component of the reply
|
||||||
|
const actionRow = new MessageActionRow().addComponents(prevButton, confirmButton, nextButton, cancelButton);
|
||||||
|
|
||||||
|
// Get the query
|
||||||
|
const query = interaction.options.getString('query');
|
||||||
|
strings.temp.gifName = interaction.options.getString('name').toLowerCase();
|
||||||
|
|
||||||
|
// Search Tenor for the GIF
|
||||||
|
tenor.Search.Query(query, '10').then(res => {
|
||||||
|
strings.temp.gifs = [];
|
||||||
|
strings.temp.gifIndex = 0;
|
||||||
|
strings.temp.gifLimit = res.length - 1;
|
||||||
|
strings.temp.gifUserId = interaction.user.id;
|
||||||
|
|
||||||
|
if (res[0] == undefined) {
|
||||||
|
interaction.reply('Sorry I was unable to find a GIF of ' + query);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (const row of res) {
|
||||||
|
strings.temp.gifs.push({
|
||||||
|
embed_url: row.media[0].gif.url,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
interaction.reply({ content: strings.temp.gifs[0].embed_url, components: [actionRow], ephemeral: true });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (interaction.options.getSubcommand() == 'enterurl') {
|
||||||
|
const gifData = {
|
||||||
|
name: interaction.options.getString('name'),
|
||||||
|
embed_url: interaction.options.getString('url'),
|
||||||
|
};
|
||||||
|
fn.upload.gif(gifData, interaction.client);
|
||||||
|
interaction.reply({ content: `I've saved the GIF as ${gifData.name}.gif`, ephemeral: true });
|
||||||
|
fn.download.gifs(interaction.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
};
|
|
@ -0,0 +1,17 @@
|
||||||
|
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||||
|
const fn = require('../functions.js');
|
||||||
|
const { emoji } = require('../strings.json');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
data: new SlashCommandBuilder()
|
||||||
|
.setName('savejoint')
|
||||||
|
.setDescription('Save a phrase for /joint!')
|
||||||
|
.addStringOption(option =>
|
||||||
|
option.setName('joint-content')
|
||||||
|
.setDescription('What is the phrase?')
|
||||||
|
.setRequired(true)),
|
||||||
|
async execute(interaction) {
|
||||||
|
fn.upload.joint(interaction.options.getString('joint-content'), interaction.client);
|
||||||
|
interaction.reply({ content: `The joint has been rolled${emoji.joint}`, ephemeral: true });
|
||||||
|
},
|
||||||
|
};
|
|
@ -0,0 +1,17 @@
|
||||||
|
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||||
|
const fn = require('../functions.js');
|
||||||
|
// const { emoji } = require('../strings.json');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
data: new SlashCommandBuilder()
|
||||||
|
.setName('savemd')
|
||||||
|
.setDescription('Add medical advice to NodBot\'s Database!')
|
||||||
|
.addStringOption(option =>
|
||||||
|
option.setName('advice-content')
|
||||||
|
.setDescription('What is the advice?')
|
||||||
|
.setRequired(true)),
|
||||||
|
async execute(interaction) {
|
||||||
|
fn.upload.medicalAdvice(interaction.options.getString('advice-content'), interaction.client);
|
||||||
|
interaction.reply({ content: `The advice has been saved!`, ephemeral: true });
|
||||||
|
},
|
||||||
|
};
|
|
@ -0,0 +1,24 @@
|
||||||
|
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||||
|
const fn = require('../functions.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
data: new SlashCommandBuilder()
|
||||||
|
.setName('savepasta')
|
||||||
|
.setDescription('Save a copypasta!')
|
||||||
|
.addStringOption(option =>
|
||||||
|
option.setName('pasta-name')
|
||||||
|
.setDescription('What should the name of the copypasta be?')
|
||||||
|
.setRequired(true))
|
||||||
|
.addStringOption(option =>
|
||||||
|
option.setName('pasta-content')
|
||||||
|
.setDescription('What is the content of the copypasta?')
|
||||||
|
.setRequired(true)),
|
||||||
|
async execute(interaction) {
|
||||||
|
const pastaData = {
|
||||||
|
name: interaction.options.getString('pasta-name'),
|
||||||
|
content: interaction.options.getString('pasta-content'),
|
||||||
|
};
|
||||||
|
fn.upload.pasta(pastaData, interaction.client);
|
||||||
|
interaction.reply({content: `The copypasta has been saved as ${pastaData.name}.pasta`, ephemeral: true });
|
||||||
|
},
|
||||||
|
};
|
|
@ -0,0 +1,54 @@
|
||||||
|
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||||
|
const fn = require('../functions.js');
|
||||||
|
const { emoji } = require('../strings.json');
|
||||||
|
|
||||||
|
// Strain Name | Type | Effects | Flavor | Rating | Description
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
data: new SlashCommandBuilder()
|
||||||
|
.setName('savestrain')
|
||||||
|
.setDescription('Store a new Strain in the database!')
|
||||||
|
.addStringOption(option =>
|
||||||
|
option.setName('name')
|
||||||
|
.setDescription('Name of the Strain')
|
||||||
|
.setRequired(true))
|
||||||
|
.addStringOption(option =>
|
||||||
|
option.setName('type')
|
||||||
|
.setDescription('Indica/Sativa/Hybrid')
|
||||||
|
.setRequired(true)
|
||||||
|
.addChoices(
|
||||||
|
{ name: "Indica", value: "Indica" },
|
||||||
|
{ name: "Hybrid", value: "Hybrid" },
|
||||||
|
{ name: "Sativa", value: "Sativa" }
|
||||||
|
))
|
||||||
|
.addStringOption(option =>
|
||||||
|
option.setName('effects')
|
||||||
|
.setDescription('The effects given by the strain')
|
||||||
|
.setRequired(false))
|
||||||
|
.addStringOption(option =>
|
||||||
|
option.setName('flavor')
|
||||||
|
.setDescription('Flavor notes')
|
||||||
|
.setRequired(false))
|
||||||
|
.addStringOption(option =>
|
||||||
|
option.setName('rating')
|
||||||
|
.setDescription('Number of stars')
|
||||||
|
.setRequired(false))
|
||||||
|
.addStringOption(option =>
|
||||||
|
option.setName('description')
|
||||||
|
.setDescription('Description of the strain')
|
||||||
|
.setRequired(false)),
|
||||||
|
async execute(interaction) {
|
||||||
|
fn.upload.strain(interaction).then(res => {
|
||||||
|
interaction.reply({
|
||||||
|
content: `The strain information has been saved. (${interaction.options.getString('name')})`,
|
||||||
|
ephemeral: true
|
||||||
|
});
|
||||||
|
}).catch(err => {
|
||||||
|
console.log(`E: ${err}`);
|
||||||
|
interaction.reply({
|
||||||
|
content: 'There was a problem saving the strain.',
|
||||||
|
ephemeral: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
74
strings.json
74
strings.json
|
@ -14,71 +14,13 @@
|
||||||
"urls": {
|
"urls": {
|
||||||
"avatar": "https://cdn.discordapp.com/avatars/513184762073055252/12227aa23a06d5178853e59b72c7487b.webp?size=128"
|
"avatar": "https://cdn.discordapp.com/avatars/513184762073055252/12227aa23a06d5178853e59b72c7487b.webp?size=128"
|
||||||
},
|
},
|
||||||
"costs": {
|
"capbacks": [
|
||||||
"gpt": {
|
"on god?!",
|
||||||
"gpt-3.5-turbo": 0.2
|
"fr fr?!",
|
||||||
},
|
"no cap?!",
|
||||||
"dalle": {
|
"no cap fr",
|
||||||
"256x256": 1.6,
|
"bussin fr, no cap",
|
||||||
"512x512": 1.8,
|
"ongggg no :billed_cap: fr fr"
|
||||||
"1024x1024": 2.0
|
],
|
||||||
}
|
|
||||||
},
|
|
||||||
"ai": {
|
|
||||||
"chatModel": "gpt-3.5-turbo",
|
|
||||||
"chatPromptCentsPer": 0.15,
|
|
||||||
"chatPromptUnits": 1000,
|
|
||||||
"chatResCentsPer": 0.2,
|
|
||||||
"chatResUnits": 1000
|
|
||||||
},
|
|
||||||
"autoresponses": {
|
|
||||||
"bigDoinks": {
|
|
||||||
"keywords": ["big", "doinks"],
|
|
||||||
"responses": [
|
|
||||||
"<:bigdoinks:1053706618853924905> Gang.",
|
|
||||||
"<:bigdoinks:1053706618853924905> Out here in Amish",
|
|
||||||
"<:bigdoinks:1053706618853924905> Out here in Amish, smoking Big Doinks in Amish... Gang."
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ligma": {
|
|
||||||
"keywords": ["ligma"],
|
|
||||||
"responses": [
|
|
||||||
"ligma balls lmao gottem",
|
|
||||||
"ligma balls ahaha",
|
|
||||||
"https://tenor.com/view/ligma-balls-gif-12236083",
|
|
||||||
"<:deadmonkey:1139186312444911707>"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ong": {
|
|
||||||
"keywords": [
|
|
||||||
"frfr",
|
|
||||||
"fr fr",
|
|
||||||
"bussin",
|
|
||||||
"no cap",
|
|
||||||
" ong "
|
|
||||||
],
|
|
||||||
"responses": [
|
|
||||||
"on god?!",
|
|
||||||
"fr fr?!",
|
|
||||||
"no cap?!",
|
|
||||||
"no cap fr",
|
|
||||||
"bussin fr, no cap",
|
|
||||||
"ongggg no :billed_cap: fr fr"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"fuckYou": {
|
|
||||||
"keywords": [
|
|
||||||
"fuck",
|
|
||||||
"nodbot"
|
|
||||||
],
|
|
||||||
"responses": [
|
|
||||||
"no u",
|
|
||||||
"go fuck yourself",
|
|
||||||
"why does everyone hate me :sob:",
|
|
||||||
"<:kms:1253790048696926298>",
|
|
||||||
"Eat a bag of dicks"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"temp": {}
|
"temp": {}
|
||||||
}
|
}
|
Loading…
Reference in New Issue