Compare commits
44 Commits
Author | SHA1 | Date |
---|---|---|
Skylar Grant | 2a3b53ea08 | |
Skylar Grant | 99af5ca8b4 | |
Skylar Grant | 7003351ecc | |
Skylar Grant | bfa6e10011 | |
Skylar Grant | 22f2ac58df | |
Skylar Grant | 3dcc4e021f | |
Skylar Grant | d1e2152de9 | |
Skylar Grant | 1a024b216a | |
Skylar Grant | 0106983a5f | |
Skylar Grant | caefe0e228 | |
Skylar Grant | 928f12fe01 | |
Skylar Grant | ae9ce308b2 | |
Skylar Grant | 2ea94092db | |
Skylar Grant | 3f5cc0a9ff | |
Skylar Grant | 545756b762 | |
Skylar Grant | d61ffbaaf7 | |
Skylar Grant | 15d39e3381 | |
Skylar Grant | 97b4136b64 | |
Skylar Grant | 82f65a800c | |
Skylar Grant | f995d9a643 | |
Skylar Grant | ff3a423a30 | |
Skylar Grant | 7321f4535b | |
Skylar Grant | c562c06925 | |
Skylar Grant | b28e193b55 | |
Skylar Grant | 6e062ffef2 | |
Skylar Grant | f3051ec944 | |
Skylar Grant | cb834cb7ee | |
Skylar Grant | 0cfa91eb10 | |
Skylar Grant | 17a9bd4ea2 | |
Skylar Grant | 18ef6e56c2 | |
Skylar Grant | 1bff94e71b | |
Skylar Grant | 10021d6926 | |
Skylar Grant | 38fdc07e4e | |
Skylar Grant | e99e6b2e1f | |
Skylar Grant | 98acb652af | |
Skylar Grant | c8d059e36d | |
Skylar Grant | 7c09aaffaa | |
Skylar Grant | 08618e2be2 | |
Skylar Grant | 200468ac10 | |
Skylar Grant | efdc605dc0 | |
Skylar Grant | 2c75ff09d9 | |
Skylar Grant | 4e2e8bc702 | |
Skylar Grant | 53625be91f | |
Skylar Grant | 755c8510d7 |
|
@ -1,7 +1,7 @@
|
||||||
name: NodBot Production Dockerization
|
name: NodBot Production Dockerization
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
commit:
|
||||||
branches:
|
branches:
|
||||||
- pe
|
- pe
|
||||||
|
|
||||||
|
|
|
@ -114,3 +114,4 @@ dist
|
||||||
|
|
||||||
# TernJS port file
|
# TernJS port file
|
||||||
.tern-port
|
.tern-port
|
||||||
|
.DS_Store
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
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,4 +5,5 @@ 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,4 +1,5 @@
|
||||||
{
|
{
|
||||||
"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)) {
|
if (!client.gifs.has(commandData.args.toLowerCase())) {
|
||||||
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);
|
||||||
commandData.embed_url = client.gifs.get(commandData.args).embed_url;
|
const gifData = client.gifs.get(commandData.args.toLowerCase());
|
||||||
// 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(commandData.embed_url);
|
message.reply(gifData.url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,12 +5,33 @@ 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);
|
||||||
}
|
}
|
||||||
const randIndex = Math.floor(Math.random() * joints.length);
|
// Generate a random number between 0 and the length of the joints array
|
||||||
|
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 replyBody = '';
|
let pastaData;
|
||||||
let iconUrl;
|
|
||||||
if (!client.pastas.has(commandData.args)) {
|
if (!client.pastas.has(commandData.args)) {
|
||||||
commandData.content = 'Sorry I couldn\'t find that pasta.';
|
pastaData = {
|
||||||
|
content: "Sorry, I couldn't find that pasta."
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
commandData.content = client.pastas.get(commandData.args).content;
|
pastaData = client.pastas.get(commandData.args);
|
||||||
commandData.iconUrl = client.pastas.get(commandData.args).iconUrl;
|
|
||||||
}
|
}
|
||||||
message.reply(fn.embeds.pasta(commandData));
|
message.reply(fn.embeds.pasta(commandData, pastaData));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,7 +7,6 @@ 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,20 +10,33 @@ module.exports = {
|
||||||
// message.reply(fn.spongebob(commandData)).then(() => {
|
// message.reply(fn.spongebob(commandData)).then(() => {
|
||||||
// message.delete();
|
// message.delete();
|
||||||
// });
|
// });
|
||||||
if (message.reference != undefined) {
|
if (message.reference != undefined) { // message.reference is undefined if the message isn't a reply to another message
|
||||||
const repliedMessageId = message.reference.messageId;
|
if (commandData.args !== "") { // If the replying message isn't just .sb
|
||||||
message.channel.messages.fetch(repliedMessageId)
|
const repliedMessageId = message.reference.messageId; // grab the message Id of the replied-to msg
|
||||||
.then(repliedMessage => {
|
message.channel.messages.fetch(repliedMessageId) // Fetch the message because with our luck it isn't in the cache
|
||||||
repliedMessage.reply(fn.spongebob({ args: repliedMessage.content })).then(() => {
|
.then(repliedMessage => {
|
||||||
if (message.deletable) message.delete();
|
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 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...
|
||||||
.catch(err => {
|
const repliedMessageId = message.reference.messageId; // grab the message Id of the replied-to msg
|
||||||
console.error(err);
|
message.channel.messages.fetch(repliedMessageId) // Fetch the message because with our luck it isn't in the cache
|
||||||
});
|
.then(repliedMessage => {
|
||||||
} else {
|
repliedMessage.reply(fn.spongebob({ args: repliedMessage.content })).then(() => {
|
||||||
|
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 (message.deletable) message.delete(); // If the initiating message is deletable, delete it.
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
304
functions.js
304
functions.js
|
@ -21,6 +21,10 @@ 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');
|
||||||
|
@ -29,6 +33,7 @@ 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,
|
||||||
|
@ -86,12 +91,13 @@ 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
|
||||||
};
|
// };
|
||||||
client.gifs.set(gif.name, gif);
|
const gifData = new GifData().setInfo(row.name, row.embed_url);
|
||||||
|
client.gifs.set(gifData.name, gifData);
|
||||||
}
|
}
|
||||||
if (isDev) console.log('GIFs Collection Built');
|
if (isDev) console.log('GIFs Collection Built');
|
||||||
},
|
},
|
||||||
|
@ -111,13 +117,8 @@ 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 pasta = {
|
const pastaData = new PastaData().setInfo(row.name, row.content, row.iconurl, row.id);
|
||||||
id: row.id,
|
client.pastas.set(pastaData.name, pastaData);
|
||||||
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');
|
||||||
},
|
},
|
||||||
|
@ -148,7 +149,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.medicalAdviceCol) client.medicalAdviceColl = new Discord.Collection();
|
if (!client.medicalAdviceColl) 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 = {
|
||||||
|
@ -156,16 +157,21 @@ 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);
|
||||||
|
@ -176,8 +182,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).replace('.','').toLowerCase();
|
commandData.command = message.content.slice(finalPeriod + 1).toLowerCase();
|
||||||
commandData.author = `${message.author.username}#${message.author.discriminator}`;
|
commandData.author = `${message.author.username}`;
|
||||||
return this.checkCommand(commandData);
|
return this.checkCommand(commandData);
|
||||||
},
|
},
|
||||||
checkCommand(commandData) {
|
checkCommand(commandData) {
|
||||||
|
@ -199,7 +205,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('Help Page')
|
.setAuthor({name: 'Help Page'})
|
||||||
.setDescription(strings.help.description)
|
.setDescription(strings.help.description)
|
||||||
.setThumbnail(strings.urls.avatar);
|
.setThumbnail(strings.urls.avatar);
|
||||||
|
|
||||||
|
@ -252,25 +258,25 @@ const functions = {
|
||||||
},
|
},
|
||||||
gif(commandData) {
|
gif(commandData) {
|
||||||
return { embeds: [new Discord.MessageEmbed()
|
return { embeds: [new Discord.MessageEmbed()
|
||||||
.setAuthor(`${commandData.args}.${commandData.command}`)
|
.setAuthor({name: `${commandData.args}.${commandData.command}`})
|
||||||
.setImage(commandData.embed_url)
|
.setImage(commandData.embed_url)
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setFooter(commandData.author)]};
|
.setFooter({text: commandData.author})]};
|
||||||
},
|
},
|
||||||
pasta(commandData) {
|
pasta(commandData, pastaData) {
|
||||||
return { embeds: [ new Discord.MessageEmbed()
|
return { embeds: [ new Discord.MessageEmbed()
|
||||||
.setAuthor(`${commandData.args}.${commandData.command}`)
|
.setAuthor({name: `${commandData.args}.${commandData.command}`})
|
||||||
.setDescription(commandData.content)
|
.setDescription(pastaData.content)
|
||||||
.setThumbnail(commandData.iconUrl)
|
.setThumbnail("https://assets.vfsh.dev/shednod.png")
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setFooter(commandData.author)]};
|
.setFooter({text: commandData.author})]};
|
||||||
},
|
},
|
||||||
pastas(commandData) {
|
pastas(commandData) {
|
||||||
const pastasArray = [];
|
const pastasArray = [];
|
||||||
const pastasEmbed = new Discord.MessageEmbed()
|
const pastasEmbed = new Discord.MessageEmbed()
|
||||||
.setAuthor(commandData.command)
|
.setAuthor({name: commandData.command})
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setFooter(commandData.author);
|
.setFooter({text: 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`);
|
||||||
|
@ -281,34 +287,27 @@ const functions = {
|
||||||
|
|
||||||
return { embeds: [pastasEmbed], ephemeral: true };
|
return { embeds: [pastasEmbed], ephemeral: true };
|
||||||
},
|
},
|
||||||
gifs(commandData) {
|
gifs(commandData, gifList) {
|
||||||
const gifsArray = [];
|
|
||||||
const gifsEmbed = new Discord.MessageEmbed()
|
const gifsEmbed = new Discord.MessageEmbed()
|
||||||
.setAuthor(commandData.command)
|
.setAuthor({name: commandData.command})
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setFooter(commandData.author);
|
.setFooter({text: 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(commandData.command)
|
.setAuthor({name: commandData.command})
|
||||||
.setDescription(commandData.content)
|
.setDescription(commandData.content)
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setFooter(commandData.author)]};
|
.setFooter({text: commandData.author})]};
|
||||||
},
|
},
|
||||||
requests(commandData) {
|
requests(commandData) {
|
||||||
const requestsEmbed = new Discord.MessageEmbed()
|
const requestsEmbed = new Discord.MessageEmbed()
|
||||||
.setAuthor(commandData.command)
|
.setAuthor({name: commandData.command})
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setFooter(commandData.author);
|
.setFooter({text: commandData.author});
|
||||||
|
|
||||||
const requestsArray = [];
|
const requestsArray = [];
|
||||||
|
|
||||||
|
@ -323,11 +322,9 @@ const functions = {
|
||||||
|
|
||||||
return { embeds: [requestsEmbed], ephemeral: true };
|
return { embeds: [requestsEmbed], ephemeral: true };
|
||||||
},
|
},
|
||||||
strain(commandData, message) {
|
strain(strainInfo, interaction) {
|
||||||
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',
|
||||||
|
@ -351,7 +348,7 @@ const functions = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Rating',
|
name: 'Rating',
|
||||||
value: `${strainInfo.rating}⭐️s`,
|
value: `⭐️${strainInfo.rating}`,
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -361,8 +358,33 @@ const functions = {
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
message.reply({ embeds: [ strainEmbed ]});
|
interaction.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) {
|
||||||
|
@ -372,18 +394,19 @@ const functions = {
|
||||||
},
|
},
|
||||||
upload: {
|
upload: {
|
||||||
request(commandData, client) {
|
request(commandData, client) {
|
||||||
const query = `INSERT INTO requests (author, request, status, url) VALUES (${db.escape(commandData.author)},${db.escape(commandData.args)},'Active',${db.escape(commandData.url)})`;
|
const query = `INSERT INTO requests (author, request, status) VALUES (${db.escape(commandData.author)},${db.escape(commandData.args)},'Active')`;
|
||||||
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);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
pasta(pastaData, client) {
|
async pasta(pastaData, client) {
|
||||||
const query = `INSERT INTO pastas (name, content) VALUES (${db.escape(pastaData.name)},${db.escape(pastaData.content)})`;
|
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)}`;
|
||||||
db.query(query, (err, rows, fields) => {
|
await 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)})`;
|
||||||
|
@ -392,9 +415,9 @@ const functions = {
|
||||||
functions.download.joints(client);
|
functions.download.joints(client);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
gif(gifData, client) {
|
async gif(gifData, client) {
|
||||||
const query = `INSERT INTO gifs (name, embed_url) VALUES (${db.escape(gifData.name)}, ${db.escape(gifData.embed_url)})`;
|
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)}`;
|
||||||
db.query(query, (err, rows, fields) => {
|
await db.query(query, (err, rows, fields) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
functions.download.gifs(client);
|
functions.download.gifs(client);
|
||||||
});
|
});
|
||||||
|
@ -433,6 +456,36 @@ 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: {
|
||||||
|
@ -450,9 +503,9 @@ const functions = {
|
||||||
functions.collections.pastas(rows, client);
|
functions.collections.pastas(rows, client);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
gifs(client) {
|
async gifs(client) {
|
||||||
const query = 'SELECT * FROM gifs ORDER BY id ASC';
|
const query = 'SELECT * FROM gifs ORDER BY id ASC';
|
||||||
db.query(query, (err, rows, fields) => {
|
await db.query(query, (err, rows, fields) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
functions.collections.gifs(rows, client);
|
functions.collections.gifs(rows, client);
|
||||||
});
|
});
|
||||||
|
@ -464,12 +517,11 @@ const functions = {
|
||||||
functions.collections.joints(rows, client);
|
functions.collections.joints(rows, client);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
strain(commandData, message) {
|
strain(strainName, interaction) {
|
||||||
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) {
|
||||||
commandData.strainInfo = {
|
const 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}`,
|
||||||
|
@ -478,7 +530,7 @@ const functions = {
|
||||||
flavor: `${rows[0].flavor}`,
|
flavor: `${rows[0].flavor}`,
|
||||||
rating: `${rows[0].rating}`,
|
rating: `${rows[0].rating}`,
|
||||||
};
|
};
|
||||||
functions.embeds.strain(commandData, message);
|
functions.embeds.strain(strainInfo, interaction);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -501,12 +553,7 @@ 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));
|
||||||
const name = strainSearcher.search(strainName)[0];
|
return strainSearcher.search(strainName).slice(0,25);
|
||||||
if (name != undefined) {
|
|
||||||
return name;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
submit(strainName) {
|
submit(strainName) {
|
||||||
const query = ``
|
const query = ``
|
||||||
|
@ -514,6 +561,48 @@ 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) {
|
||||||
|
@ -533,6 +622,7 @@ 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;
|
||||||
|
@ -540,21 +630,97 @@ 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 (Math.random() > 0.5) {
|
if (lastIsUpper === 0) {
|
||||||
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,8 +7,15 @@ const token = process.env.TOKEN;
|
||||||
const statusChannelId = process.env.statusChannelId;
|
const statusChannelId = process.env.statusChannelId;
|
||||||
|
|
||||||
// Discord.JS
|
// Discord.JS
|
||||||
const { Client } = require('discord.js-selfbot-v13');
|
const { Client, Intents } = require('discord.js');
|
||||||
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',
|
||||||
|
@ -20,12 +27,14 @@ 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);
|
||||||
|
@ -101,10 +110,11 @@ 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,
|
||||||
embed_url: strings.temp.gifs[strings.temp.gifIndex].embed_url,
|
// 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);
|
||||||
|
@ -169,14 +179,39 @@ client.on('interactionCreate', async interaction => {
|
||||||
|
|
||||||
// Handle autocomplete requests
|
// Handle autocomplete requests
|
||||||
if (interaction.isAutocomplete()) {
|
if (interaction.isAutocomplete()) {
|
||||||
if (interaction.commandName == 'strain') {
|
switch (interaction.commandName) {
|
||||||
const searchString = interaction.options.getFocused();
|
case 'strain':
|
||||||
const choices = fn.weed.strain.lookup(searchString, interaction.client);
|
const searchString = interaction.options.getFocused();
|
||||||
await interaction.respond(
|
const choices = fn.weed.strain.lookup(searchString, interaction.client);
|
||||||
choices.map(choice => ({ name: choice, value: choice }))
|
await interaction.respond(
|
||||||
)
|
choices.map(choice => ({ name: choice, value: choice }))
|
||||||
} else {
|
);
|
||||||
return;
|
break;
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -185,16 +220,13 @@ 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;
|
|
||||||
|
|
||||||
// Wildcard Responses, will respond if any message contains the trigger word(s), excluding self-messages
|
// Automatic Responses, will respond if any message contains the keyword(s), excluding self-messages
|
||||||
const lowerContent = message.content.toLowerCase();
|
const lowerContent = message.content.toLowerCase();
|
||||||
if (lowerContent.includes('big') && lowerContent.includes('doinks')) message.reply('gang.');
|
const autoresponses = fn.autoresponses.checkForAll(lowerContent);
|
||||||
if (lowerContent.includes('ligma')) message.reply('ligma balls, goteem');
|
autoresponses.forEach(e => {
|
||||||
if (lowerContent.includes('frfr') || lowerContent.includes('fr fr') || lowerContent.includes('bussin') || lowerContent.includes(' ong') || lowerContent.startsWith('ong')) {
|
fn.autoresponses.send(message, e);
|
||||||
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.1.0",
|
"version": "3.2.3",
|
||||||
"description": "Nods and Nod Accessories.",
|
"description": "Nods and Nod Accessories, now with ChatGPT!",
|
||||||
"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": {
|
||||||
|
|
|
@ -0,0 +1,110 @@
|
||||||
|
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,23 +11,26 @@ 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 => {
|
// const gifsMap = interaction.client.gifs.map(e => {e.name, e.url});
|
||||||
return {
|
// const commandData = {
|
||||||
id: e.id,
|
// gifs: [],
|
||||||
name: e.name,
|
// command: 'gifs',
|
||||||
};
|
// 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 = {
|
||||||
gifs: [],
|
command: "/gifs",
|
||||||
command: 'gifs',
|
author: interaction.member.displayName
|
||||||
author: interaction.user.tag,
|
|
||||||
};
|
};
|
||||||
for (const row of gifsMap) {
|
interaction.reply(fn.embeds.gifs(commandData, gifList));
|
||||||
commandData.gifs.push({
|
|
||||||
id: row.id,
|
|
||||||
name: row.name,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
interaction.reply(fn.embeds.gifs(commandData));
|
|
||||||
},
|
},
|
||||||
};
|
};
|
|
@ -0,0 +1,240 @@
|
||||||
|
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}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
|
@ -1,93 +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');
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -1,17 +0,0 @@
|
||||||
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 });
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -1,17 +0,0 @@
|
||||||
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 });
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -1,24 +0,0 @@
|
||||||
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 });
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -1,54 +0,0 @@
|
||||||
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,13 +14,71 @@
|
||||||
"urls": {
|
"urls": {
|
||||||
"avatar": "https://cdn.discordapp.com/avatars/513184762073055252/12227aa23a06d5178853e59b72c7487b.webp?size=128"
|
"avatar": "https://cdn.discordapp.com/avatars/513184762073055252/12227aa23a06d5178853e59b72c7487b.webp?size=128"
|
||||||
},
|
},
|
||||||
"capbacks": [
|
"costs": {
|
||||||
"on god?!",
|
"gpt": {
|
||||||
"fr fr?!",
|
"gpt-3.5-turbo": 0.2
|
||||||
"no cap?!",
|
},
|
||||||
"no cap fr",
|
"dalle": {
|
||||||
"bussin fr, no cap",
|
"256x256": 1.6,
|
||||||
"ongggg no :billed_cap: fr fr"
|
"512x512": 1.8,
|
||||||
],
|
"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