diff --git a/commands/fun/fakebot.js b/commands/fun/fakebot.js index 149ec55..8fe460b 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,28 @@ class fakebotCommand extends Command { async exec(message, args) { 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 (member) { + if (member.nickname) { + username = member.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 +69,9 @@ class fakebotCommand extends Command { webhook.send(args.message); setTimeout(() => { - webhook.delete(); + webhook.delete({ + reason: `Fakebot/user command triggered by: ${message.author.username}` + }); }, 3000); }); }); 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); } } diff --git a/commands/general/tweet.js b/commands/general/tweet.js index 9c89644..fd5d205 100644 --- a/commands/general/tweet.js +++ b/commands/general/tweet.js @@ -33,11 +33,27 @@ 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!'); + } + 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, @@ -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) { @@ -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,6 +142,10 @@ class tweetCommand extends Command { T.post('statuses/update', options, function (err, response) { if (err) { + 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! '); @@ -179,7 +177,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}`); }); } diff --git a/commands/minigame/rps.js b/commands/minigame/rps.js new file mode 100644 index 0000000..60f9f01 --- /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; 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}\``); }