Compare commits
No commits in common. "ff3a423a30cd7518f448c62939704a758f12a510" and "0cfa91eb10e772ef1ba52ebda534e8e782b17a5f" have entirely different histories.
ff3a423a30
...
0cfa91eb10
2
.github/workflows/production-docker.yml
vendored
2
.github/workflows/production-docker.yml
vendored
@ -22,7 +22,7 @@ jobs:
|
|||||||
whoami
|
whoami
|
||||||
cd /root/nodbot
|
cd /root/nodbot
|
||||||
git pull
|
git pull
|
||||||
git checkout $GITHUB_HEAD_REF
|
git checkout main
|
||||||
- name: Build the Docker image
|
- name: Build the Docker image
|
||||||
run: |
|
run: |
|
||||||
cd /root/nodbot
|
cd /root/nodbot
|
||||||
|
@ -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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
FROM node:18
|
FROM node:16
|
||||||
RUN mkdir -p /usr/src/app
|
RUN mkdir -p /usr/src/app
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,12 +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)) {
|
||||||
commandData.content = 'Sorry I couldn\'t find that pasta.';
|
commandData.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));
|
||||||
}
|
}
|
||||||
}
|
}
|
94
functions.js
94
functions.js
@ -45,7 +45,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,
|
||||||
@ -103,13 +102,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');
|
||||||
},
|
},
|
||||||
@ -129,8 +127,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');
|
||||||
},
|
},
|
||||||
@ -178,7 +181,7 @@ const functions = {
|
|||||||
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);
|
||||||
@ -190,7 +193,7 @@ const functions = {
|
|||||||
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).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) {
|
||||||
@ -212,7 +215,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);
|
||||||
|
|
||||||
@ -265,25 +268,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(pastaData.iconUrl)
|
.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`);
|
||||||
@ -294,27 +297,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 = [];
|
||||||
|
|
||||||
@ -408,7 +418,7 @@ const functions = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
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)})`;
|
||||||
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);
|
||||||
@ -421,9 +431,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);
|
||||||
});
|
});
|
||||||
@ -477,7 +487,7 @@ const functions = {
|
|||||||
const description = db.escape(( interaction.options.getString('description') || 'Unknown' ));
|
const description = db.escape(( interaction.options.getString('description') || 'Unknown' ));
|
||||||
const flavor = db.escape(( interaction.options.getString('flavor') || 'Unknown' ));
|
const flavor = db.escape(( interaction.options.getString('flavor') || 'Unknown' ));
|
||||||
const rating = db.escape(( interaction.options.getString('rating') || '3' ));
|
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)}`;
|
const strainQuery = `INSERT INTO strains (strain, type, effects, description, flavor, rating) VALUES (${strain}, ${type}, ${effects}, ${description}, ${flavor}, ${rating})`;
|
||||||
console.log(strainQuery);
|
console.log(strainQuery);
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
db.query(strainQuery, (err, rows, fields) => {
|
db.query(strainQuery, (err, rows, fields) => {
|
||||||
@ -509,9 +519,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);
|
||||||
});
|
});
|
||||||
@ -598,16 +608,6 @@ const functions = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
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) {
|
||||||
|
43
main.js
43
main.js
@ -27,7 +27,6 @@ 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', () => {
|
||||||
@ -109,11 +108,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);
|
||||||
@ -178,39 +176,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 }))
|
||||||
);
|
)
|
||||||
break;
|
} else {
|
||||||
case "edit":
|
return;
|
||||||
//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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -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));
|
||||||
},
|
},
|
||||||
};
|
};
|
@ -10,7 +10,6 @@ const { SlashCommandBuilder } = require('@discordjs/builders');
|
|||||||
const { MessageActionRow, MessageButton } = require('discord.js');
|
const { MessageActionRow, MessageButton } = require('discord.js');
|
||||||
const fn = require('../functions.js');
|
const fn = require('../functions.js');
|
||||||
const strings = require('../strings.json');
|
const strings = require('../strings.json');
|
||||||
const { GifData } = require('../CustomModules/NodBot.js');
|
|
||||||
const { emoji } = strings;
|
const { emoji } = strings;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@ -179,11 +178,10 @@ module.exports = {
|
|||||||
// GIF URL
|
// GIF URL
|
||||||
case "gifurl":
|
case "gifurl":
|
||||||
//TODO Check on option names
|
//TODO Check on option names
|
||||||
// const gifData = {
|
const gifData = {
|
||||||
// name: interaction.options.getString('name').toLowerCase(),
|
name: interaction.options.getString('name').toLowerCase(),
|
||||||
// url: interaction.options.getString('url'),
|
embed_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);
|
fn.upload.gif(gifData, interaction.client);
|
||||||
interaction.editReply({ content: `I've saved the GIF as ${gifData.name}.gif`, ephemeral: true });
|
interaction.editReply({ content: `I've saved the GIF as ${gifData.name}.gif`, ephemeral: true });
|
||||||
fn.download.gifs(interaction.client);
|
fn.download.gifs(interaction.client);
|
||||||
|
Loading…
Reference in New Issue
Block a user