Discord.js是否有办法让所有用户分开变量?

时间:2019-12-29 21:51:58

标签: discord discord.js

有没有办法让一台服务器中的所有用户ID分开变量?

1 个答案:

答案 0 :(得分:1)

是的,有点。您可以使用for循环进行遍历,然后在所需的用户上运行所需的任何代码。

// Where '888888888888888888' is your server id. Store the server as a variable.
const server = client.guilds.get("888888888888888888"); 

// Go through each of the members, and console.log() their name
server.members.forEach(member => console.log(member.user.username)); 
//Replace console.log() with what you want to do to them. (e.x give role, ban, kick, dm)