From 91d2c2fc68a315405b0e5f044de43d4681ae7278 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Thu, 25 Jan 2018 06:08:06 +0000 Subject: [PATCH 01/23] Version 6.6.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 57e4713b8..9808042fa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bastion", - "version": "6.6.1", + "version": "6.6.2", "description": "Bastion: A Discord Bot that can do Administration, Moderation, Searches, can play Music, Games, has User Levels, Virtual Currencies, a good sense of Humor and can even talk with you!", "url": "https://bastionbot.org/", "main": "index.js", From ffe68ce05bf2af976347f52d3433762afcdb8d71 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Thu, 25 Jan 2018 06:10:15 +0000 Subject: [PATCH 02/23] Using special IDs instead of getPatrons in claim; Fix #96 --- changes.json | 12 +++--------- modules/money/claim.js | 7 ++----- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/changes.json b/changes.json index 0766cd1f1..d80b6dd56 100644 --- a/changes.json +++ b/changes.json @@ -1,15 +1,9 @@ { - "date": "January 24, 2018", + "date": "January 25, 2018", "fixed": [ - "Fixed crashes when Cleverbot API didn't returned any response.", - "Fixed Bastion not stopping the typing event.", - "Fixed `claim` not working for uncached guild members." - ], - "improved": [ - "You can now give Bastion Currencies without having to mention them; just use their IDs. Yeah, less annoying.", - "If there's no one in the voice channel, Bastion will automatically pause the music.", - "Under-the-hood improvements" + "Fixed `claim` crashes when there was no Patreon API key." ], + "improved": [], "added": [], "removed": [], "issues": [] diff --git a/modules/money/claim.js b/modules/money/claim.js index 51129f9b1..f75132462 100644 --- a/modules/money/claim.js +++ b/modules/money/claim.js @@ -7,14 +7,11 @@ let claimedUsers = []; const specialIDs = require('../../data/specialIDs.json'); -exports.exec = async (Bastion, message) => { +exports.exec = (Bastion, message) => { if (!claimedUsers.includes(message.author.id)) { let rewardAmount; - let patrons = await Bastion.functions.getPatrons(754397); - patrons = patrons.map(patron => patron.discord_id); - - if (patrons.includes(message.author.id)) { + if (message.member && message.member.roles.has(specialIDs.patronsRole)) { rewardAmount = Bastion.functions.getRandomInt(100, 150); } else if (message.member && message.member.roles.has(specialIDs.donorsRole)) { From cdc92e2d3a983ef2c00c2ca1cd2780c144500b00 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Thu, 25 Jan 2018 06:55:04 +0000 Subject: [PATCH 03/23] getPatrons func doesn't need campaign ID anymore --- changes.json | 4 ++- functions/getPatrons.js | 65 ++++++++++++++++++++++++----------------- 2 files changed, 42 insertions(+), 27 deletions(-) diff --git a/changes.json b/changes.json index d80b6dd56..28e7ec416 100644 --- a/changes.json +++ b/changes.json @@ -3,7 +3,9 @@ "fixed": [ "Fixed `claim` crashes when there was no Patreon API key." ], - "improved": [], + "improved": [ + "Under-the-hood improvements" + ], "added": [], "removed": [], "issues": [] diff --git a/functions/getPatrons.js b/functions/getPatrons.js index 51fa9158b..d0cc36bed 100644 --- a/functions/getPatrons.js +++ b/functions/getPatrons.js @@ -1,45 +1,58 @@ const request = require('request-promise-native'); const patreon = require('../settings/credentials.json').patreon; -module.exports = (campaignID) => { +module.exports = () => { return new Promise(async (resolve, reject) => { try { let options = { headers: { 'Authorization': `Bearer ${patreon ? patreon.creatorAccessToken : undefined}` }, - uri: `https://www.patreon.com/api/oauth2/api/campaigns/${campaignID}/pledges`, + uri: 'https://www.patreon.com/api/oauth2/api/current_user/campaigns', json: true }; let response = await request(options); - let data = response.data; - let included = response.included; - - let pledges = data.filter(data => data.type === 'pledge'); - let users = included.filter(inc => inc.type === 'user'); - - let patrons = pledges.map(pledge => { - let id = pledge.relationships.patron.data.id; - let user = users.filter(user => user.id === pledge.relationships.patron.data.id)[0]; - - return { - id: id, - full_name: user.attributes.full_name, - vanity: user.attributes.vanity, - email: user.attributes.email, - discord_id: user.attributes.social_connections.discord.user_id, - amount_cents: pledge.attributes.amount_cents, - created_at: pledge.attributes.created_at, - declined_since: pledge.attributes.declined_since, - patron_pays_fees: pledge.attributes.patron_pays_fees, - pledge_cap_cents: pledge.attributes.pledge_cap_cents, - image_url: user.attributes.image_url + if (!response && response.data && response.data.length) { + options = { + headers: { + 'Authorization': `Bearer ${patreon ? patreon.creatorAccessToken : undefined}` + }, + uri: `https://www.patreon.com/api/oauth2/api/campaigns/${response.data[0].id}/pledges`, + json: true }; - }); + response = await request(options); - resolve(patrons); + let data = response.data; + let included = response.included; + + let pledges = data.filter(data => data.type === 'pledge'); + let users = included.filter(inc => inc.type === 'user'); + + let patrons = pledges.map(pledge => { + let id = pledge.relationships.patron.data.id; + let user = users.filter(user => user.id === pledge.relationships.patron.data.id)[0]; + + return { + id: id, + full_name: user.attributes.full_name, + vanity: user.attributes.vanity, + email: user.attributes.email, + discord_id: user.attributes.social_connections.discord.user_id, + amount_cents: pledge.attributes.amount_cents, + created_at: pledge.attributes.created_at, + declined_since: pledge.attributes.declined_since, + patron_pays_fees: pledge.attributes.patron_pays_fees, + pledge_cap_cents: pledge.attributes.pledge_cap_cents, + image_url: user.attributes.image_url + }; + }); + + resolve(patrons); + } + + reject('Not a Patreon Creator.'); } catch (e) { reject(e); From 4cc4f82dadc559c2aaa2551953aa99ea7eab1937 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Thu, 25 Jan 2018 06:56:36 +0000 Subject: [PATCH 04/23] Fixed a typo; My bad --- functions/getPatrons.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/getPatrons.js b/functions/getPatrons.js index d0cc36bed..cbcabb97a 100644 --- a/functions/getPatrons.js +++ b/functions/getPatrons.js @@ -14,7 +14,7 @@ module.exports = () => { let response = await request(options); - if (!response && response.data && response.data.length) { + if (response && response.data && response.data.length) { options = { headers: { 'Authorization': `Bearer ${patreon ? patreon.creatorAccessToken : undefined}` From 328e04449b9bb44c4343a70cb0b66e6340270122 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Thu, 25 Jan 2018 09:24:53 +0000 Subject: [PATCH 05/23] Improvements to patrons command * Will now show the list of Patrons of the Patreon creator whose API key is used. --- changes.json | 1 + locales/en/modules.json | 2 +- modules/info/patrons.js | 14 +++++++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/changes.json b/changes.json index 28e7ec416..dcc46fb88 100644 --- a/changes.json +++ b/changes.json @@ -4,6 +4,7 @@ "Fixed `claim` crashes when there was no Patreon API key." ], "improved": [ + "Are you a Patreon creator and hosting Bastion yourself? The `patrons` command will now show your patrons and not the patrons of the Bastion bot project.", "Under-the-hood improvements" ], "added": [], diff --git a/locales/en/modules.json b/locales/en/modules.json index d35ed0252..43dd7524c 100644 --- a/locales/en/modules.json +++ b/locales/en/modules.json @@ -149,7 +149,7 @@ "emojiInfo": "Shows information of a specifed emoji of your Discord server.", "inRole": "Shows members that have a specifed role in your Discord server.", "level": "Shows the current level of the specified user's account.", - "patrons": "Shows the list of people who continuously supports the development of the Bastion Bot project, by being my patron, on [Patreon](https://patreon.com/snkrsnkampa).", + "patrons": "Shows the list of people who continuously supports the development of the Bastion Bot project, by being my patron, on [Patreon](https://patreon.com/snkrsnkampa). But if you're hosting Bastion yourself, and you're a Patreon creator, it will show the list of your Patrons.", "ping": "Shows the response time and average WebSocket ping of Bastion.", "profile": "Shows Bastion user profile of a specified user of your Discord server.", "roleID": "Shows the ID of a specified role of your Discord server.", diff --git a/modules/info/patrons.js b/modules/info/patrons.js index a57855be3..a4e3b2ed8 100644 --- a/modules/info/patrons.js +++ b/modules/info/patrons.js @@ -6,17 +6,25 @@ exports.exec = async (Bastion, message, args) => { try { - let patrons = await Bastion.functions.getPatrons(754397); + let patrons = await Bastion.functions.getPatrons(); patrons = patrons.map(patron => patron.full_name); let noOfPages = patrons.length / 50; let i = (args.page > 0 && args.page < noOfPages + 1) ? args.page : 1; i = i - 1; + let description; + if (Bastion.user.id === '267035345537728512') { + description = 'These are the awesome people who continuously support the development of the Bastion bot project, by being my patron, on [Patreon](https://patreon.com/snkrsnkampa).\nIf you want to support the development of Bastion too, [be my Patron](https://patreon.com/bePatron?c=754397)'; + } + else { + description = 'These are the awesome people who continuously support us, by being our patron, on Patreon.'; + } + message.channel.send({ embed: { color: 16345172, - description: 'These are the awesome people who continuously support the development of the Bastion Bot project by being my patron on [Patreon](https://patreon.com/snkrsnkampa).', + description: description, fields: [ { name: 'Patrons', @@ -24,7 +32,7 @@ exports.exec = async (Bastion, message, args) => { } ], footer: { - text: `Page: ${i + 1} of ${noOfPages > parseInt(noOfPages) ? parseInt(noOfPages) + 1 : parseInt(noOfPages)} • https://patreon.com/snkrsnkampa` + text: `Page: ${i + 1} of ${noOfPages > parseInt(noOfPages) ? parseInt(noOfPages) + 1 : parseInt(noOfPages)}` } } }).catch(e => { From 81259f3010f76b3eef355e0d06d547ced03457c0 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Thu, 25 Jan 2018 14:20:16 +0000 Subject: [PATCH 06/23] Minor change to command log --- handlers/commandHandler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/commandHandler.js b/handlers/commandHandler.js index 1399a5c23..10f9b0457 100644 --- a/handlers/commandHandler.js +++ b/handlers/commandHandler.js @@ -96,7 +96,7 @@ module.exports = async message => { if (message.client.shard) { message.client.log.console(`${COLOR.green('[SHARD]:')} ${message.client.shard.id}`); } - message.client.log.console(`${COLOR.green('[SERVER]:')} ${message.guild} ${COLOR.cyan(`<#${message.guild.id}>`)}`); + message.client.log.console(`${COLOR.green('[SERVER]:')} ${message.guild} ${COLOR.cyan(message.guild.id)}`); message.client.log.console(`${COLOR.green('[CHANNEL]:')} #${message.channel.name} ${COLOR.cyan(message.channel)}`); message.client.log.console(`${COLOR.green('[USER]:')} ${message.author.tag} ${COLOR.cyan(`${message.author}`)}`); From e0614b897bf65ccf74a661174070c51c0d580118 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Fri, 26 Jan 2018 12:06:13 +0000 Subject: [PATCH 07/23] Reject bmp image - createEmoji command --- modules/administration/createEmoji.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/administration/createEmoji.js b/modules/administration/createEmoji.js index e6512b073..a2e2510e9 100644 --- a/modules/administration/createEmoji.js +++ b/modules/administration/createEmoji.js @@ -6,7 +6,7 @@ exports.exec = async (Bastion, message, args) => { try { - if (!args.url || !/^(https?:\/\/)((([-a-z0-9]{1,})?(-?)+[-a-z0-9]{1,})(\.))+([a-z]{1,63})\/((([a-z0-9._\-~#%])+\/)+)?([a-z0-9._\-~#%]+)\.(jpg|jpeg|gif|png|bmp)$/i.test(args.url) || !args.name) { + if (!args.url || !/^(https?:\/\/)((([-a-z0-9]{1,})?(-?)+[-a-z0-9]{1,})(\.))+([a-z]{1,63})\/((([a-z0-9._\-~#%])+\/)+)?([a-z0-9._\-~#%]+)\.(jpg|jpeg|gif|png)$/i.test(args.url) || !args.name) { /** * The command was ran with invalid parameters. * @fires commandUsage From 384f2a736c12f246ad6c07c3940db7790313e009 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Sat, 27 Jan 2018 03:56:25 +0000 Subject: [PATCH 08/23] removeAllRoles will now accept user ID --- changes.json | 3 ++- modules/moderation/removeAllRoles.js | 22 +++++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/changes.json b/changes.json index dcc46fb88..80a7d898d 100644 --- a/changes.json +++ b/changes.json @@ -1,10 +1,11 @@ { - "date": "January 25, 2018", + "date": "January 27, 2018", "fixed": [ "Fixed `claim` crashes when there was no Patreon API key." ], "improved": [ "Are you a Patreon creator and hosting Bastion yourself? The `patrons` command will now show your patrons and not the patrons of the Bastion bot project.", + "`removeAllRoles` can be used with the ID of the user. No need to mention them anymore.", "Under-the-hood improvements" ], "added": [], diff --git a/modules/moderation/removeAllRoles.js b/modules/moderation/removeAllRoles.js index 5edb843d8..51b88ae97 100644 --- a/modules/moderation/removeAllRoles.js +++ b/modules/moderation/removeAllRoles.js @@ -6,7 +6,7 @@ exports.exec = async (Bastion, message, args) => { try { - if (args.length < 1) { + if (args.user) { /** * The command was ran with invalid parameters. * @fires commandUsage @@ -14,7 +14,16 @@ exports.exec = async (Bastion, message, args) => { return Bastion.emit('commandUsage', message, this.help); } - let user = message.mentions.users.first(); + let user; + if (message.mentions.users.size) { + user = message.mentions.users.first(); + } + else if (args.id) { + user = await message.guild.fetchMember(args.id); + if (user) { + user = user.user; + } + } if (!user) { user = message.author; } @@ -46,7 +55,10 @@ exports.exec = async (Bastion, message, args) => { exports.config = { aliases: [ 'removeallr' ], - enabled: true + enabled: true, + argsDefinitions: [ + { name: 'user', type: String, defaultOption: true } + ] }; exports.help = { @@ -54,6 +66,6 @@ exports.help = { botPermission: 'MANAGE_ROLES', userTextPermission: 'MANAGE_ROLES', userVoicePermission: '', - usage: 'removeAllRoles [@user-mention]', - example: [ 'removeAllRoles @user#0001', 'removeAllRoles' ] + usage: 'removeAllRoles [ @USER_MENTION | USER_ID ]', + example: [ 'removeAllRoles @user#0001', 'removeAllRoles 282424753565461211', 'removeAllRoles' ] }; From 60db42725f05fb794c703c1e49d9d1164107d6b3 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Sat, 27 Jan 2018 03:58:22 +0000 Subject: [PATCH 09/23] Minor typo fix --- modules/moderation/removeAllRoles.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/moderation/removeAllRoles.js b/modules/moderation/removeAllRoles.js index 51b88ae97..687e64492 100644 --- a/modules/moderation/removeAllRoles.js +++ b/modules/moderation/removeAllRoles.js @@ -6,7 +6,7 @@ exports.exec = async (Bastion, message, args) => { try { - if (args.user) { + if (args.id) { /** * The command was ran with invalid parameters. * @fires commandUsage @@ -57,7 +57,7 @@ exports.config = { aliases: [ 'removeallr' ], enabled: true, argsDefinitions: [ - { name: 'user', type: String, defaultOption: true } + { name: 'id', type: String, defaultOption: true } ] }; From 786b83c6210b81f105e1041101233623936b8dcc Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Sat, 27 Jan 2018 04:03:49 +0000 Subject: [PATCH 10/23] deafen command now accepts user ID --- changes.json | 2 +- modules/moderation/deafen.js | 27 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/changes.json b/changes.json index 80a7d898d..04c7860f7 100644 --- a/changes.json +++ b/changes.json @@ -5,7 +5,7 @@ ], "improved": [ "Are you a Patreon creator and hosting Bastion yourself? The `patrons` command will now show your patrons and not the patrons of the Bastion bot project.", - "`removeAllRoles` can be used with the ID of the user. No need to mention them anymore.", + "`removeAllRoles` and `deafen` commands can be used with the ID of the user. No need to mention them anymore.", "Under-the-hood improvements" ], "added": [], diff --git a/modules/moderation/deafen.js b/modules/moderation/deafen.js index 3b48e094d..54e7e415e 100644 --- a/modules/moderation/deafen.js +++ b/modules/moderation/deafen.js @@ -6,7 +6,13 @@ exports.exec = async (Bastion, message, args) => { try { - let user = message.mentions.users.first(); + let user; + if (message.mentions.users.size) { + user = message.mentions.users.first(); + } + else if (args.id) { + user = await Bastion.fetchUser(args.id); + } if (!user) { /** * The command was ran with invalid parameters. @@ -20,15 +26,10 @@ exports.exec = async (Bastion, message, args) => { await member.setDeaf(true); - let reason = args.slice(1).join(' '); - if (reason.length < 1) { - reason = 'No reason given'; - } - message.channel.send({ embed: { color: Bastion.colors.ORANGE, - description: `${message.author.tag} deafened ${user.tag} with reason **${reason}**` + description: `${message.author.tag} deafened ${user.tag} with reason **${args.reason}**` } }).catch(e => { Bastion.log.error(e); @@ -38,7 +39,7 @@ exports.exec = async (Bastion, message, args) => { * Logs moderation events if it is enabled * @fires moderationLog */ - Bastion.emit('moderationLog', message.guild, message.author, this.help.name, user, reason); + Bastion.emit('moderationLog', message.guild, message.author, this.help.name, user, args.reason); } catch (e) { Bastion.log.error(e); @@ -47,7 +48,11 @@ exports.exec = async (Bastion, message, args) => { exports.config = { aliases: [ 'deaf' ], - enabled: true + enabled: true, + argsDefinitions: [ + { name: 'id', type: String, defaultOption: true }, + { name: 'reason', alias: 'r', type: String, multiple: true, defaultValue: [ 'No reason given.' ] } + ] }; exports.help = { @@ -55,6 +60,6 @@ exports.help = { botPermission: 'DEAFEN_MEMBERS', userTextPermission: 'DEAFEN_MEMBERS', userVoicePermission: '', - usage: 'deafen @user-mention [Reason]', - example: [ 'deafen @user#0001 Reason for the deafening.' ] + usage: 'deafen <@USER_MENTION | USER_ID> -r [Reason]', + example: [ 'deafen @user#001 -r Shouting like crazy', 'deafen 167147569575323761 -r Profanity' ] }; From f72f2a5305fdf96415abf3a1a17ab0d0d9f2d089 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Sat, 27 Jan 2018 04:08:38 +0000 Subject: [PATCH 11/23] kick command now accepts user ID --- changes.json | 2 +- modules/moderation/kick.js | 31 ++++++++++++++++++------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/changes.json b/changes.json index 04c7860f7..573529c2e 100644 --- a/changes.json +++ b/changes.json @@ -5,7 +5,7 @@ ], "improved": [ "Are you a Patreon creator and hosting Bastion yourself? The `patrons` command will now show your patrons and not the patrons of the Bastion bot project.", - "`removeAllRoles` and `deafen` commands can be used with the ID of the user. No need to mention them anymore.", + "`removeAllRoles`, `deafen` and `kick` commands can be used with the ID of the user. No need to mention them anymore.", "Under-the-hood improvements" ], "added": [], diff --git a/modules/moderation/kick.js b/modules/moderation/kick.js index 1f5dfc9e2..56b609b97 100644 --- a/modules/moderation/kick.js +++ b/modules/moderation/kick.js @@ -6,7 +6,13 @@ exports.exec = async (Bastion, message, args) => { try { - let user = message.mentions.users.first(); + let user; + if (message.mentions.users.size) { + user = message.mentions.users.first(); + } + else if (args.id) { + user = await Bastion.fetchUser(args.id); + } if (!user) { /** * The command was ran with invalid parameters. @@ -26,17 +32,12 @@ exports.exec = async (Bastion, message, args) => { return Bastion.emit('error', Bastion.strings.error(message.guild.language, 'forbidden'), Bastion.strings.error(message.guild.language, 'noPermission', true, 'kick', user), message.channel); } - let reason = args.slice(1).join(' '); - if (reason.length < 1) { - reason = 'No given reason'; - } - - await member.kick(reason); + await member.kick(args.reason); message.channel.send({ embed: { color: Bastion.colors.RED, - description: `${message.author.tag} kicked ${user.tag} with reason **${reason}**`, + description: `${message.author.tag} kicked ${user.tag} with reason **${args.reason}**`, footer: { text: `ID ${user.id}` } @@ -49,12 +50,12 @@ exports.exec = async (Bastion, message, args) => { * Logs moderation events if it is enabled * @fires moderationLog */ - Bastion.emit('moderationLog', message.guild, message.author, this.help.name, member, reason); + Bastion.emit('moderationLog', message.guild, message.author, this.help.name, member, args.reason); member.send({ embed: { color: Bastion.colors.RED, - description: `${message.author.tag} kicked you from **${message.guild.name}** server with reason **${reason}**` + description: `${message.author.tag} kicked you from **${message.guild.name}** server with reason **${args.reason}**` } }).catch(e => { Bastion.log.error(e); @@ -67,7 +68,11 @@ exports.exec = async (Bastion, message, args) => { exports.config = { aliases: [ 'k' ], - enabled: true + enabled: true, + argsDefinitions: [ + { name: 'id', type: String, defaultOption: true }, + { name: 'reason', alias: 'r', type: String, multiple: true, defaultValue: [ 'No reason given.' ] } + ] }; exports.help = { @@ -75,6 +80,6 @@ exports.help = { botPermission: 'KICK_MEMBERS', userTextPermission: 'KICK_MEMBERS', userVoicePermission: '', - usage: 'kick @user-mention [Reason]', - example: [ 'kick @user#0001 Reason for the kick.' ] + usage: 'kick <@USER_MENTION | USER_ID> -r [Reason]', + example: [ 'kick @user#001 -r Being rude to everyone.', 'kick 167147569575323761 -r Spamming' ] }; From 6bc45e2756147ccf093f3fb21ebb08da39abd576 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Sat, 27 Jan 2018 04:12:12 +0000 Subject: [PATCH 12/23] mute command now accepts user ID --- changes.json | 2 +- modules/moderation/mute.js | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/changes.json b/changes.json index 573529c2e..48b7a6790 100644 --- a/changes.json +++ b/changes.json @@ -5,7 +5,7 @@ ], "improved": [ "Are you a Patreon creator and hosting Bastion yourself? The `patrons` command will now show your patrons and not the patrons of the Bastion bot project.", - "`removeAllRoles`, `deafen` and `kick` commands can be used with the ID of the user. No need to mention them anymore.", + "`removeAllRoles`, `deafen`, `kick` and `mute` commands can be used with the ID of the user. No need to mention them anymore.", "Under-the-hood improvements" ], "added": [], diff --git a/modules/moderation/mute.js b/modules/moderation/mute.js index 8e22b50f1..1f31767fd 100644 --- a/modules/moderation/mute.js +++ b/modules/moderation/mute.js @@ -6,7 +6,13 @@ exports.exec = async (Bastion, message, args) => { try { - let user = message.mentions.users.first(); + let user; + if (message.mentions.users.size) { + user = message.mentions.users.first(); + } + else if (args.id) { + user = await Bastion.fetchUser(args.id); + } if (!user) { /** * The command was ran with invalid parameters. @@ -20,15 +26,12 @@ exports.exec = async (Bastion, message, args) => { await member.setMute(true); - let reason = args.slice(1).join(' '); - if (reason.length < 1) { - reason = 'No reason given'; - } + args.reason = args.reason.join(' '); message.channel.send({ embed: { color: Bastion.colors.ORANGE, - description: `${message.author.tag} voice-muted ${user.tag} with reason **${reason}**` + description: `${message.author.tag} voice-muted ${user.tag} with reason **${args.reason}**` } }).catch(e => { Bastion.log.error(e); @@ -38,7 +41,7 @@ exports.exec = async (Bastion, message, args) => { * Logs moderation events if it is enabled * @fires moderationLog */ - Bastion.emit('moderationLog', message.guild, message.author, this.help.name, user, reason); + Bastion.emit('moderationLog', message.guild, message.author, this.help.name, user, args.reason); } catch (e) { Bastion.log.error(e); @@ -47,7 +50,11 @@ exports.exec = async (Bastion, message, args) => { exports.config = { aliases: [ 'm' ], - enabled: true + enabled: true, + argsDefinitions: [ + { name: 'id', type: String, defaultOption: true }, + { name: 'reason', alias: 'r', type: String, multiple: true, defaultValue: [ 'No reason given.' ] } + ] }; exports.help = { From b777e147d51c87561790f15e3437b19512c586fb Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Sat, 27 Jan 2018 04:14:40 +0000 Subject: [PATCH 13/23] Fixed invalid joining of mod reasons - kick, mute commands --- modules/moderation/deafen.js | 2 ++ modules/moderation/kick.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/modules/moderation/deafen.js b/modules/moderation/deafen.js index 54e7e415e..781f7c5d1 100644 --- a/modules/moderation/deafen.js +++ b/modules/moderation/deafen.js @@ -26,6 +26,8 @@ exports.exec = async (Bastion, message, args) => { await member.setDeaf(true); + args.reason = args.reason.join(' '); + message.channel.send({ embed: { color: Bastion.colors.ORANGE, diff --git a/modules/moderation/kick.js b/modules/moderation/kick.js index 56b609b97..db2a4b766 100644 --- a/modules/moderation/kick.js +++ b/modules/moderation/kick.js @@ -34,6 +34,8 @@ exports.exec = async (Bastion, message, args) => { await member.kick(args.reason); + args.reason = args.reason.join(' '); + message.channel.send({ embed: { color: Bastion.colors.RED, From 6f49c42014ba76e58ea0ce330af1325778381317 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Sat, 27 Jan 2018 04:17:40 +0000 Subject: [PATCH 14/23] clearWarn command now accepts user ID --- changes.json | 2 +- modules/moderation/clearWarn.js | 27 +++++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/changes.json b/changes.json index 48b7a6790..527808f77 100644 --- a/changes.json +++ b/changes.json @@ -5,7 +5,7 @@ ], "improved": [ "Are you a Patreon creator and hosting Bastion yourself? The `patrons` command will now show your patrons and not the patrons of the Bastion bot project.", - "`removeAllRoles`, `deafen`, `kick` and `mute` commands can be used with the ID of the user. No need to mention them anymore.", + "`clearWarn`, `removeAllRoles`, `deafen`, `kick` and `mute` commands can be used with the ID of the user. No need to mention them anymore.", "Under-the-hood improvements" ], "added": [], diff --git a/modules/moderation/clearWarn.js b/modules/moderation/clearWarn.js index 250376f97..980975b0e 100644 --- a/modules/moderation/clearWarn.js +++ b/modules/moderation/clearWarn.js @@ -6,7 +6,13 @@ exports.exec = async (Bastion, message, args) => { try { - let user = message.mentions.users.first(); + let user; + if (message.mentions.users.size) { + user = message.mentions.users.first(); + } + else if (args.id) { + user = await Bastion.fetchUser(args.id); + } if (!user) { /** * The command was ran with invalid parameters. @@ -18,10 +24,7 @@ exports.exec = async (Bastion, message, args) => { let member = await message.guild.fetchMember(user.id); if (message.author.id !== message.guild.ownerID && message.member.highestRole.comparePositionTo(member.highestRole) <= 0) return Bastion.log.info(Bastion.strings.error(message.guild.language, 'lowerRole', true)); - let reason = args.slice(1).join(' '); - if (reason.length < 1) { - reason = 'No given reason'; - } + args.reason = args.reason.join(' '); if (!message.guild.warns) { /** @@ -42,7 +45,7 @@ exports.exec = async (Bastion, message, args) => { message.channel.send({ embed: { color: Bastion.colors.GREEN, - description: `${message.author.tag} cleared the warnings for ${user.tag} with reason **${reason}**` + description: `${message.author.tag} cleared the warnings for ${user.tag} with reason **${args.reason}**` } }).catch(e => { Bastion.log.error(e); @@ -52,7 +55,7 @@ exports.exec = async (Bastion, message, args) => { * Logs moderation events if it is enabled * @fires moderationLog */ - Bastion.emit('moderationLog', message.guild, message.author, this.help.name, user, reason); + Bastion.emit('moderationLog', message.guild, message.author, this.help.name, user, args.reason); } catch (e) { Bastion.log.error(e); @@ -61,7 +64,11 @@ exports.exec = async (Bastion, message, args) => { exports.config = { aliases: [ 'warnClear' ], - enabled: true + enabled: true, + argsDefinitions: [ + { name: 'id', type: String, defaultOption: true }, + { name: 'reason', alias: 'r', type: String, multiple: true, defaultValue: [ 'No reason given.' ] } + ] }; exports.help = { @@ -69,6 +76,6 @@ exports.help = { botPermission: '', userTextPermission: 'KICK_MEMBERS', userVoicePermission: '', - usage: 'clearWarn @user-mention [Reason]', - example: [ 'clearWarn @user#0001 Reason for clearing the warning.' ] + usage: 'clearWarn <@USER_MENTION | USER_ID> -r [Reason]', + example: [ 'clearWarn @user#001 -r Advertisement', 'clearWarn 167147569575323761 -r Invite links' ] }; From 742209428cd7a9e438065a54fe3ba5fa4421eb80 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Sat, 27 Jan 2018 04:19:42 +0000 Subject: [PATCH 15/23] Updated usage & example - mute command --- modules/moderation/mute.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/moderation/mute.js b/modules/moderation/mute.js index 1f31767fd..b96c0ec0c 100644 --- a/modules/moderation/mute.js +++ b/modules/moderation/mute.js @@ -62,6 +62,6 @@ exports.help = { botPermission: 'MUTE_MEMBERS', userTextPermission: 'MUTE_MEMBERS', userVoicePermission: '', - usage: 'mute @user-mention [Reason]', - example: [ 'mute @user#0001 Reason for the mute.' ] + usage: 'mute <@USER_MENTION | USER_ID> -r [Reason]', + example: [ 'mute @user#001 -r Shouting like crazy', 'mute 167147569575323761 -r Singing like a broken radio' ] }; From 0feea91c28828120732dca14a2794938a4fb6558 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Sat, 27 Jan 2018 04:21:02 +0000 Subject: [PATCH 16/23] Updated example - clearwarn command --- modules/moderation/clearWarn.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/moderation/clearWarn.js b/modules/moderation/clearWarn.js index 980975b0e..90902668a 100644 --- a/modules/moderation/clearWarn.js +++ b/modules/moderation/clearWarn.js @@ -77,5 +77,5 @@ exports.help = { userTextPermission: 'KICK_MEMBERS', userVoicePermission: '', usage: 'clearWarn <@USER_MENTION | USER_ID> -r [Reason]', - example: [ 'clearWarn @user#001 -r Advertisement', 'clearWarn 167147569575323761 -r Invite links' ] + example: [ 'clearWarn @user#001 -r Apologized', 'clearWarn 167147569575323761 -r Forgiven' ] }; From 2a850a194e01336e2fae152bcc02b6bffa298377 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Sat, 27 Jan 2018 04:23:54 +0000 Subject: [PATCH 17/23] warn command now accepts user ID --- changes.json | 2 +- modules/moderation/warn.js | 29 ++++++++++++++++++----------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/changes.json b/changes.json index 527808f77..a8ec3512b 100644 --- a/changes.json +++ b/changes.json @@ -5,7 +5,7 @@ ], "improved": [ "Are you a Patreon creator and hosting Bastion yourself? The `patrons` command will now show your patrons and not the patrons of the Bastion bot project.", - "`clearWarn`, `removeAllRoles`, `deafen`, `kick` and `mute` commands can be used with the ID of the user. No need to mention them anymore.", + "`clearWarn`, `removeAllRoles`, `deafen`, `kick`, `mute` and `warn` commands can be used with the ID of the user. No need to mention them anymore.", "Under-the-hood improvements" ], "added": [], diff --git a/modules/moderation/warn.js b/modules/moderation/warn.js index 9f46b2773..8a6e163c0 100644 --- a/modules/moderation/warn.js +++ b/modules/moderation/warn.js @@ -6,7 +6,13 @@ exports.exec = async (Bastion, message, args) => { try { - let user = message.mentions.users.first(); + let user; + if (message.mentions.users.size) { + user = message.mentions.users.first(); + } + else if (args.id) { + user = await Bastion.fetchUser(args.id); + } if (!user) { /** * The command was ran with invalid parameters. @@ -18,10 +24,7 @@ exports.exec = async (Bastion, message, args) => { let member = await message.guild.fetchMember(user.id); if (message.author.id !== message.guild.ownerID && message.member.highestRole.comparePositionTo(member.highestRole) <= 0) return Bastion.log.info(Bastion.strings.error(message.guild.language, 'lowerRole', true)); - let reason = args.slice(1).join(' '); - if (reason.length < 1) { - reason = 'No given reason'; - } + args.reason = args.reason.join(' '); if (!message.guild.warns) { message.guild.warns = {}; @@ -123,7 +126,7 @@ exports.exec = async (Bastion, message, args) => { message.channel.send({ embed: { color: Bastion.colors.ORANGE, - description: `${message.author.tag} warned ${user.tag} with reason **${reason}**` + description: `${message.author.tag} warned ${user.tag} with reason **${args.reason}**` } }).catch(e => { Bastion.log.error(e); @@ -133,7 +136,7 @@ exports.exec = async (Bastion, message, args) => { DMChannel.send({ embed: { color: Bastion.colors.ORANGE, - description: `${message.author.tag} warned you in **${message.guild.name}** server with reason **${reason}**` + description: `${message.author.tag} warned you in **${message.guild.name}** server with reason **${args.reason}**` } }).catch(e => { Bastion.log.error(e); @@ -143,7 +146,7 @@ exports.exec = async (Bastion, message, args) => { * Logs moderation events if it is enabled * @fires moderationLog */ - Bastion.emit('moderationLog', message.guild, message.author, this.help.name, user, reason); + Bastion.emit('moderationLog', message.guild, message.author, this.help.name, user, args.reason); } catch (e) { Bastion.log.error(e); @@ -152,7 +155,11 @@ exports.exec = async (Bastion, message, args) => { exports.config = { aliases: [ 'w' ], - enabled: true + enabled: true, + argsDefinitions: [ + { name: 'id', type: String, defaultOption: true }, + { name: 'reason', alias: 'r', type: String, multiple: true, defaultValue: [ 'No reason given.' ] } + ] }; exports.help = { @@ -160,6 +167,6 @@ exports.help = { botPermission: 'KICK_MEMBERS', userTextPermission: 'KICK_MEMBERS', userVoicePermission: '', - usage: 'warn @user-mention [Reason]', - example: [ 'warn @user#0001 Reason for the warning.' ] + usage: 'warn <@USER_MENTION | USER_ID> -r [Reason]', + example: [ 'warn @user#001 -r NSFW in non NSFW channels', 'warn 167147569575323761 -r Advertisements' ] }; From a915a3cefcbf173f10251c4c67cf45280669ad40 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Sat, 27 Jan 2018 04:25:58 +0000 Subject: [PATCH 18/23] unMute command now accepts user ID --- changes.json | 2 +- modules/moderation/unMute.js | 27 +++++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/changes.json b/changes.json index a8ec3512b..a429cc04e 100644 --- a/changes.json +++ b/changes.json @@ -5,7 +5,7 @@ ], "improved": [ "Are you a Patreon creator and hosting Bastion yourself? The `patrons` command will now show your patrons and not the patrons of the Bastion bot project.", - "`clearWarn`, `removeAllRoles`, `deafen`, `kick`, `mute` and `warn` commands can be used with the ID of the user. No need to mention them anymore.", + "`clearWarn`, `removeAllRoles`, `deafen`, `kick`, `mute`, `unMute` and `warn` commands can be used with the ID of the user. No need to mention them anymore.", "Under-the-hood improvements" ], "added": [], diff --git a/modules/moderation/unMute.js b/modules/moderation/unMute.js index 86ef38c10..33c88f834 100644 --- a/modules/moderation/unMute.js +++ b/modules/moderation/unMute.js @@ -6,7 +6,13 @@ exports.exec = async (Bastion, message, args) => { try { - let user = message.mentions.users.first(); + let user; + if (message.mentions.users.size) { + user = message.mentions.users.first(); + } + else if (args.id) { + user = await Bastion.fetchUser(args.id); + } if (!user) { /** * The command was ran with invalid parameters. @@ -18,17 +24,14 @@ exports.exec = async (Bastion, message, args) => { let member = await message.guild.fetchMember(user.id); if (message.author.id !== message.guild.ownerID && message.member.highestRole.comparePositionTo(member.highestRole) <= 0) return Bastion.log.info(Bastion.strings.error(message.guild.language, 'lowerRole', true)); - let reason = args.slice(1).join(' '); - if (reason.length < 1) { - reason = 'No reason given'; - } + args.reason = args.reason.join(' '); await member.setMute(false); message.channel.send({ embed: { color: Bastion.colors.GREEN, - description: `${message.author.tag} voice-unmuted ${user.tag} with reason **${reason}**` + description: `${message.author.tag} voice-unmuted ${user.tag} with reason **${args.reason}**` } }).catch(e => { Bastion.log.error(e); @@ -38,7 +41,7 @@ exports.exec = async (Bastion, message, args) => { * Logs moderation events if it is enabled * @fires moderationLog */ - Bastion.emit('moderationLog', message.guild, message.author, this.help.name, user, reason); + Bastion.emit('moderationLog', message.guild, message.author, this.help.name, user, args.reason); } catch (e) { Bastion.log.error(e); @@ -47,7 +50,11 @@ exports.exec = async (Bastion, message, args) => { exports.config = { aliases: [], - enabled: true + enabled: true, + argsDefinitions: [ + { name: 'id', type: String, defaultOption: true }, + { name: 'reason', alias: 'r', type: String, multiple: true, defaultValue: [ 'No reason given.' ] } + ] }; exports.help = { @@ -55,6 +62,6 @@ exports.help = { botPermission: 'MUTE_MEMBERS', userTextPermission: 'MUTE_MEMBERS', userVoicePermission: '', - usage: 'unMute @user-mention [Reason]', - example: [ 'unMute @user#0001 Reason for the unmute.' ] + usage: 'unMute <@USER_MENTION | USER_ID> -r [Reason]', + example: [ 'unMute @user#001 -r Apologized', 'unMute 167147569575323761 -r Forgiven' ] }; From 3cecf9c9405b54ed9e1c825eca89adcc46e172e2 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Sat, 27 Jan 2018 04:27:26 +0000 Subject: [PATCH 19/23] unDeafen command now accepts user ID --- changes.json | 2 +- modules/moderation/unDeafen.js | 27 +++++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/changes.json b/changes.json index a429cc04e..69e850b8c 100644 --- a/changes.json +++ b/changes.json @@ -5,7 +5,7 @@ ], "improved": [ "Are you a Patreon creator and hosting Bastion yourself? The `patrons` command will now show your patrons and not the patrons of the Bastion bot project.", - "`clearWarn`, `removeAllRoles`, `deafen`, `kick`, `mute`, `unMute` and `warn` commands can be used with the ID of the user. No need to mention them anymore.", + "`clearWarn`, `removeAllRoles`, `deafen`, `kick`, `mute`, `unDeafen`, `unMute` and `warn` commands can be used with the ID of the user. No need to mention them anymore.", "Under-the-hood improvements" ], "added": [], diff --git a/modules/moderation/unDeafen.js b/modules/moderation/unDeafen.js index 91839ce52..ae1c331bf 100644 --- a/modules/moderation/unDeafen.js +++ b/modules/moderation/unDeafen.js @@ -6,7 +6,13 @@ exports.exec = async (Bastion, message, args) => { try { - let user = message.mentions.users.first(); + let user; + if (message.mentions.users.size) { + user = message.mentions.users.first(); + } + else if (args.id) { + user = await Bastion.fetchUser(args.id); + } if (!user) { /** * The command was ran with invalid parameters. @@ -18,17 +24,14 @@ exports.exec = async (Bastion, message, args) => { let member = await message.guild.fetchMember(user.id); if (message.author.id !== message.guild.ownerID && message.member.highestRole.comparePositionTo(member.highestRole) <= 0) return Bastion.log.info(Bastion.strings.error(message.guild.language, 'lowerRole', true)); - let reason = args.slice(1).join(' '); - if (reason.length < 1) { - reason = 'No reason given'; - } + args.reason = args.reason.join(' '); await member.setDeaf(false); message.channel.send({ embed: { color: Bastion.colors.GREEN, - description: `${message.author.tag} undeafend ${user.tag} with reason **${reason}**` + description: `${message.author.tag} undeafend ${user.tag} with reason **${args.reason}**` } }).catch(e => { Bastion.log.error(e); @@ -38,7 +41,7 @@ exports.exec = async (Bastion, message, args) => { * Logs moderation events if it is enabled * @fires moderationLog */ - Bastion.emit('moderationLog', message.guild, message.author, this.help.name, user, reason); + Bastion.emit('moderationLog', message.guild, message.author, this.help.name, user, args.reason); } catch (e) { Bastion.log.error(e); @@ -47,7 +50,11 @@ exports.exec = async (Bastion, message, args) => { exports.config = { aliases: [ 'undeaf' ], - enabled: true + enabled: true, + argsDefinitions: [ + { name: 'id', type: String, defaultOption: true }, + { name: 'reason', alias: 'r', type: String, multiple: true, defaultValue: [ 'No reason given.' ] } + ] }; exports.help = { @@ -55,6 +62,6 @@ exports.help = { botPermission: 'DEAFEN_MEMBERS', userTextPermission: 'DEAFEN_MEMBERS', userVoicePermission: '', - usage: 'unDeafen @user-mention [Reason]', - example: [ 'unDeafen @user#0001 Reason for undeafening.' ] + usage: 'unDeafen <@USER_MENTION | USER_ID> -r [Reason]', + example: [ 'unDeafen @user#001 -r Apologized', 'unDeafen 167147569575323761 -r Forgiven' ] }; From 1d28dece6ce873870a245d4306dfc4f98fac4fc3 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Sat, 27 Jan 2018 04:29:08 +0000 Subject: [PATCH 20/23] textUnMute command now accepts user ID --- changes.json | 2 +- modules/moderation/textUnMute.js | 27 +++++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/changes.json b/changes.json index 69e850b8c..d4203042d 100644 --- a/changes.json +++ b/changes.json @@ -5,7 +5,7 @@ ], "improved": [ "Are you a Patreon creator and hosting Bastion yourself? The `patrons` command will now show your patrons and not the patrons of the Bastion bot project.", - "`clearWarn`, `removeAllRoles`, `deafen`, `kick`, `mute`, `unDeafen`, `unMute` and `warn` commands can be used with the ID of the user. No need to mention them anymore.", + "`clearWarn`, `removeAllRoles`, `deafen`, `kick`, `mute`, `textUnMute`, `unDeafen`, `unMute` and `warn` commands can be used with the ID of the user. No need to mention them anymore.", "Under-the-hood improvements" ], "added": [], diff --git a/modules/moderation/textUnMute.js b/modules/moderation/textUnMute.js index 601541acf..4b63086f1 100644 --- a/modules/moderation/textUnMute.js +++ b/modules/moderation/textUnMute.js @@ -6,7 +6,13 @@ exports.exec = async (Bastion, message, args) => { try { - let user = message.mentions.users.first(); + let user; + if (message.mentions.users.size) { + user = message.mentions.users.first(); + } + else if (args.id) { + user = await Bastion.fetchUser(args.id); + } if (!user) { /** * The command was ran with invalid parameters. @@ -22,15 +28,12 @@ exports.exec = async (Bastion, message, args) => { if (permissionOverwrites) { await permissionOverwrites.delete(); - let reason = args.slice(1).join(' '); - if (reason.length < 1) { - reason = 'No reason given'; - } + args.reason = args.reason.join(' '); message.channel.send({ embed: { color: Bastion.colors.GREEN, - description: `${message.author.tag} text-unmuted ${user.tag} with reason **${reason}**` + description: `${message.author.tag} text-unmuted ${user.tag} with reason **${args.reason}**` } }).catch(e => { Bastion.log.error(e); @@ -40,7 +43,7 @@ exports.exec = async (Bastion, message, args) => { * Logs moderation events if it is enabled * @fires moderationLog */ - Bastion.emit('moderationLog', message.guild, message.author, this.help.name, user, reason, { + Bastion.emit('moderationLog', message.guild, message.author, this.help.name, user, args.reason, { channel: message.channel }); } @@ -52,7 +55,11 @@ exports.exec = async (Bastion, message, args) => { exports.config = { aliases: [ 'tum' ], - enabled: true + enabled: true, + argsDefinitions: [ + { name: 'id', type: String, defaultOption: true }, + { name: 'reason', alias: 'r', type: String, multiple: true, defaultValue: [ 'No reason given.' ] } + ] }; exports.help = { @@ -60,6 +67,6 @@ exports.help = { botPermission: 'MANAGE_ROLES', userTextPermission: 'MANAGE_ROLES', userVoicePermission: '', - usage: 'textUnMute @user-mention [Reason]', - example: [ 'textUnMute @user#0001 Reason for the unmute.' ] + usage: 'textUnMute <@USER_MENTION | USER_ID> -r [Reason]', + example: [ 'textUnMute @user#001 -r Apologized', 'textUnMute 167147569575323761 -r Forgiven' ] }; From af0d904588f75f49c0772f80bcc685b1adc47797 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Sat, 27 Jan 2018 04:33:30 +0000 Subject: [PATCH 21/23] textMute command now accepts user ID --- changes.json | 2 +- modules/moderation/textMute.js | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/changes.json b/changes.json index d4203042d..731b807a2 100644 --- a/changes.json +++ b/changes.json @@ -5,7 +5,7 @@ ], "improved": [ "Are you a Patreon creator and hosting Bastion yourself? The `patrons` command will now show your patrons and not the patrons of the Bastion bot project.", - "`clearWarn`, `removeAllRoles`, `deafen`, `kick`, `mute`, `textUnMute`, `unDeafen`, `unMute` and `warn` commands can be used with the ID of the user. No need to mention them anymore.", + "`clearWarn`, `removeAllRoles`, `deafen`, `kick`, `mute`, `textMute`, `textUnMute`, `unDeafen`, `unMute` and `warn` commands can be used with the ID of the user. No need to mention them anymore.", "Under-the-hood improvements" ], "added": [], diff --git a/modules/moderation/textMute.js b/modules/moderation/textMute.js index 986f64b1a..1bd942732 100644 --- a/modules/moderation/textMute.js +++ b/modules/moderation/textMute.js @@ -6,7 +6,13 @@ exports.exec = async (Bastion, message, args) => { try { - let user = message.mentions.users.first(); + let user; + if (message.mentions.users.size) { + user = message.mentions.users.first(); + } + else if (args.id) { + user = await Bastion.fetchUser(args.id); + } if (!user) { /** * The command was ran with invalid parameters. @@ -18,10 +24,7 @@ exports.exec = async (Bastion, message, args) => { let member = await message.guild.fetchMember(user.id); if (message.author.id !== message.guild.ownerID && message.member.highestRole.comparePositionTo(member.highestRole) <= 0) return Bastion.log.info(Bastion.strings.error(message.guild.language, 'lowerRole', true)); - if (args.reason) { - args.reason = args.reason.filter(str => !str.startsWith('<@') || !str.endsWith('>')); - } - args.reason = args.reason && args.reason.length ? args.reason.join(' ') : 'No reason given'; + args.reason = args.reason.join(' '); if (args.server) { let mutedRole = message.guild.roles.find('name', 'Bastion:mute'); @@ -74,7 +77,8 @@ exports.config = { aliases: [ 'tm' ], enabled: true, argsDefinitions: [ - { name: 'reason', type: String, multiple: true, defaultOption: true }, + { name: 'id', type: String, defaultOption: true }, + { name: 'reason', alias: 'r', type: String, multiple: true, defaultValue: [ 'No reason given.' ] }, { name: 'server', type: Boolean, alias: 's' } ] }; @@ -84,6 +88,6 @@ exports.help = { botPermission: 'MANAGE_ROLES', userTextPermission: 'MANAGE_ROLES', userVoicePermission: '', - usage: 'textMute @user-mention [Reason] [--server]', - example: [ 'textMute @user#0001 off topic discussions', 'textMute @user#0001 misbehaving others --server' ] + usage: 'textMute < @USER_MENTION | USER_ID > [-r Reason] [--server]', + example: [ 'textMute @user#0001 -r off topic discussions', 'textMute 167147569575323761 -r misbehaving with others --server' ] }; From ac37f7be26969c5c376c4cac7611aaba654d60b5 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Sat, 27 Jan 2018 04:35:24 +0000 Subject: [PATCH 22/23] softBan command now accepts user ID --- changes.json | 2 +- modules/moderation/softBan.js | 31 +++++++++++++++++++------------ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/changes.json b/changes.json index 731b807a2..3b2f2d628 100644 --- a/changes.json +++ b/changes.json @@ -5,7 +5,7 @@ ], "improved": [ "Are you a Patreon creator and hosting Bastion yourself? The `patrons` command will now show your patrons and not the patrons of the Bastion bot project.", - "`clearWarn`, `removeAllRoles`, `deafen`, `kick`, `mute`, `textMute`, `textUnMute`, `unDeafen`, `unMute` and `warn` commands can be used with the ID of the user. No need to mention them anymore.", + "`clearWarn`, `deafen`, `kick`, `mute`, `removeAllRoles`, `softBan`, `textMute`, `textUnMute`, `unDeafen`, `unMute` and `warn` commands can be used with the ID of the user. No need to mention them anymore.", "Under-the-hood improvements" ], "added": [], diff --git a/modules/moderation/softBan.js b/modules/moderation/softBan.js index 1da6cc5aa..e161e0242 100644 --- a/modules/moderation/softBan.js +++ b/modules/moderation/softBan.js @@ -6,7 +6,13 @@ exports.exec = async (Bastion, message, args) => { try { - let user = message.mentions.users.first(); + let user; + if (message.mentions.users.size) { + user = message.mentions.users.first(); + } + else if (args.id) { + user = await Bastion.fetchUser(args.id); + } if (!user) { /** * The command was ran with invalid parameters. @@ -26,14 +32,11 @@ exports.exec = async (Bastion, message, args) => { return Bastion.emit('error', Bastion.strings.error(message.guild.language, 'forbidden'), Bastion.strings.error(message.guild.language, 'noPermission', true, 'soft-ban', user), message.channel); } - let reason = args.slice(1).join(' '); - if (reason.length < 1) { - reason = 'No reason given'; - } + args.reason = args.reason.join(' '); await member.ban({ days: 7, - reason: reason + reason: args.reason }); await message.guild.unban(user.id).catch(e => { @@ -64,7 +67,7 @@ exports.exec = async (Bastion, message, args) => { message.channel.send({ embed: { color: Bastion.colors.RED, - description: `${message.author.tag} soft-banned ${user.tag} with reason **${reason}**`, + description: `${message.author.tag} soft-banned ${user.tag} with reason **${args.reason}**`, footer: { text: `ID ${user.id}` } @@ -77,13 +80,13 @@ exports.exec = async (Bastion, message, args) => { * Logs moderation events if it is enabled * @fires moderationLog */ - Bastion.emit('moderationLog', message.guild, message.author, this.help.name, user, reason); + Bastion.emit('moderationLog', message.guild, message.author, this.help.name, user, args.reason); let DMChannel = await user.createDM(); DMChannel.send({ embed: { color: Bastion.colors.RED, - description: `${message.author.tag} soft-banned you from **${message.guild.name}** server with reason **${reason}**` + description: `${message.author.tag} soft-banned you from **${message.guild.name}** server with reason **${args.reason}**` } }).catch(e => { Bastion.log.error(e); @@ -96,7 +99,11 @@ exports.exec = async (Bastion, message, args) => { exports.config = { aliases: [ 'sb' ], - enabled: true + enabled: true, + argsDefinitions: [ + { name: 'id', type: String, defaultOption: true }, + { name: 'reason', alias: 'r', type: String, multiple: true, defaultValue: [ 'No reason given.' ] } + ] }; exports.help = { @@ -104,6 +111,6 @@ exports.help = { botPermission: 'BAN_MEMBERS', userTextPermission: 'BAN_MEMBERS', userVoicePermission: '', - usage: 'softBan @user-mention [Reason]', - example: [ 'softBan @user#0001 Reason for soft ban.' ] + usage: 'softBan <@USER_MENTION | USER_ID> -r [Reason]', + example: [ 'softBan @user#001 -r Spamming in support channel.', 'softBan 167147569575323761 -r Reputed spammer.' ] }; From 0ec2198bb1057d204aef10c1a544edf845924745 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Sat, 27 Jan 2018 04:42:46 +0000 Subject: [PATCH 23/23] nickname command now accepts user ID --- changes.json | 2 +- modules/moderation/nickname.js | 29 +++++++++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/changes.json b/changes.json index 3b2f2d628..77c25eef8 100644 --- a/changes.json +++ b/changes.json @@ -5,7 +5,7 @@ ], "improved": [ "Are you a Patreon creator and hosting Bastion yourself? The `patrons` command will now show your patrons and not the patrons of the Bastion bot project.", - "`clearWarn`, `deafen`, `kick`, `mute`, `removeAllRoles`, `softBan`, `textMute`, `textUnMute`, `unDeafen`, `unMute` and `warn` commands can be used with the ID of the user. No need to mention them anymore.", + "`clearWarn`, `deafen`, `kick`, `mute`, `nickname`, `removeAllRoles`, `softBan`, `textMute`, `textUnMute`, `unDeafen`, `unMute` and `warn` commands can be used with the ID of the user. No need to mention them anymore.", "Under-the-hood improvements" ], "added": [], diff --git a/modules/moderation/nickname.js b/modules/moderation/nickname.js index 16979d6f0..bf7aa377a 100644 --- a/modules/moderation/nickname.js +++ b/modules/moderation/nickname.js @@ -6,7 +6,13 @@ exports.exec = async (Bastion, message, args) => { try { - let user = message.mentions.users.first(); + let user; + if (message.mentions.users.size) { + user = message.mentions.users.first(); + } + else if (args.id) { + user = await Bastion.fetchUser(args.id); + } if (!user) { /** * The command was ran with invalid parameters. @@ -25,24 +31,23 @@ exports.exec = async (Bastion, message, args) => { nickStat = 'Can\'t change server owner\'s nickname.'; } else { - args = args.slice(1); - args = args.join(' '); + args.nick = args.nick.join(' '); - if (args.length > 32) { + if (args.nick > 32) { color = Bastion.colors.RED; nickStat = 'Nickname can\'t be longer than 32 characters.'; } else { - if (args.length < 1) { + if (args.nick < 1) { color = Bastion.colors.RED; nickStat = `${message.author.tag} removed the nickname of ${user.tag}`; } else { color = Bastion.colors.GREEN; - nickStat = `${message.author.tag} set the nickname of ${user.tag} to **${args}**`; + nickStat = `${message.author.tag} set the nickname of ${user.tag} to **${args.nick}**`; } } - await member.setNickname(args); + await member.setNickname(args.nick); } message.channel.send({ @@ -61,7 +66,11 @@ exports.exec = async (Bastion, message, args) => { exports.config = { aliases: [ 'nick' ], - enabled: true + enabled: true, + argsDefinitions: [ + { name: 'id', type: String, defaultOption: true }, + { name: 'nick', alias: 'n', type: String, multiple: true, defaultValue: [] } + ] }; exports.help = { @@ -69,6 +78,6 @@ exports.help = { botPermission: 'MANAGE_NICKNAMES', userTextPermission: 'MANAGE_NICKNAMES', userVoicePermission: '', - usage: 'nickname <@user-mention> [nick]', - example: [ 'nickname @user#0001 The Legend', 'nickname @user#0001' ] + usage: 'nickname < @USER_MENTION | USER_ID > [-n nick]', + example: [ 'nickname @user#0001 -n The Legend', 'nickname 167147569575323761' ] };