diff --git a/README.md b/README.md index ad89b39d..c584d7c5 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Xiao is a Discord bot coded in JavaScript with 6. Run `npm i -g pm2` to install PM2. 7. Run `pm2 start Xiao.js --name xiao` to run the bot. -## Commands (338) +## Commands (339) ### Utility: * **eval:** Executes JavaScript code. @@ -404,6 +404,7 @@ Xiao is a Discord bot coded in JavaScript with * **cleverbot:** Talk to Cleverbot. * **prune:** Deletes up to 99 messages from the current channel. +* **rename-all:** Renames every member of the server. * **strawpoll:** Generates a Strawpoll with the options you provide. ### Roleplay: diff --git a/commands/other/rename-all.js b/commands/other/rename-all.js new file mode 100644 index 00000000..f2c3feb2 --- /dev/null +++ b/commands/other/rename-all.js @@ -0,0 +1,46 @@ +const Command = require('../../structures/Command'); + +module.exports = class RenameAllCommand extends Command { + constructor(client) { + super(client, { + name: 'rename-all', + group: 'other', + memberName: 'rename-all', + description: 'Renames every member of the server.', + details: 'Only the bot owner(s) may use this command.', + ownerOnly: true, + guildOnly: true, + clientPermissions: ['MANAGE_NICKNAMES', 'CHANGE_NICKNAME'], + userPermissions: ['ADMINISTRATOR'], + args: [ + { + key: 'nickname', + prompt: 'What nickname do you want everyone to have?', + type: 'string', + min: 2, + max: 32 + } + ] + }); + } + + async run(msg, { nickname }) { + try { + await msg.reply('Fetching members...'); + await msg.guild.members.fetch(); + await msg.reply('Fetched members! Renaming...'); + let i = 0; + for (const member of msg.guild.members) { + try { + await member.setNickname(nickname); + } catch (err) { + i++; + continue; + } + } + return msg.reply(`Successfully renamed all but ${i} members to **${nickname}**!`); + } catch (err) { + return msg.reply(`Failed to rename everyone: \`${err.message}\``); + } + } +}; diff --git a/package.json b/package.json index 2c27fd9c..b4d37b5b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "102.0.3", + "version": "102.1.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {