From d2d4fda926bb4b29837c5122141369a3347c44f1 Mon Sep 17 00:00:00 2001 From: Supositware Date: Wed, 2 Jan 2019 10:21:07 +0100 Subject: [PATCH 01/20] use djs v12 and discord akairo v8 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2c7c825f..263029c9 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,8 @@ "@google-cloud/text-to-speech": "^0.4.0", "auto-reload": "^0.1.0", "canvas": "^2.2.0", - "discord-akairo": "^7.5.5", - "discord.js": "^11.4.2", + "discord-akairo": "github:1Computer1/discord-akairo#master", + "discord.js": "github:discordjs/discord.js#master", "node-fetch": "^2.3.0", "reload-json": "^0.3.1", "superagent": "^4.1.0", From bda3ea476581bc99e0f173ed92834e716a59f82b Mon Sep 17 00:00:00 2001 From: Supositware Date: Wed, 2 Jan 2019 10:21:21 +0100 Subject: [PATCH 02/20] updated the change from discord v12 and akairo v8 --- commands/general/advice.js | 5 +-- commands/general/reddit.js | 5 +-- commands/utility/ping.js | 2 +- commands/utility/server.js | 21 +++++----- commands/utility/taglist.js | 5 +-- commands/utility/translate.js | 12 +++--- commands/utility/updoot.js | 20 ++++----- index.js | 74 ++++++++++++++++++++------------- listeners/UnhandledRejection.js | 16 ------- listeners/guildCreate.js | 4 +- listeners/guildDelete.js | 4 +- listeners/messageReactionAdd.js | 22 +++++----- listeners/ready.js | 26 ++++++++++++ 13 files changed, 119 insertions(+), 97 deletions(-) delete mode 100644 listeners/UnhandledRejection.js create mode 100644 listeners/ready.js diff --git a/commands/general/advice.js b/commands/general/advice.js index 8a07d5ad..f72ebc97 100644 --- a/commands/general/advice.js +++ b/commands/general/advice.js @@ -1,5 +1,5 @@ const { Command } = require('discord-akairo'); -const Discord = require('discord.js'); +const { MessageEmbed } = require('discord.js'); const fetch = require('node-fetch'); class AdviceCommand extends Command { @@ -19,8 +19,7 @@ class AdviceCommand extends Command { fetch('http://api.adviceslip.com/advice').then((response) => { return response.json(); }).then((response) => { - const adviceEmbed = new Discord.RichEmbed() - .setColor('#ff9900') + const adviceEmbed = new MessageEmbed() .setColor('#ff9900') .setTitle(response.slip.slip_id) .setDescription(response.slip.advice); diff --git a/commands/general/reddit.js b/commands/general/reddit.js index de27f319..0a9ff9e9 100644 --- a/commands/general/reddit.js +++ b/commands/general/reddit.js @@ -1,5 +1,5 @@ const { Command } = require('discord-akairo'); -const Discord = require('discord.js'); +const { MessageEmbed } = require('discord.js'); const fetch = require('node-fetch'); class RedditCommand extends Command { @@ -39,8 +39,7 @@ class RedditCommand extends Command { } if (response.data.children[i].data.over_18 == true) return message.channel.send('No nsfw'); - const redditEmbed = new Discord.RichEmbed() - .setColor('#ff9900') + const redditEmbed = new MessageEmbed() .setColor('#ff9900') .setTitle(response.data.children[i].data.title) .setImage(response.data.children[i].data.url) .setURL('https://reddit.com' + response.data.children[i].data.permalink) diff --git a/commands/utility/ping.js b/commands/utility/ping.js index f46743e7..d496f218 100644 --- a/commands/utility/ping.js +++ b/commands/utility/ping.js @@ -16,7 +16,7 @@ class PingCommand extends Command { async exec(message) { return message.util.reply('Pong!').then(sent => { const timeDiff = (sent.editedAt || sent.createdAt) - (message.editedAt || message.createdAt); - const text = `šŸ”‚\u2000**RTT**: ${timeDiff} ms\nšŸ’Ÿ\u2000**Heartbeat**: ${Math.round(this.client.ping)} ms`; + const text = `šŸ”‚\u2000**PING**: ${timeDiff} ms`; return message.util.reply(`Pong!\n${text}`); }); } diff --git a/commands/utility/server.js b/commands/utility/server.js index 1de95ccd..9c7658ae 100644 --- a/commands/utility/server.js +++ b/commands/utility/server.js @@ -1,4 +1,5 @@ const { Command } = require('discord-akairo'); +const { MessageEmbed } = require('discord.js'); class ServerCommand extends Command { constructor() { @@ -15,19 +16,17 @@ class ServerCommand extends Command { } async exec(message) { - const customresponse = require(`../tag/${message.guild.id}.json`); + const customresponse = require(`../../tag/${message.guild.id}.json`); var count = Object.keys(customresponse).length; - - - const addEmbed = { - color: 0x0099ff, - title: 'Stats of the server', - thumbnail: { - url: `${message.guild.iconURL}`, - }, - description: `Member: **${message.guild.memberCount}** \nChannel number: **${message.guild.channels.size}**\nGuild created at **${message.guild.createdAt}**\nOwner: **${message.guild.owner}**\nTag number: **${count}**`, - }; + const addEmbed = new MessageEmbed() + .setColor('#0099ff') + .setTitle('Stats of the server') + .setAuthor(message.author.username) + .setDescription(`Member: **${message.guild.memberCount}** \nChannel number: **${message.guild.channels.size}**\nGuild created at **${message.guild.createdAt}**\nOwner: **${message.guild.owner}**\nTag number: **${count}**`) + .setTimestamp(); + + message.channel.send({ embed: addEmbed }); } diff --git a/commands/utility/taglist.js b/commands/utility/taglist.js index 0927a7d1..e9505282 100644 --- a/commands/utility/taglist.js +++ b/commands/utility/taglist.js @@ -1,5 +1,5 @@ const { Command } = require('discord-akairo'); -const Discord = require('discord.js'); +const { MessageEmbed } = require('discord.js'); const reload = require('auto-reload'); const fs = require('fs'); @@ -31,8 +31,7 @@ class taglistCommand extends Command { let json = JSON.stringify(data); json = json.replace(/[{}'\\]+/g, ''); json = json.replace(/,+/g, '\n'); - const tagEmbed = new Discord.RichEmbed() - .setColor('#ff9900') + const tagEmbed = new MessageEmbed() .setColor('#ff9900') .setTitle('Tags list') .setDescription(`Trigger:Response\n\n${json}`) .setFooter(`You have ${count} tags on this server`); diff --git a/commands/utility/translate.js b/commands/utility/translate.js index d1142c07..6b85f7be 100644 --- a/commands/utility/translate.js +++ b/commands/utility/translate.js @@ -1,5 +1,5 @@ const { Command } = require('discord-akairo'); -const Discord = require('discord.js'); +const { MessageEmbed } = require('discord.js'); const fetch = require('node-fetch'); const { yandexAPI } = require('../../config.json'); @@ -8,11 +8,13 @@ class TranslationCommand extends Command { super('translation', { aliases: ['translation', 'trn'], category: 'utility', - split: 'sticky', args: [ { id: 'language', - type: 'string', + type: ['az','ml','sq','mt','am','mk','en','mi','ar','mr','hy','mhr','af','mn','eu','de','ba','ne','be','no','bn','pa','my','pap','bg','fa','bs','pl','cy','pt','hu','ro','vi','ru','ht','ceb','gl','sr','nl','si','mrj','sk','el','sl','ka','sw','gu','su','da','tg','he','th','yi','tl','id','ta','ga','tt','it','te','is','tr','es','udm','kk','uz','kn','uk','ca','ur','ky','fi','zh','fr','ko','hi','xh','hr','km','cs','lo','sv','la','gd','lv','et','lt','eo','lb','jv','mg','ja','ms'], + prompt: { + retry: 'That\'s not a valid language! try again.' + }, default: 'en' }, { @@ -23,7 +25,7 @@ class TranslationCommand extends Command { description: { content: 'Translate what you send in your desired language. You can find the language code here: https://tech.yandex.com/translate/doc/dg/concepts/api-overview-docpage/', usage: '[language code] [Text to translate]', - examples: ['fr What are we doing today?', 'en Que faisons-nous aujourd\'hui?'] + examples: ['fr "What are we doing today?"', 'en "Que faisons-nous aujourd\'hui?"'] } }); } @@ -43,7 +45,7 @@ class TranslationCommand extends Command { return message.channel.send('An error has occured'); - const translationEmbed = new Discord.RichEmbed() + const translationEmbed = new MessageEmbed() .setColor('#0099ff') .setTitle('Asked for the following translation:') .setAuthor(message.author.username) diff --git a/commands/utility/updoot.js b/commands/utility/updoot.js index 6a739c2e..35e5f094 100644 --- a/commands/utility/updoot.js +++ b/commands/utility/updoot.js @@ -1,4 +1,5 @@ const { Command } = require('discord-akairo'); +const { MessageEmbed } = require('discord.js'); class UpdootCommand extends Command { constructor() { @@ -15,17 +16,14 @@ class UpdootCommand extends Command { } async exec(message) { - const upDoot = { - color: 0x93C54B, - title: 'Vote for my bot', - url: 'https://discordbots.org/bot/377563711927484418/vote', - description: 'You can vote for my bot if you think the bot is awesome!', - timestamp: new Date(), - footer: { - text: 'Thanks for the updoots', - icon_url: 'https://cdn.discordapp.com/avatars/377563711927484418/1335d202aa466dbeaa4ed2e4b616484a.png?size=2048', - }, - }; + const upDoot = new MessageEmbed() + .setColor('#0099ff') + .setTitle('Vote for my bot') + .setURL('https://discordbots.org/bot/377563711927484418/vote') + .setAuthor(message.author.username) + .setDescription('You can vote for my bot if you think the bot is awesome!') + .setTimestamp() + .setFooter('Thanks for the updoots', 'https://cdn.discordapp.com/avatars/377563711927484418/1335d202aa466dbeaa4ed2e4b616484a.png?size=2048'); message.channel.send({ embed: upDoot }); } diff --git a/index.js b/index.js index f21e4a57..7db9c31a 100644 --- a/index.js +++ b/index.js @@ -1,33 +1,49 @@ -const { AkairoClient } = require('discord-akairo'); -const { token, prefix, ownerID, statsChannel } = require('./config.json'); +const { AkairoClient, CommandHandler, InhibitorHandler, ListenerHandler } = require('discord-akairo'); +const { token, prefix, ownerID } = require('./config.json'); -const client = new AkairoClient({ - ownerID: ownerID, - prefix: prefix, - allowMention: true, - handleEdits: true, - emitters: { - process - }, - commandUtil: true, - commandUtilLifetime: 600000, - commandDirectory: './commands/', - inhibitorDirectory: './inhibitors/', - listenerDirectory: './listeners/' -}, { - disableEveryone: true -}); -// Ready messages dosent work on the listeners event for some reasons -client.on('ready', async () => { - // Send stats to the console - console.log(`\x1b[32mLogged in as \x1b[34m${client.user.tag}\x1b[0m! (\x1b[33m${client.user.id}\x1b[0m)`); - console.log(`Ready to serve in \x1b[33m${client.channels.size}\x1b[0m channels on \x1b[33m${client.guilds.size}\x1b[0m servers, for a total of \x1b[33m${client.users.size}\x1b[0m users. \x1b${client.readyAt}\x1b[0m`); - // Send stats to the 'stats' channel in the support server if its not the test bot - if (client.user.id == 377563711927484418) { - const channel = client.channels.get(statsChannel); - channel.send(`Ready to serve in ${client.channels.size} channels on ${client.guilds.size} servers, for a total of ${client.users.size} users. ${client.readyAt}`); - client.user.setActivity(`${prefix} feedback to tell me what you think of the bot! | ${prefix} help`); } -}); +class hahaYesClient extends AkairoClient { + constructor() { + super({ + ownerID: ownerID, + }, { + disableEveryone: true + }); + this.commandHandler = new CommandHandler(this, { + directory: './commands/', + prefix: prefix, + commandUtil: true, + commandUtilLifetime: 600000, + allowMention: true, + handleEdits: true, + }); + + this.inhibitorHandler = new InhibitorHandler(this, { + directory: './inhibitors/', + emitters: { + process + }, + }); + + this.listenerHandler = new ListenerHandler(this, { + directory: './listeners/' + }); + + this.listenerHandler.setEmitters({ + commandHandler: this.commandHandler, + inhibitorHandler: this.inhibitorHandler, + listenerHandler: this.listenerHandler + }); + + this.commandHandler.useInhibitorHandler(this.inhibitorHandler); + this.commandHandler.useListenerHandler(this.listenerHandler); + + this.listenerHandler.loadAll(); + this.inhibitorHandler.loadAll(); + this.commandHandler.loadAll(); + } +} + +const client = new hahaYesClient(); client.login(token); \ No newline at end of file diff --git a/listeners/UnhandledRejection.js b/listeners/UnhandledRejection.js deleted file mode 100644 index e141f3d2..00000000 --- a/listeners/UnhandledRejection.js +++ /dev/null @@ -1,16 +0,0 @@ -const { Listener } = require('discord-akairo'); - -class UnhandledRejectionListener extends Listener { - constructor() { - super('unhandledRejection', { - eventName: 'unhandledRejection', - emitter: 'process' - }); - } - - exec(error) { - console.error(error); - } -} - -module.exports = UnhandledRejectionListener; \ No newline at end of file diff --git a/listeners/guildCreate.js b/listeners/guildCreate.js index 4b33e68f..c20b9f2c 100644 --- a/listeners/guildCreate.js +++ b/listeners/guildCreate.js @@ -1,5 +1,5 @@ const { Listener } = require('discord-akairo'); -const Discord = require('discord.js'); +const { MessageEmbed } = require('discord.js'); const { statsChannel } = require('../config.json'); @@ -14,7 +14,7 @@ class guildCreateListener extends Listener { async exec(guild) { console.log(`${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\nOwner ID: ${guild.owner}`); const channel = this.client.channels.get(statsChannel); - const addEmbed = new Discord.RichEmbed() + const addEmbed = new MessageEmbed() .setColor('#52e80d') .setTitle('Someone added me ! YAY :D') .setURL('https://www.youtube.com/watch?v=6n3pFFPSlW4') diff --git a/listeners/guildDelete.js b/listeners/guildDelete.js index d2e884da..c6ba9741 100644 --- a/listeners/guildDelete.js +++ b/listeners/guildDelete.js @@ -1,5 +1,5 @@ const { Listener } = require('discord-akairo'); -const Discord = require('discord.js'); +const { MessageEmbed } = require('discord.js'); const { statsChannel } = require('../config.json'); @@ -15,7 +15,7 @@ class guildCreateListener extends Listener { console.log(`***BOT KICKED***\n${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\nOwner ID: ${guild.owner}\n***BOT KICKED***`); const channel = this.client.channels.get(statsChannel); - const kickEmbed = new Discord.RichEmbed() + const kickEmbed = new MessageEmbed() .setColor('#FF0000') .setTitle('They kicked me out :(') .setURL('https://www.youtube.com/watch?v=6n3pFFPSlW4') diff --git a/listeners/messageReactionAdd.js b/listeners/messageReactionAdd.js index 27095825..4c2e247e 100644 --- a/listeners/messageReactionAdd.js +++ b/listeners/messageReactionAdd.js @@ -1,5 +1,5 @@ const { Listener } = require('discord-akairo'); -const Discord = require('discord.js'); +const { MessageEmbed } = require('discord.js'); const reload = require('auto-reload'); class MessageReactionAddListener extends Listener { @@ -18,11 +18,11 @@ class MessageReactionAddListener extends Listener { let starboardChannel = reload(`../starboard/${reaction.message.guild.id}.json`); const channel = this.client.channels.get(starboardChannel['starboard']); - const starEmbed = new Discord.RichEmbed() - .setColor() - .setDescription(messageContent) - .setAuthor(reaction.message.author.username, reaction.message.author.displayAvatarURL) - .setTimestamp() + const starEmbed = new MessageEmbed() + .setColor() + .setDescription(messageContent) + .setAuthor(reaction.message.author.username, reaction.message.author.displayAvatarURL) + .setTimestamp(); channel.send({ embed: starEmbed}); return channel.send(`From: ${reaction.message.channel}\n${messageAttachments}`); @@ -31,11 +31,11 @@ class MessageReactionAddListener extends Listener { let shameboardChannel = reload(`../starboard/${message.guild.id}.json`); const channel = client.channels.get(shameboardChannel['shameboard']); - const starEmbed = new Discord.RichEmbed() - .setColor() - .setDescription(messageContent) - .setAuthor(reaction.message.author.username, reaction.message.author.displayAvatarURL) - .setTimestamp() + const starEmbed = new MessageEmbed() + .setColor() + .setDescription(messageContent) + .setAuthor(reaction.message.author.username, reaction.message.author.displayAvatarURL) + .setTimestamp(); try { channel.send({ embed: starEmbed}); diff --git a/listeners/ready.js b/listeners/ready.js new file mode 100644 index 00000000..a5b8d45b --- /dev/null +++ b/listeners/ready.js @@ -0,0 +1,26 @@ +const { Listener } = require('discord-akairo'); +const { prefix, statsChannel } = require('../config.json'); + + +class ReadyListener extends Listener { + constructor() { + super('ready', { + emitter: 'client', + event: 'ready' + }); + } + + async exec() { + // Send stats to the console + console.log(`\x1b[32mLogged in as \x1b[34m${this.client.user.tag}\x1b[0m! (\x1b[33m${this.client.user.id}\x1b[0m)`); + console.log(`Ready to serve in \x1b[33m${this.client.channels.size}\x1b[0m channels on \x1b[33m${this.client.guilds.size}\x1b[0m servers, for a total of \x1b[33m${this.client.users.size}\x1b[0m users. \x1b${this.client.readyAt}\x1b[0m`); + // Send stats to the 'stats' channel in the support server if its not the test bot + if (this.client.user.id == 377563711927484418) { + const channel = this.client.channels.get(statsChannel); + channel.send(`Ready to serve in ${this.client.channels.size} channels on ${this.client.guilds.size} servers, for a total of ${this.client.users.size} users. ${this.client.readyAt}`); + this.client.user.setActivity(`${prefix} feedback to tell me what you think of the bot! | ${prefix} help`); + } + } +} + +module.exports = ReadyListener; \ No newline at end of file From 38ed4c36307818dcb84a864e5893fd9422068216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bersier?= Date: Wed, 2 Jan 2019 09:23:50 +0000 Subject: [PATCH 03/20] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 263029c9..b630634b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hahayes", - "version": "2.0.0", + "version": "2.1.0", "description": "", "main": "index.js", "scripts": { From e826ed8fcacf141d888194627991d64961716dc5 Mon Sep 17 00:00:00 2001 From: Supositware Date: Wed, 2 Jan 2019 10:34:04 +0100 Subject: [PATCH 04/20] Added default text --- commands/images/idubbbz.js | 3 ++- commands/images/idubbbzpaint.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/commands/images/idubbbz.js b/commands/images/idubbbz.js index 9c8569a5..b3407747 100644 --- a/commands/images/idubbbz.js +++ b/commands/images/idubbbz.js @@ -12,7 +12,8 @@ class IdubbbzCommand extends Command { args: [ { id: 'text', - type: 'string' + type: 'string', + default: 'nigger fagget' }, { id: 'image', diff --git a/commands/images/idubbbzpaint.js b/commands/images/idubbbzpaint.js index e2cd914d..f1fd8331 100644 --- a/commands/images/idubbbzpaint.js +++ b/commands/images/idubbbzpaint.js @@ -11,7 +11,8 @@ class IdubbbzPaintCommand extends Command { args: [ { id: 'text', - type: 'string' + type: 'string', + default: 'Perfection' }, { id: 'image', From af6153ef4052a305d7a2a483cfa1fb43a3dd505e Mon Sep 17 00:00:00 2001 From: Supositware Date: Wed, 2 Jan 2019 18:45:53 +0100 Subject: [PATCH 05/20] various fixes for djs v12 --- commands/admin/autoresponse.js | 10 +++++----- commands/admin/shameboard.js | 6 +++--- commands/admin/starboard.js | 6 +++--- commands/admin/tag.js | 7 +++---- commands/admin/untag.js | 4 ++-- commands/general/advice.js | 3 ++- commands/general/emotesay.js | 2 ++ commands/general/reddit.js | 5 ++++- commands/general/say.js | 4 +++- commands/general/sayd.js | 2 ++ commands/general/tts.js | 6 +++--- commands/general/ttsvc.js | 2 +- commands/utility/avatar.js | 6 +++--- commands/utility/download.js | 4 ++-- commands/utility/stats.js | 17 ++++++++++++++++- commands/utility/taglist.js | 19 +++++++++++-------- 16 files changed, 65 insertions(+), 38 deletions(-) diff --git a/commands/admin/autoresponse.js b/commands/admin/autoresponse.js index cad071bb..de1d3093 100644 --- a/commands/admin/autoresponse.js +++ b/commands/admin/autoresponse.js @@ -38,7 +38,7 @@ class autoresponseCommand extends Command { fs.readFile('./json/autoresponse.json', 'utf8', function readFileCallback(err, data) { if (err) { - fs.close(); + console.log(err); } else { @@ -48,14 +48,14 @@ class autoresponseCommand extends Command { json = json.replace(/[<#>]/g, ''); fs.writeFile('./json/autoresponse.json', json, 'utf8', function (err) { if (err) { - fs.close(); + return console.log(err); } }); } }); - fs.close(); + return message.channel.send('Auto response have been disable/enable on every channel'); } else if (text == 'disable' || 'enable') { @@ -68,7 +68,7 @@ class autoresponseCommand extends Command { json = JSON.stringify(autoresponse); //convert it back to json fs.writeFile('./json/autoresponse.json', json, 'utf8', function (err) { if (err) { - fs.close(); + return console.log(err); } }); @@ -76,7 +76,7 @@ class autoresponseCommand extends Command { }); } - fs.close(); + return message.channel.send(`Autoresponse have been ${text}d`); } } diff --git a/commands/admin/shameboard.js b/commands/admin/shameboard.js index 406dd512..e3aa8c2d 100644 --- a/commands/admin/shameboard.js +++ b/commands/admin/shameboard.js @@ -25,7 +25,7 @@ class shameboardCommand extends Command { if (err) { console.log(err); } - fs.close(); + return message.channel.send('This channel have been set as the shameboard'); }); } else { @@ -34,13 +34,13 @@ class shameboardCommand extends Command { var json = JSON.stringify(shameboard); //convert it back to json fs.writeFile(`./starboard/${message.guild.id}.json`, json, 'utf8', function (err) { if (err) { - fs.close(); + return console.log(err); } }); } }); - fs.close(); + return message.channel.send('This channel have been set as the shameboard'); } } diff --git a/commands/admin/starboard.js b/commands/admin/starboard.js index f4cdf8bd..7ceb2613 100644 --- a/commands/admin/starboard.js +++ b/commands/admin/starboard.js @@ -25,7 +25,7 @@ class StarBoardCommand extends Command { if (err) { console.log(err); } - fs.close(); + return message.channel.send('This channel have been set as the starboard'); }); } else { @@ -34,13 +34,13 @@ class StarBoardCommand extends Command { var json = JSON.stringify(starboard); //convert it back to json fs.writeFile(`./starboard/${message.guild.id}.json`, json, 'utf8', function (err) { if (err) { - fs.close(); + return console.log(err); } }); } }); - fs.close(); + return message.channel.send('This channel have been set as the starboard'); } } diff --git a/commands/admin/tag.js b/commands/admin/tag.js index 5bc207e6..8d6f9467 100644 --- a/commands/admin/tag.js +++ b/commands/admin/tag.js @@ -37,9 +37,9 @@ class TagCommand extends Command { fs.readFile(`./tag/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data) { if (err) { - fs.writeFile(`./tag/${message.guild.id}.json`, `{'${trigger}':'${response}'}`, function (err) { + fs.writeFile(`./tag/${message.guild.id}.json`, `{"${trigger}":"${response}"}`, function (err) { if (err) { - fs.close(); + console.log(err); } }); @@ -49,14 +49,13 @@ class TagCommand extends Command { json = JSON.stringify(customresponse); //convert it back to json fs.writeFile(`./tag/${message.guild.id}.json`, json, 'utf8', function (err) { if (err) { - fs.close(); return console.log(err); } }); } }); - fs.close(); + return message.channel.send(`autoresponse have been set to ${trigger} : ${response}`); } } diff --git a/commands/admin/untag.js b/commands/admin/untag.js index c41e1db2..f8785d78 100644 --- a/commands/admin/untag.js +++ b/commands/admin/untag.js @@ -40,14 +40,14 @@ class UnTagCommand extends Command { json = JSON.stringify(customresponse); //convert it back to json fs.writeFile(`./tag/${message.guild.id}.json`, json, 'utf8', function (err) { if (err) { - fs.close(); + return console.log(err); } }); } }); - fs.close(); + return message.channel.send(`The following autoresponse have been deleted: ${trigger}`); } diff --git a/commands/general/advice.js b/commands/general/advice.js index f72ebc97..c4fd9d78 100644 --- a/commands/general/advice.js +++ b/commands/general/advice.js @@ -19,7 +19,8 @@ class AdviceCommand extends Command { fetch('http://api.adviceslip.com/advice').then((response) => { return response.json(); }).then((response) => { - const adviceEmbed = new MessageEmbed() .setColor('#ff9900') + const adviceEmbed = new MessageEmbed() + .setColor('#ff9900') .setTitle(response.slip.slip_id) .setDescription(response.slip.advice); diff --git a/commands/general/emotesay.js b/commands/general/emotesay.js index b90295d6..413fbc5f 100644 --- a/commands/general/emotesay.js +++ b/commands/general/emotesay.js @@ -23,6 +23,8 @@ class EmotesayCommand extends Command { async exec(message, args) { let text = args.text; + if (!text) + return; message.delete(); let emojiArray = []; diff --git a/commands/general/reddit.js b/commands/general/reddit.js index 0a9ff9e9..e2444d78 100644 --- a/commands/general/reddit.js +++ b/commands/general/reddit.js @@ -11,7 +11,10 @@ class RedditCommand extends Command { args: [ { id: 'sub', - type: 'string' + type: 'string', + prompt: { + retry: 'That\'s not a valid subreddit! try again.' + }, } ], description: { diff --git a/commands/general/say.js b/commands/general/say.js index 71ee8f46..534f8656 100644 --- a/commands/general/say.js +++ b/commands/general/say.js @@ -15,13 +15,15 @@ class SayCommand extends Command { description: { content: 'Repeat what you say but can also replace ', usage: '[text]', - examples: ['[member] is a big [adverbs] [verb]'] + examples: ['[member] is a big [adverb] [verb]'] } }); } async exec(message, args) { let text = args.text; + if (!text) + return; // Load all the different files const verb = require('../../dictionary/verbs.json'); diff --git a/commands/general/sayd.js b/commands/general/sayd.js index 6a360e47..3585a7e9 100644 --- a/commands/general/sayd.js +++ b/commands/general/sayd.js @@ -23,6 +23,8 @@ class SaydCommand extends Command { async exec(message, args) { let text = args.text; + if (!text) + return; // Load all the different files const verb = require('../../dictionary/verbs.json'); diff --git a/commands/general/tts.js b/commands/general/tts.js index 82bdf925..91234ff3 100644 --- a/commands/general/tts.js +++ b/commands/general/tts.js @@ -38,7 +38,7 @@ class TtsCommand extends Command { // Performs the Text-to-Speech request gclient.synthesizeSpeech(request, (err, response) => { if (err) { - fs.close(); + console.error('ERROR:', err); return; } @@ -48,13 +48,13 @@ class TtsCommand extends Command { if (err) { console.error('ERROR:', err); message.channel.send('An error has occured, the message is probably too long'); - fs.close(); + return; } console.log('Audio content written to file: tts.mp3'); message.channel.send({ files: ['./tts.mp3'] }); }); - fs.close(); + }); } } diff --git a/commands/general/ttsvc.js b/commands/general/ttsvc.js index 53dfc7e0..d489e67e 100644 --- a/commands/general/ttsvc.js +++ b/commands/general/ttsvc.js @@ -50,7 +50,7 @@ class TtsvcCommand extends Command { if (err) { console.error('ERROR:', err); message.channel.send('An error has occured, the message is probably too long'); - fs.close(); + return; } console.log('Audio content written to file: ttsvc.mp3'); diff --git a/commands/utility/avatar.js b/commands/utility/avatar.js index 39de9253..d4340582 100644 --- a/commands/utility/avatar.js +++ b/commands/utility/avatar.js @@ -20,10 +20,10 @@ class AvatarCommand extends Command { } async exec(message, args) { - if (!args.user) // While these kind of statments work you really should use {} - return message.channel.send(`Your avatar:\n${message.author.displayAvatarURL}`); + if (!args.user) + return message.channel.send(`Your avatar:\n${message.author.displayAvatarURL()}`); else - return message.channel.send(`${args.user.username}'s avatar:\n${args.user.displayAvatarURL}`); + return message.channel.send(`${args.user.username}'s avatar:\n${args.user.displayAvatarURL()}`); } } diff --git a/commands/utility/download.js b/commands/utility/download.js index f24d93ac..735d9cb2 100644 --- a/commands/utility/download.js +++ b/commands/utility/download.js @@ -43,10 +43,10 @@ class DownloadCommand extends Command { message.delete(); message.channel.send(`Downloaded by ${message.author.username}`, { files: ['./video.mp4'] }) .catch(() => message.channel.send('File too big')); - fs.close(); + }); } else { - fs.close(); + message.channel.send('You need to input a valid link'); } } diff --git a/commands/utility/stats.js b/commands/utility/stats.js index 9113caf0..f8fb1b7c 100644 --- a/commands/utility/stats.js +++ b/commands/utility/stats.js @@ -1,4 +1,5 @@ const { Command } = require('discord-akairo'); +const { MessageEmbed } = require('discord.js'); class StatsCommand extends Command { constructor() { @@ -21,7 +22,21 @@ class StatsCommand extends Command { let minutes = Math.floor(totalSeconds / 60); let seconds = totalSeconds.toFixed(0) % 60; let uptime = `${days} days, ${hours} hours, ${minutes} minutes and ${seconds} seconds`; - return message.channel.send(`Servers: \`${this.client.guilds.size}\`\nChannels: \`${this.client.channels.size}\`\nUsers: \`${this.client.users.size}\`\nBot uptime: \`${uptime}\``); + const used = process.memoryUsage().heapUsed / 1024 / 1024; + + const statsEmbed = new MessageEmbed() + .setColor('#0099ff') + .setTitle('Bot stats') + .setAuthor('Haha yes') + .addField('Servers', this.client.guilds.size, true) + .addField('Channels', this.client.channels.size, true) + .addField('Users', this.client.users.size, true) + .addField('Uptime', uptime, true) + .addField('Ram usage', `${Math.round(used * 100) / 100} MB`, true) + .setTimestamp() + .setFooter('Powered by Yandex.Translate '); + + return message.channel.send(statsEmbed); } } diff --git a/commands/utility/taglist.js b/commands/utility/taglist.js index e9505282..9bba8ccb 100644 --- a/commands/utility/taglist.js +++ b/commands/utility/taglist.js @@ -18,28 +18,31 @@ class taglistCommand extends Command { } async exec(message) { - let customresponse = reload(`../../tag/${message.guild.id}.json`); - let count = Object.keys(customresponse).length; - - + try { + var customresponse = reload(`../../tag/${message.guild.id}.json`); + var count = Object.keys(customresponse).length; + } catch (err) { + message.channel.send('An error has occured, do you have any tags on the server?'); + console.error(err); + } await fs.readFile(`./tag/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data) { if (err) { console.log(err); - fs.close(); + return; } let json = JSON.stringify(data); json = json.replace(/[{}'\\]+/g, ''); json = json.replace(/,+/g, '\n'); - const tagEmbed = new MessageEmbed() .setColor('#ff9900') + const tagEmbed = new MessageEmbed() + .setColor('#ff9900') .setTitle('Tags list') .setDescription(`Trigger:Response\n\n${json}`) .setFooter(`You have ${count} tags on this server`); message.channel.send(tagEmbed); }); - fs.close(); - message.channel.send('An error has occured, do you have any tags on the server?'); + } } From 604e689928bcdeec02f8d4c892431baf260080c8 Mon Sep 17 00:00:00 2001 From: Supositware Date: Wed, 2 Jan 2019 18:59:16 +0100 Subject: [PATCH 06/20] added credit --- commands/utility/credit.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 commands/utility/credit.js diff --git a/commands/utility/credit.js b/commands/utility/credit.js new file mode 100644 index 00000000..0c4f04c0 --- /dev/null +++ b/commands/utility/credit.js @@ -0,0 +1,21 @@ +const { Command } = require('discord-akairo'); + +class creditCommand extends Command { + constructor() { + super('credit', { + aliases: ['credit'], + category: 'utility', + description: { + content: 'Show credits for the bot', + usage: '(optional) [@user]', + examples: ['', '@user'] + } + }); + } + + async exec(message) { + message.channel.send('Thanks to Tina the Cyclops girl#0064 for inspiring me making a bot,\nThanks to discord.js team for making discord.js\nThanks to 1computer1 for making discord-akairo and the help command'); + } +} + +module.exports = creditCommand; \ No newline at end of file From 557d5df71e732a5315e7f0b5948fba70a342f6fc Mon Sep 17 00:00:00 2001 From: Supositware Date: Wed, 2 Jan 2019 18:59:20 +0100 Subject: [PATCH 07/20] --- package.json | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b630634b..03aa4f58 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,6 @@ { "name": "hahayes", "version": "2.1.0", - "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" @@ -28,5 +27,14 @@ "eslint-plugin-node": "^8.0.0", "eslint-plugin-promise": "^4.0.1", "eslint-plugin-standard": "^4.0.0" - } + }, + "repository": { + "type": "git", + "url": "git+https://gitlab.com/LoicBersier/DiscordBot.git" + }, + "bugs": { + "url": "https://gitlab.com/LoicBersier/DiscordBot/issues" + }, + "homepage": "https://gitlab.com/LoicBersier/DiscordBot#readme", + "description": "" } From cb7e32957d5d261452852c4d2256df0ee2118eb2 Mon Sep 17 00:00:00 2001 From: Supositware Date: Wed, 2 Jan 2019 18:59:32 +0100 Subject: [PATCH 08/20] return nothing when nothing have been specified --- commands/general/clap.js | 2 ++ commands/general/reddit.js | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/commands/general/clap.js b/commands/general/clap.js index 732d80ce..4869cb42 100644 --- a/commands/general/clap.js +++ b/commands/general/clap.js @@ -21,6 +21,8 @@ class ClapCommand extends Command { } async exec(message, args) { + if (!args.text) + return; let clap = args.text.replace(/ /g, ' šŸ‘ '); message.delete(); message.channel.send(`${clap} šŸ‘`); diff --git a/commands/general/reddit.js b/commands/general/reddit.js index e2444d78..ad23aeaf 100644 --- a/commands/general/reddit.js +++ b/commands/general/reddit.js @@ -12,9 +12,6 @@ class RedditCommand extends Command { { id: 'sub', type: 'string', - prompt: { - retry: 'That\'s not a valid subreddit! try again.' - }, } ], description: { @@ -28,6 +25,8 @@ class RedditCommand extends Command { async exec(message, args) { let sub = args.sub; let i, a; + if (!sub) + return; fetch('https://www.reddit.com/r/' + sub + '.json?limit=100').then((response) => { return response.json(); From 6218675e5029153e107d3bc2c784f3906cd6c118 Mon Sep 17 00:00:00 2001 From: Supositware Date: Wed, 2 Jan 2019 19:05:32 +0100 Subject: [PATCH 09/20] --- listeners/message.js | 66 ++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/listeners/message.js b/listeners/message.js index c64718d8..cd855d63 100644 --- a/listeners/message.js +++ b/listeners/message.js @@ -1,7 +1,7 @@ const { Listener } = require('discord-akairo'); -const responseObject = require("../json/reply.json"); -const reactObject = require("../json/react.json"); -const imgResponseObject = require("../json/imgreply.json"); +const responseObject = require('../json/reply.json'); +const reactObject = require('../json/react.json'); +const imgResponseObject = require('../json/imgreply.json'); const reload = require('auto-reload'); class MessageListener extends Listener { @@ -13,39 +13,39 @@ class MessageListener extends Listener { } async exec(message) { - let autoresponse = reload('../json/autoresponse.json'); - let message_content = message.content.toLowerCase(); + let autoresponse = reload('../json/autoresponse.json'); + let message_content = message.content.toLowerCase(); + let customresponse = reload(`../tag/${message.guild.id}.json`); - if (message.author.bot) return; { - - // If autoresponse is enable send the response - if(autoresponse[message.channel.id] == 'enable') { - // Reply with images as attachement - if(imgResponseObject[message_content]) { - message.channel.send({files: [imgResponseObject[message_content]]}); - } - // React only to the messages - else if(reactObject[message_content]) { - message.react(reactObject[message_content]); - } - // auto respond to messages - else if(responseObject[message_content]) { - message.channel.send(responseObject[message_content]); - // If it contain "like if" react with šŸ‘ - } else if (message_content.includes("like if")) { - message.react("\u{1F44D}") - // If it contain "jeff" react with a jeff emote - } else if (message_content.includes("jeff")) { - message.react("496028845967802378") - } - } - let customresponse = reload(`../tag/${message.guild.id}.json`); - // User autoresponse - if(customresponse[message_content]) { - message.channel.send(customresponse[message_content]) - } + if (message.author.bot) return; { + // User autoresponse + if(customresponse[message_content]) { + message.channel.send(customresponse[message_content]); } + + // If autoresponse is enable send the response + if(autoresponse[message.channel.id] == 'enable') { + // Reply with images as attachement + if(imgResponseObject[message_content]) { + message.channel.send({files: [imgResponseObject[message_content]]}); + } + // React only to the messages + else if(reactObject[message_content]) { + message.react(reactObject[message_content]); + } + // auto respond to messages + else if(responseObject[message_content]) { + message.channel.send(responseObject[message_content]); + // If it contain 'like if' react with šŸ‘ + } else if (message_content.includes('like if')) { + message.react('\u{1F44D}'); + // If it contain 'jeff' react with a jeff emote + } else if (message_content.includes('jeff')) { + message.react('496028845967802378'); + } + } + } } } From 40396fda669a9b27485335afa51b1bba5b211da4 Mon Sep 17 00:00:00 2001 From: Supositware Date: Wed, 2 Jan 2019 21:46:12 +0100 Subject: [PATCH 10/20] Change for Akairo V8 --- listeners/commandblocked.js | 2 +- listeners/guildCreate.js | 2 +- listeners/guildDelete.js | 2 +- listeners/message.js | 14 +++++++------- listeners/messageReactionAdd.js | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/listeners/commandblocked.js b/listeners/commandblocked.js index fc92a050..6fed8c79 100644 --- a/listeners/commandblocked.js +++ b/listeners/commandblocked.js @@ -4,7 +4,7 @@ class CommandBlockedListener extends Listener { constructor() { super('commandBlocked', { emitter: 'commandHandler', - eventName: 'commandBlocked' + event: 'commandBlocked' }); } diff --git a/listeners/guildCreate.js b/listeners/guildCreate.js index c20b9f2c..aba20968 100644 --- a/listeners/guildCreate.js +++ b/listeners/guildCreate.js @@ -7,7 +7,7 @@ class guildCreateListener extends Listener { constructor() { super('guildCreate', { emitter: 'client', - eventName: 'guildCreate' + event: 'guildCreate' }); } diff --git a/listeners/guildDelete.js b/listeners/guildDelete.js index c6ba9741..7c993c59 100644 --- a/listeners/guildDelete.js +++ b/listeners/guildDelete.js @@ -7,7 +7,7 @@ class guildCreateListener extends Listener { constructor() { super('guildDelete', { emitter: 'client', - eventName: 'guildDelete' + event: 'guildDelete' }); } diff --git a/listeners/message.js b/listeners/message.js index cd855d63..2085e020 100644 --- a/listeners/message.js +++ b/listeners/message.js @@ -4,11 +4,11 @@ const reactObject = require('../json/react.json'); const imgResponseObject = require('../json/imgreply.json'); const reload = require('auto-reload'); -class MessageListener extends Listener { +class messageListener extends Listener { constructor() { super('message', { emitter: 'client', - eventName: 'message' + event: 'message' }); } @@ -16,14 +16,14 @@ class MessageListener extends Listener { let autoresponse = reload('../json/autoresponse.json'); let message_content = message.content.toLowerCase(); let customresponse = reload(`../tag/${message.guild.id}.json`); - + if (message.author.bot) return; { - + // User autoresponse if(customresponse[message_content]) { message.channel.send(customresponse[message_content]); } - + // If autoresponse is enable send the response if(autoresponse[message.channel.id] == 'enable') { // Reply with images as attachement @@ -44,9 +44,9 @@ class MessageListener extends Listener { } else if (message_content.includes('jeff')) { message.react('496028845967802378'); } - } + } } } } -module.exports = MessageListener; \ No newline at end of file +module.exports = messageListener; \ No newline at end of file diff --git a/listeners/messageReactionAdd.js b/listeners/messageReactionAdd.js index 4c2e247e..a1c82574 100644 --- a/listeners/messageReactionAdd.js +++ b/listeners/messageReactionAdd.js @@ -6,7 +6,7 @@ class MessageReactionAddListener extends Listener { constructor() { super('messagereactionadd', { emitter: 'client', - eventName: 'messageReactionAdd' + event: 'messageReactionAdd' }); } From 2f3bb99759923465ddc609f662c49abc20402eaa Mon Sep 17 00:00:00 2001 From: Supositware Date: Wed, 2 Jan 2019 21:46:45 +0100 Subject: [PATCH 11/20] reduced commandutilLifetime --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 7db9c31a..579f034d 100644 --- a/index.js +++ b/index.js @@ -14,7 +14,7 @@ class hahaYesClient extends AkairoClient { directory: './commands/', prefix: prefix, commandUtil: true, - commandUtilLifetime: 600000, + commandUtilLifetime: 60000, allowMention: true, handleEdits: true, }); From 7abc70a9af8bda09aae05d75a634130e2231e4e7 Mon Sep 17 00:00:00 2001 From: Supositware Date: Wed, 2 Jan 2019 22:35:11 +0100 Subject: [PATCH 12/20] show if autoresponse is enable in this channel --- commands/utility/stats.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/commands/utility/stats.js b/commands/utility/stats.js index f8fb1b7c..3212727b 100644 --- a/commands/utility/stats.js +++ b/commands/utility/stats.js @@ -1,5 +1,6 @@ const { Command } = require('discord-akairo'); const { MessageEmbed } = require('discord.js'); +const reload = require('auto-reload'); class StatsCommand extends Command { constructor() { @@ -15,6 +16,10 @@ class StatsCommand extends Command { } async exec(message) { + const autoresponse = reload('../../json/autoresponse.json'); + if (autoresponse[message.channel.id] == undefined) + var autoresponseStatus = 'disable'; + let totalSeconds = (this.client.uptime / 1000); let days = Math.floor(totalSeconds / 86400); let hours = Math.floor(totalSeconds / 3600); @@ -33,6 +38,7 @@ class StatsCommand extends Command { .addField('Users', this.client.users.size, true) .addField('Uptime', uptime, true) .addField('Ram usage', `${Math.round(used * 100) / 100} MB`, true) + .addField('Autoresponse in this channel',autoresponseStatus,true) .setTimestamp() .setFooter('Powered by Yandex.Translate '); From f8e5f531d678cef4e5d2bc6f2c5cdd6cf822bdbb Mon Sep 17 00:00:00 2001 From: Supositware Date: Wed, 2 Jan 2019 22:36:29 +0100 Subject: [PATCH 13/20] --- commands/utility/stats.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/commands/utility/stats.js b/commands/utility/stats.js index 3212727b..35ba85d9 100644 --- a/commands/utility/stats.js +++ b/commands/utility/stats.js @@ -17,8 +17,11 @@ class StatsCommand extends Command { async exec(message) { const autoresponse = reload('../../json/autoresponse.json'); - if (autoresponse[message.channel.id] == undefined) - var autoresponseStatus = 'disable'; + let autoresponseStatus; + if (autoresponse[message.channel.id] == undefined || autoresponse[message.channel.id] == 'disable') + autoresponseStatus = 'disabled'; + else if (autoresponse[message.channel.id] == 'enable') + autoresponseStatus = 'enabled'; let totalSeconds = (this.client.uptime / 1000); let days = Math.floor(totalSeconds / 86400); From bdfcc6945342adf4ea63095ed5c4f222803e7295 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 3 Jan 2019 14:22:39 +0100 Subject: [PATCH 14/20] --- .eslintrc.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 82ca6058..73bee58c 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -16,10 +16,6 @@ "error", "tab" ], - "linebreak-style": [ - "error", - "windows" - ], "quotes": [ "error", "single" From e9868775a66fd7adf4e6fb97b9aa02f7d5043b62 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 3 Jan 2019 16:10:36 +0100 Subject: [PATCH 15/20] Forgot a semicolon --- commands/utility/invite.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/utility/invite.js b/commands/utility/invite.js index 79a94ae1..aa3f75d9 100644 --- a/commands/utility/invite.js +++ b/commands/utility/invite.js @@ -15,7 +15,7 @@ class InviteCommand extends Command { } async exec(message) { - message.channel.send('Check your dm') + message.channel.send('Check your dm'); return message.author.send(`You can add me from here: https://discordapp.com/oauth2/authorize?client_id=${this.client.user.id}&scope=bot&permissions=0\nYou can also join my support server over here: ${supportServer} come and say hi :)`); } } From 7b1c64df083c025a94d980d103ee76844609dd29 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 3 Jan 2019 17:17:24 +0100 Subject: [PATCH 16/20] --- .gitignore | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 5937bb56..7c3b6008 100644 --- a/.gitignore +++ b/.gitignore @@ -5,10 +5,8 @@ node_modules node_modules\ .vscode video.mp4 -json/autoresponse.json json/blacklist.json json/customresponse.json -tag/* -starboard/* tts.mp3 ttsvc.mp3 +starboard/487640086859743232.json From bb954a78bd2e728b2e1957c8cdd8d764e7871004 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 3 Jan 2019 17:17:30 +0100 Subject: [PATCH 17/20] forgot that file --- json/autoresponse.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 json/autoresponse.json diff --git a/json/autoresponse.json b/json/autoresponse.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/json/autoresponse.json @@ -0,0 +1 @@ +{} \ No newline at end of file From e6660a371de3c03f0847998d0026da0c5115b814 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 3 Jan 2019 17:18:29 +0100 Subject: [PATCH 18/20] Dosen't duplicate entry in starboard anymore --- json/starboard.json | 1 + listeners/messageReactionAdd.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 json/starboard.json diff --git a/json/starboard.json b/json/starboard.json new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/json/starboard.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/listeners/messageReactionAdd.js b/listeners/messageReactionAdd.js index a1c82574..4f94af4e 100644 --- a/listeners/messageReactionAdd.js +++ b/listeners/messageReactionAdd.js @@ -1,6 +1,7 @@ const { Listener } = require('discord-akairo'); const { MessageEmbed } = require('discord.js'); const reload = require('auto-reload'); +let messageID = require('../json/starboard.json'); class MessageReactionAddListener extends Listener { constructor() { @@ -15,6 +16,11 @@ class MessageReactionAddListener extends Listener { let messageAttachments = reaction.message.attachments.map(u=> `${u.url}`); if (reaction.emoji.name === 'šŸŒŸ' && reaction.count === 4) { + if (messageID.includes(reaction.message.id)) + return console.log('Message already in starboard!'); + + messageID.push(reaction.message.id); + let starboardChannel = reload(`../starboard/${reaction.message.guild.id}.json`); const channel = this.client.channels.get(starboardChannel['starboard']); @@ -25,9 +31,14 @@ class MessageReactionAddListener extends Listener { .setTimestamp(); channel.send({ embed: starEmbed}); - return channel.send(`From: ${reaction.message.channel}\n${messageAttachments}`); + return channel.send(`From: ${reaction.message.channel} ID: ${reaction.message.id} \n${messageAttachments}`); } if (reaction.emoji.name === 'āœ”' && reaction.count === 4) { + if (messageID.includes(reaction.message.id)) + return console.log('Message already in starboard!'); + + messageID.push(reaction.message.id); + let shameboardChannel = reload(`../starboard/${message.guild.id}.json`); const channel = client.channels.get(shameboardChannel['shameboard']); From 97b312625e76d3e8b70a9a49e09d87bd76ece486 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 3 Jan 2019 17:28:31 +0100 Subject: [PATCH 19/20] removed footer text --- commands/utility/stats.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/commands/utility/stats.js b/commands/utility/stats.js index 35ba85d9..b649f2d7 100644 --- a/commands/utility/stats.js +++ b/commands/utility/stats.js @@ -42,9 +42,8 @@ class StatsCommand extends Command { .addField('Uptime', uptime, true) .addField('Ram usage', `${Math.round(used * 100) / 100} MB`, true) .addField('Autoresponse in this channel',autoresponseStatus,true) - .setTimestamp() - .setFooter('Powered by Yandex.Translate '); - + .setTimestamp(); + return message.channel.send(statsEmbed); } } From 084e5cb21e625487e6783688a171b792bb8f4c00 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 3 Jan 2019 17:52:54 +0100 Subject: [PATCH 20/20] fixed shameboard --- listeners/messageReactionAdd.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/listeners/messageReactionAdd.js b/listeners/messageReactionAdd.js index 4f94af4e..d4485ad6 100644 --- a/listeners/messageReactionAdd.js +++ b/listeners/messageReactionAdd.js @@ -11,7 +11,7 @@ class MessageReactionAddListener extends Listener { }); } - async exec(reaction, message, client) { + async exec(reaction) { let messageContent = reaction.message.content; let messageAttachments = reaction.message.attachments.map(u=> `${u.url}`); @@ -36,26 +36,21 @@ class MessageReactionAddListener extends Listener { if (reaction.emoji.name === 'āœ”' && reaction.count === 4) { if (messageID.includes(reaction.message.id)) return console.log('Message already in starboard!'); - + messageID.push(reaction.message.id); - let shameboardChannel = reload(`../starboard/${message.guild.id}.json`); - const channel = client.channels.get(shameboardChannel['shameboard']); + let shameboardChannel = reload(`../starboard/${reaction.message.guild.id}.json`); + const channel = this.client.channels.get(shameboardChannel['shameboard']); - const starEmbed = new MessageEmbed() + const shameEmbed = new MessageEmbed() .setColor() .setDescription(messageContent) .setAuthor(reaction.message.author.username, reaction.message.author.displayAvatarURL) .setTimestamp(); - try { - channel.send({ embed: starEmbed}); - await channel.send(messageAttachments); - } catch(err) { - console.error('There is no shameboard'); - } + channel.send({ embed: shameEmbed}); + return channel.send(`From: ${reaction.message.channel} ID: ${reaction.message.id} \n${messageAttachments}`); } - } }