From 7e5eb5e4f4e9cb9c74303f0a369eb01fcf59add6 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 28 Nov 2019 15:36:18 +0100 Subject: [PATCH 01/10] Various check for user first --- commands/general/tweet.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/commands/general/tweet.js b/commands/general/tweet.js index 9c89644..ec2d89a 100644 --- a/commands/general/tweet.js +++ b/commands/general/tweet.js @@ -33,9 +33,25 @@ class tweetCommand extends Command { } async exec(message, args) { - const client = this.client; let date = new Date(); let Attachment = (message.attachments).array(); + // see if user is not banned + const blacklist = await TwitterBlacklist.findOne({where: {userID:message.author.id}}); + if (blacklist) { + return message.channel.send(`You have been blacklisted for the following reasons: \`\`${blacklist.get('reason')}\`\` be less naughty less time.`); + } + + // If account is younger than 6 months old don't accept attachment + if (Attachment[0] && message.author.createdAt > date.setMonth(date.getMonth() - 6)) { + return message.channel.send('Your account need to be 6 months or older to be able to send attachment!'); + } + + // Don't let account new account use this command to prevent spam + if (message.author.createdAt > date.setDate(date.getDate() - 7)) { + return message.channel.send('Your account is too new to be able to use this command!'); + } + + const client = this.client; if (!Attachment[0] && !args.text) return message.channel.send('You need to input something for me to tweet!'); @@ -54,22 +70,6 @@ class tweetCommand extends Command { filter.removeWords(...uncensor); */ - // see if user is not banned - const blacklist = await TwitterBlacklist.findOne({where: {userID:message.author.id}}); - if (blacklist) { - return message.channel.send(`You have been blacklisted for the following reasons: \`\`${blacklist.get('reason')}\`\` be less naughty less time.`); - } - - // If account is younger than 6 months old don't accept attachment - if (Attachment[0] && message.author.createdAt > date.setMonth(date.getMonth() - 6)) { - return message.channel.send('Your account need to be 6 months or older to be able to send attachment!'); - } - - // Don't let account new account use this command to prevent spam - if (message.author.createdAt > date.setDate(date.getDate() - 7)) { - return message.channel.send('Your account is too new to be able to use this command!'); - } - // remove zero width space let text = ''; if (args.text) { From 15354ea108035f5652bed0e66fcec20edb6a8d13 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 28 Nov 2019 15:40:34 +0100 Subject: [PATCH 02/10] Show error message when image is too big --- commands/general/tweet.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/commands/general/tweet.js b/commands/general/tweet.js index ec2d89a..05a0019 100644 --- a/commands/general/tweet.js +++ b/commands/general/tweet.js @@ -50,10 +50,10 @@ class tweetCommand extends Command { if (message.author.createdAt > date.setDate(date.getDate() - 7)) { return message.channel.send('Your account is too new to be able to use this command!'); } - - const client = this.client; - + if (!Attachment[0] && !args.text) return message.channel.send('You need to input something for me to tweet!'); + + const client = this.client; let T = new Twit({ consumer_key: twiConsumer, @@ -148,6 +148,7 @@ class tweetCommand extends Command { T.post('statuses/update', options, function (err, response) { if (err) { + if (err.code == 324) return message.channel.send(err.message); console.error('OH NO!!!!'); console.error(err); return message.channel.send('OH NO!!! AN ERROR HAS OCCURED!!! please hold on while i find what\'s causing this issue! '); @@ -179,7 +180,6 @@ class tweetCommand extends Command { channel = client.channels.get(twiChannel); channel.send({embed: Embed}); - return message.channel.send(`Go see ur epic tweet https://twitter.com/i/status/${tweetid}`); }); } From 2c395c6552b6d5bab663044acd0edc5b979f87ea Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 28 Nov 2019 15:46:25 +0100 Subject: [PATCH 03/10] Show error messages from twitter api --- commands/general/tweet.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/commands/general/tweet.js b/commands/general/tweet.js index 05a0019..fd5d205 100644 --- a/commands/general/tweet.js +++ b/commands/general/tweet.js @@ -83,12 +83,6 @@ class tweetCommand extends Command { text = rand.random(text, message); } - - - if (text.length > 280) { - return message.channel.send('Your message is more than the 280 characters limit!'); - } - try { // Make sure there is an attachment and if its an image if (Attachment[0]) { @@ -148,7 +142,10 @@ class tweetCommand extends Command { T.post('statuses/update', options, function (err, response) { if (err) { - if (err.code == 324) return message.channel.send(err.message); + if (err.code == 88) return message.channel.send(err.message); // Rate limit exceeded + if (err.code == 186) return message.channel.send(err.message); // Tweet needs to be a bit shorter. + if (err.code == 187) return message.channel.send(err.message); // Status is a duplicate. + if (err.code == 326) return message.channel.send(err.message); // To protect our users from spam and other malicious activity, this account is temporarily locked. console.error('OH NO!!!!'); console.error(err); return message.channel.send('OH NO!!! AN ERROR HAS OCCURED!!! please hold on while i find what\'s causing this issue! '); From 63515aa73aba3146f17c1241a39101fac5388785 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Fri, 29 Nov 2019 21:50:22 +0100 Subject: [PATCH 04/10] Show nickname if user is in guild --- commands/fun/fakebot.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/commands/fun/fakebot.js b/commands/fun/fakebot.js index 149ec55..742cc97 100644 --- a/commands/fun/fakebot.js +++ b/commands/fun/fakebot.js @@ -8,7 +8,7 @@ class fakebotCommand extends Command { clientPermissions: ['MANAGE_WEBHOOKS'], args: [ { - id: 'member', + id: 'user', type: 'user', prompt: { start: 'Who should i fake?', @@ -35,20 +35,25 @@ class fakebotCommand extends Command { async exec(message, args) { let Attachment = (message.attachments).array(); let url; + let username = args.user.username; // Get attachment link if (Attachment[0]) { url = Attachment[0].url; } + // Show nickname if user is in guild + if (message.guild.members.get(args.user.id)) { + username = message.guild.members.get(args.user.id).nickname; + } - message.channel.createWebhook(args.member.username, { - avatar: args.member.displayAvatarURL(), + message.channel.createWebhook(username, { + avatar: args.user.displayAvatarURL(), reason: `Fakebot/user command triggered by: ${message.author.username}` }) .then(webhook => { // Have to edit after creation otherwise the picture doesn't get applied webhook.edit({ - name: args.member.username, - avatar: args.member.displayAvatarURL(), + name: username, + avatar: args.user.displayAvatarURL(), reason: `Fakebot/user command triggered by: ${message.author.username}` }); this.client.fetchWebhook(webhook.id, webhook.token) @@ -61,7 +66,9 @@ class fakebotCommand extends Command { webhook.send(args.message); setTimeout(() => { - webhook.delete(); + webhook.delete({ + reason: `Fakebot/user command triggered by: ${message.author.username}` + }); }, 3000); }); }); From 35378dfa07360c9a0d6414922b03b0faa40a7f28 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Fri, 29 Nov 2019 21:56:00 +0100 Subject: [PATCH 05/10] fix nickname thing --- commands/fun/fakebot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/fun/fakebot.js b/commands/fun/fakebot.js index 742cc97..59bf160 100644 --- a/commands/fun/fakebot.js +++ b/commands/fun/fakebot.js @@ -41,7 +41,7 @@ class fakebotCommand extends Command { url = Attachment[0].url; } // Show nickname if user is in guild - if (message.guild.members.get(args.user.id)) { + if (message.guild.members.get(args.user.id).nickname) { username = message.guild.members.get(args.user.id).nickname; } From 868779edf745393bfe9ebaa7cc6c3e029ce2d52b Mon Sep 17 00:00:00 2001 From: loicbersier Date: Fri, 29 Nov 2019 22:04:26 +0100 Subject: [PATCH 06/10] fix(?) the nickname --- commands/fun/fakebot.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/commands/fun/fakebot.js b/commands/fun/fakebot.js index 59bf160..8fe460b 100644 --- a/commands/fun/fakebot.js +++ b/commands/fun/fakebot.js @@ -36,13 +36,16 @@ class fakebotCommand extends Command { let Attachment = (message.attachments).array(); let url; let username = args.user.username; + let member = message.guild.members.get(args.user.id); // Get attachment link if (Attachment[0]) { url = Attachment[0].url; } // Show nickname if user is in guild - if (message.guild.members.get(args.user.id).nickname) { - username = message.guild.members.get(args.user.id).nickname; + if (member) { + if (member.nickname) { + username = member.nickname; + } } message.channel.createWebhook(username, { From 4e86a6f3c530daf1d613d1159129725fdf148056 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Fri, 29 Nov 2019 22:29:56 +0100 Subject: [PATCH 07/10] Don't send message when missing perm --- event/listeners/missingPermissions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/event/listeners/missingPermissions.js b/event/listeners/missingPermissions.js index a991d56..947f3c4 100644 --- a/event/listeners/missingPermissions.js +++ b/event/listeners/missingPermissions.js @@ -12,7 +12,7 @@ class missingPermissionsListener extends Listener { switch(type) { case 'client': if (missing == 'SEND_MESSAGES') { - return message.author.send(`Im missing the required permissions for this command!, \`${missing}\``); + return; } else { message.reply(`Im missing the required permissions for this command!, \`${missing}\``); } From 422a7b69db8dddc58039d8529467303bad3c6f13 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sat, 30 Nov 2019 19:06:11 +0100 Subject: [PATCH 08/10] let people use this command without manage message perm --- commands/general/say.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/commands/general/say.js b/commands/general/say.js index e4ce714..ca8e431 100644 --- a/commands/general/say.js +++ b/commands/general/say.js @@ -7,7 +7,7 @@ class SayCommand extends Command { super('say', { aliases: ['say', 'sayd'], category: 'general', - clientPermissions: ['SEND_MESSAGES', 'MANAGE_MESSAGES'], + clientPermissions: ['SEND_MESSAGES'], args: [ { id: 'text', @@ -148,11 +148,18 @@ class SayCommand extends Command { // Send the final text if (attach) { if (message.util.parsed.alias == 'sayd') - message.delete(); + if (message.channel.permissionsFor(this.client.user).has('MANAGE_MESSAGES')) + message.delete(); + else + message.channel.send('Im missing he `MANAGE_MESSAGES` perm to delete your message!'); + return message.channel.send(text, {files: [attach]}); } else { if (message.util.parsed.alias == 'sayd') - message.delete(); + if (message.channel.permissionsFor(this.client.user).has('MANAGE_MESSAGES')) + message.delete(); + else + message.channel.send('Im missing he `MANAGE_MESSAGES` perm to delete your message!'); return message.channel.send(text); } } From b208a5af8f184a6fa2f8b756910942034b4c5f94 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Tue, 3 Dec 2019 00:26:15 +0100 Subject: [PATCH 09/10] Rock paper scissors --- commands/minigame/rps.js | 65 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 commands/minigame/rps.js diff --git a/commands/minigame/rps.js b/commands/minigame/rps.js new file mode 100644 index 0000000..d58139e --- /dev/null +++ b/commands/minigame/rps.js @@ -0,0 +1,65 @@ +const { Command } = require('discord-akairo'); + +class rpsCommand extends Command { + constructor() { + super('rps', { + aliases: ['rps', 'rockpapersci'], + category: 'minigame', + clientPermissions: ['SEND_MESSAGES'], + args: [ + { + id: 'selection', + type: 'string', + match: 'rest', + }, + ], + description: { + content: 'Simply rock paper scissors\nCredit to: druid#0425 (276882603158798336))', + usage: '[rock/paper/scissors]', + examples: ['rock'] + } + }); + } + + async exec(message, args) { + let pcHand = Math.floor((Math.random()*3)+1); + let playerHand = args.selection; + + switch (playerHand) { + case 'rock': + if (pcHand==1) { + message.channel.send('You both chose rock!'); + } else if (pcHand==2) { + message.channel.send('The bot chose paper, you lose!'); + } else { + message.channel.send('The bot chose scissors, you win!'); + } + break; + case 'paper': + if (pcHand==1) { + message.channel.send('You both chose paper!'); + } else if (pcHand==2) { + message.channel.send('The bot chose scissors, you lose!'); + } else { + message.channel.send('The bot chose rock, you win!'); + } + break; + case 'scissors': + if (pcHand==1) { + message.channel.send('You both chose scissors!'); + } else if (pcHand==2) { + message.channel.send('The bot chose rock, you lose!'); + } else { + message.channel.send('The bot chose paper, you win!'); + } + break; + + default: + message.channel.send(`You entered ${playerHand} which is an incorrect choice.`); + break; + } + + } +} + +module.exports = rpsCommand; \ No newline at end of file From a65b2c90871b0de5c25f1ca83e2197d7cc7835cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bersier?= Date: Mon, 2 Dec 2019 23:36:33 +0000 Subject: [PATCH 10/10] Removed useless ) --- commands/minigame/rps.js | 130 +++++++++++++++++++-------------------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/commands/minigame/rps.js b/commands/minigame/rps.js index d58139e..60f9f01 100644 --- a/commands/minigame/rps.js +++ b/commands/minigame/rps.js @@ -1,65 +1,65 @@ -const { Command } = require('discord-akairo'); - -class rpsCommand extends Command { - constructor() { - super('rps', { - aliases: ['rps', 'rockpapersci'], - category: 'minigame', - clientPermissions: ['SEND_MESSAGES'], - args: [ - { - id: 'selection', - type: 'string', - match: 'rest', - }, - ], - description: { - content: 'Simply rock paper scissors\nCredit to: druid#0425 (276882603158798336))', - usage: '[rock/paper/scissors]', - examples: ['rock'] - } - }); - } - - async exec(message, args) { - let pcHand = Math.floor((Math.random()*3)+1); - let playerHand = args.selection; - - switch (playerHand) { - case 'rock': - if (pcHand==1) { - message.channel.send('You both chose rock!'); - } else if (pcHand==2) { - message.channel.send('The bot chose paper, you lose!'); - } else { - message.channel.send('The bot chose scissors, you win!'); - } - break; - case 'paper': - if (pcHand==1) { - message.channel.send('You both chose paper!'); - } else if (pcHand==2) { - message.channel.send('The bot chose scissors, you lose!'); - } else { - message.channel.send('The bot chose rock, you win!'); - } - break; - case 'scissors': - if (pcHand==1) { - message.channel.send('You both chose scissors!'); - } else if (pcHand==2) { - message.channel.send('The bot chose rock, you lose!'); - } else { - message.channel.send('The bot chose paper, you win!'); - } - break; - - default: - message.channel.send(`You entered ${playerHand} which is an incorrect choice.`); - break; - } - - } -} - -module.exports = rpsCommand; \ No newline at end of file +const { Command } = require('discord-akairo'); + +class rpsCommand extends Command { + constructor() { + super('rps', { + aliases: ['rps', 'rockpapersci'], + category: 'minigame', + clientPermissions: ['SEND_MESSAGES'], + args: [ + { + id: 'selection', + type: 'string', + match: 'rest', + }, + ], + description: { + content: 'Simply rock paper scissors\nCredit to: druid#0425 (276882603158798336)', + usage: '[rock/paper/scissors]', + examples: ['rock'] + } + }); + } + + async exec(message, args) { + let pcHand = Math.floor((Math.random()*3)+1); + let playerHand = args.selection; + + switch (playerHand) { + case 'rock': + if (pcHand==1) { + message.channel.send('You both chose rock!'); + } else if (pcHand==2) { + message.channel.send('The bot chose paper, you lose!'); + } else { + message.channel.send('The bot chose scissors, you win!'); + } + break; + case 'paper': + if (pcHand==1) { + message.channel.send('You both chose paper!'); + } else if (pcHand==2) { + message.channel.send('The bot chose scissors, you lose!'); + } else { + message.channel.send('The bot chose rock, you win!'); + } + break; + case 'scissors': + if (pcHand==1) { + message.channel.send('You both chose scissors!'); + } else if (pcHand==2) { + message.channel.send('The bot chose rock, you lose!'); + } else { + message.channel.send('The bot chose paper, you win!'); + } + break; + + default: + message.channel.send(`You entered ${playerHand} which is an incorrect choice.`); + break; + } + + } +} + +module.exports = rpsCommand;