diff --git a/README.md b/README.md index 6f58b35..fd6d3a9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # NodBot A simple Discord bot created by @voidf1sh#0420 for retreiving gifs, saving copypastas, and more coming soon. +## Dependancies +NodBot depends on `fs`, `discord.js`, `dotenv`, and `giphy-api`. + ## Features Dynamic Help Message Ability to save favorite gifs and copypastas diff --git a/commands/gif.js b/commands/gif.js index 000b231..9692c22 100644 --- a/commands/gif.js +++ b/commands/gif.js @@ -1,3 +1,5 @@ +const functions = require('../functions'); + const giphy = require('giphy-api')(process.env.giphyAPIKey); module.exports = { name: 'gif', @@ -7,14 +9,26 @@ module.exports = { if (!client.gifs.has(file.name)) { giphy.search(file.name, (err, res) => { if (res.data[0] != undefined) { - message.channel.send(file.name + ' requested by ' + message.author.username + '\n' + res.data[0].embed_url).then().catch(console.error); + // message.channel.send(file.name + ' requested by ' + message.author.username + '\n' + res.data[0].embed_url).then().catch(console.error); + const gifInfo = { + 'name': file.name, + 'embed_url': res.data[0].images.original.url, + 'requestor': '@' + message.author.username + '#' + message.author.discriminator, + }; + message.channel.send(functions.createGifEmbed(gifInfo)); } else { message.channel.send('I was unable to find a gif of ' + file.name); } if (err) console.error(err); }); } else { - message.channel.send(file.name + ' requested by ' + message.author.username + '\n' + client.gifs.get(file.name).embed_url); + // message.channel.send(file.name + ' requested by ' + message.author.username + '\n' + client.gifs.get(file.name).embed_url); + const gifInfo = { + 'name': file.name, + 'embed_url': file.embed_url, + 'requestor': message.author.username + '#' + message.author.discriminator, + }; + message.channel.send(functions.createGifEmbed(gifInfo)); } } } \ No newline at end of file diff --git a/commands/help.js b/commands/help.js index 130f5cb..c02ad47 100644 --- a/commands/help.js +++ b/commands/help.js @@ -31,7 +31,7 @@ module.exports = { if (command.aliases) data.push(`**Aliases:** ${command.aliases.join(', ')}`); if (command.description) data.push(`**Description:** ${command.description}`); - if (command.usage) data.push(`**Usage:** ${prefix}${command.name} ${command.usage}`); + if (command.usage) data.push(`**Usage:** \`${command.usage}.${command.name}\``); data.push(`**Cooldown:** ${command.cooldown || 3} second(s)`); diff --git a/commands/joint.js b/commands/joint.js new file mode 100644 index 0000000..84651eb --- /dev/null +++ b/commands/joint.js @@ -0,0 +1,9 @@ +const { emoji } = require('../config.json'); + +module.exports = { + name: 'joint', + description: 'Pass the joint!', + execute(message, args) { + message.channel.send('It\'s dangerous to go alone... take this: ' + emoji.joint); + } +} \ No newline at end of file diff --git a/commands/log-message.js b/commands/log-message.js deleted file mode 100644 index fbbb02a..0000000 --- a/commands/log-message.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - name: "log-message", - description: "Logs the message to console for debugging purposes.", - execute(message, args) { - console.log(message); - } -} \ No newline at end of file diff --git a/commands/ping.js b/commands/ping.js deleted file mode 100644 index eb270b5..0000000 --- a/commands/ping.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - name: 'ping', - description: 'Ping!', - execute(message, args) { - message.channel.send('Pong.'); - } -} \ No newline at end of file diff --git a/commands/reload-gifs.js b/commands/reload-gifs.js deleted file mode 100644 index 2cf85c3..0000000 --- a/commands/reload-gifs.js +++ /dev/null @@ -1,9 +0,0 @@ -/* eslint-disable quotes */ -module.exports = { - name: "reload-gifs", - description: "Refresh the hardcoded gif library.", - execute(message, args) { - const functions = require('../functions.js'); - functions.getGifFiles(message.client); - } -} \ No newline at end of file diff --git a/commands/request.js b/commands/request.js index 0ac7825..11626d8 100644 --- a/commands/request.js +++ b/commands/request.js @@ -1,6 +1,7 @@ module.exports = { name: 'request', description: 'Submit a request to the bot developer.', + usage: '', execute(message, file) { const request = file.name; message.channel.send('Your request has been submitted:\n```\n' + request + '\n```'); diff --git a/commands/savegif.js b/commands/savegif.js index 339ba28..9e49863 100644 --- a/commands/savegif.js +++ b/commands/savegif.js @@ -1,6 +1,7 @@ module.exports = { name: 'savegif', description: 'Adds a given gif to the hardcoded list.', + usage: ' ', execute(message, file) { const tempArray = file.name.split(' '); const embedURL = tempArray.shift(); diff --git a/commands/savepasta.js b/commands/savepasta.js index e5ced4f..3a2977b 100644 --- a/commands/savepasta.js +++ b/commands/savepasta.js @@ -3,12 +3,13 @@ const functions = require('../functions.js'); module.exports = { name: 'savepasta', description: 'Adds a given copypasta to the hardcoded list.', + usage: ' ', execute(message, file) { const fs = require('fs'); const pastaTextArray = message.content.split(' '); const pastaFile = functions.getFileInfo(pastaTextArray.pop()); const pastaText = pastaTextArray.join(' '); - const pastaTextEscaped = pastaText.replace(/'/g, '\\\'').replace(/\n/g, '\\n'); + const pastaTextEscaped = functions.cleanInput(pastaText); fs.appendFile(`./pastas/${pastaFile.name}.js`, `module.exports = {\n\tname: '${pastaFile.name}',\n\tcontent: '${pastaTextEscaped}'\n}`, function(err) { if (err) throw err; console.log('Saved file!'); diff --git a/commands/spongebob.js b/commands/spongebob.js index 9fc64da..20bd9f9 100644 --- a/commands/spongebob.js +++ b/commands/spongebob.js @@ -1,6 +1,7 @@ module.exports = { name: 'spongebob', description: 'SpOnGeBoB-iFy AnYtHiNg AuToMaTiCaLly', + usage: '