【发布时间】:2021-07-09 20:25:46
【问题描述】:
我在更改不和谐服务器中每个人的用户名时遇到问题。我正在使用 discord.js v12,服务器中有大约 20 人。我是它的所有者,我的机器人有管理员,但机器人只更改语音频道中人员的用户名。这是我的代码:
module.exports = {
name: 'username',
description: "Changes the whole server's usernames",
execute(message, args, prefix, Discord, client) {
let nick = message.content.slice((prefix + "username").length);
if (!args[0]) {
message.channel.send("You didn't specify what to change them to!");
}
else {
message.guild.members.cache.forEach(r => {
if (r.id == '855161030119129090') // This is to not change the username of the bot
return;
r.setNickname(nick);
});
message.channel.send('Usernames changed.');
}
}
}
【问题讨论】:
-
大量 API 调用属于 API 滥用。您的客户端可能会被 Discord API 暂停
-
以下是 Discord API 限制:discord.com/developers/docs/topics/…。 tl;dr
All bots can make up to 50 requests per second to our API.也许你的机器人已经尝试超过 50 个请求?
标签: javascript discord.js