mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-24 22:34:46 +02:00
Rename All Command
This commit is contained in:
@@ -45,7 +45,7 @@ Xiao is a Discord bot coded in JavaScript with
|
|||||||
6. Run `npm i -g pm2` to install PM2.
|
6. Run `npm i -g pm2` to install PM2.
|
||||||
7. Run `pm2 start Xiao.js --name xiao` to run the bot.
|
7. Run `pm2 start Xiao.js --name xiao` to run the bot.
|
||||||
|
|
||||||
## Commands (338)
|
## Commands (339)
|
||||||
### Utility:
|
### Utility:
|
||||||
|
|
||||||
* **eval:** Executes JavaScript code.
|
* **eval:** Executes JavaScript code.
|
||||||
@@ -404,6 +404,7 @@ Xiao is a Discord bot coded in JavaScript with
|
|||||||
|
|
||||||
* **cleverbot:** Talk to Cleverbot.
|
* **cleverbot:** Talk to Cleverbot.
|
||||||
* **prune:** Deletes up to 99 messages from the current channel.
|
* **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.
|
* **strawpoll:** Generates a Strawpoll with the options you provide.
|
||||||
|
|
||||||
### Roleplay:
|
### Roleplay:
|
||||||
|
|||||||
@@ -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
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "102.0.3",
|
"version": "102.1.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user