Rename All Command

This commit is contained in:
Daniel Odendahl Jr
2019-04-01 15:54:20 +00:00
parent fd6cc6f3b9
commit 4a59745cbd
3 changed files with 49 additions and 2 deletions
+2 -1
View File
@@ -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:
+46
View File
@@ -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}\``);
}
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "102.0.3",
"version": "102.1.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {