New handling of valid extensions and new gif and pasta lists
This commit is contained in:
parent
5236462efe
commit
04344c3fdd
@ -1,6 +1,8 @@
|
||||
# Release Notes
|
||||
|
||||
## v2.1.0
|
||||
Wondering what GIFs and Copypastas have been saved? Try `.gifs` and `.pastas`, also check out the new help message with `.help`!
|
||||
|
||||
NodBot now uses Tenor instead of Giphy for GIF searches!
|
||||
|
||||
Changing the method to search for and save GIFs for later reuse. Previously the bot simply sent a message containing the link to a GIF which Discord would display in the chat. However the new code uses Embeds to make the messages look prettier. These Embeds require a *direct* link to the GIF, which isn't very user friendly. Now you can search for a GIF and NodBot will DM you with results for you to browse before choosing the GIF you'd like to save, then name it.
|
||||
|
12
commands/gifs.js
Normal file
12
commands/gifs.js
Normal file
@ -0,0 +1,12 @@
|
||||
const functions = require('../functions.js');
|
||||
|
||||
module.exports = {
|
||||
name: 'gifs',
|
||||
description: 'Get a list of saved GIFs',
|
||||
execute(message, file) {
|
||||
message.author.createDM().then(channel => {
|
||||
channel.send(functions.createGIFList(message));
|
||||
message.reply('I\'ve sent you a DM with a list of saved GIFs.')
|
||||
}).catch(err => message.channel.send('Sorry I was unable to send you a DM.'));
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
const functions = require('../functions.js');
|
||||
|
||||
module.exports = {
|
||||
name: 'mapcommands',
|
||||
description: '',
|
||||
execute(message, file) {
|
||||
console.log(functions.mapCommands(message));
|
||||
}
|
||||
}
|
12
commands/pastas.js
Normal file
12
commands/pastas.js
Normal file
@ -0,0 +1,12 @@
|
||||
const functions = require('../functions.js');
|
||||
|
||||
module.exports = {
|
||||
name: 'pastas',
|
||||
description: 'Get a list of saved copypastas',
|
||||
execute(message, file) {
|
||||
message.author.createDM().then(channel => {
|
||||
channel.send(functions.createPastaList(message));
|
||||
message.channel.send('I\'ve sent you a DM with a list of saved copypastas.')
|
||||
}).catch(err => message.channel.send('Sorry I was unable to send you a DM.'));
|
||||
}
|
||||
}
|
20
config.json
20
config.json
@ -4,25 +4,7 @@
|
||||
"logChannel": "859249300894908447",
|
||||
"bootMessage": "NodBot v2 Starting Up",
|
||||
"shutdownMessage": "NodBot v2 Shutting Down",
|
||||
"validExtensions": [
|
||||
"gif",
|
||||
"pasta",
|
||||
"help",
|
||||
"spongebob",
|
||||
"savepasta",
|
||||
"request",
|
||||
"savegif",
|
||||
"truth",
|
||||
"joint",
|
||||
"ping",
|
||||
"strain",
|
||||
"airport",
|
||||
"weather",
|
||||
"oldgif",
|
||||
"newgif",
|
||||
"newpng",
|
||||
"mapcommands"
|
||||
],
|
||||
"validExtensions": [],
|
||||
"emoji": {
|
||||
"joint": "<:joint:862082955902976000>",
|
||||
"next": "⏭️",
|
||||
|
34
functions.js
34
functions.js
@ -3,8 +3,14 @@ const fs = require('fs');
|
||||
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
|
||||
const gifFiles = fs.readdirSync('./gifs').filter(file => file.endsWith('.js'));
|
||||
const pastaFiles = fs.readdirSync('./pastas').filter(file => file.endsWith('.js'));
|
||||
const config = require('./config.json');
|
||||
|
||||
module.exports = {
|
||||
setValidExtensions(client) {
|
||||
for (const entry of client.commands.map(command => command.name)) {
|
||||
config.validExtensions.push(entry);
|
||||
}
|
||||
},
|
||||
getCommandFiles(client) {
|
||||
client.commands = new Discord.Collection();
|
||||
for (const file of commandFiles) {
|
||||
@ -149,5 +155,33 @@ module.exports = {
|
||||
.setDescription('All commands are provided as "file extensions" instead of prefixes to the message.')
|
||||
.addFields(fields)
|
||||
.setTimestamp();
|
||||
},
|
||||
createGIFList(message) {
|
||||
let list = [];
|
||||
const { gifs } = message.client;
|
||||
for (const entry of gifs.map(gif => [gif.name])) {
|
||||
list.push(entry[0] + '.gif');
|
||||
}
|
||||
|
||||
return new Discord.MessageEmbed()
|
||||
.setAuthor('NodBot GIF List')
|
||||
.setTitle('List of Currently Saved GIFs')
|
||||
.setDescription(list.join('\n'))
|
||||
.setTimestamp()
|
||||
.setFooter(`@${message.author.username}#${message.author.discriminator}`);
|
||||
},
|
||||
createPastaList(message) {
|
||||
let list = [];
|
||||
const { pastas } = message.client;
|
||||
for (const entry of pastas.map(pasta => [pasta.name])) {
|
||||
list.push(entry[0] + '.pasta');
|
||||
}
|
||||
|
||||
return new Discord.MessageEmbed()
|
||||
.setAuthor('NodBot Pasta List')
|
||||
.setTitle('List of Currently Saved Copypastas')
|
||||
.setDescription(list.join('\n'))
|
||||
.setTimestamp()
|
||||
.setFooter(`@${message.author.username}#${message.author.discriminator}`);
|
||||
}
|
||||
}
|
1
index.js
1
index.js
@ -18,6 +18,7 @@ client.once('ready', () => {
|
||||
functions.getCommandFiles(client);
|
||||
functions.getGifFiles(client);
|
||||
functions.getPastaFiles(client);
|
||||
functions.setValidExtensions(client);
|
||||
// Get the owner and DM them a message that the bot is ready, useful for remote deployment
|
||||
client.users.fetch(process.env.ownerID).then(user => {
|
||||
user.createDM().then(channel => {
|
||||
|
Loading…
Reference in New Issue
Block a user