【问题标题】:Discord.js Is there any way to get all users to separate variables?Discord.js 有没有办法让所有用户分开变量?
【发布时间】:2020-04-18 18:34:09
【问题描述】:

有没有办法让一台服务器中的所有用户的 id 来分隔变量?

【问题讨论】:

  • 当然有可能,但我怀疑是否存在您真正想要这样做的情况。听起来像列表或数组是你想要的。你能说一下你想要做什么吗?
  • 我想做一些类似 muteall 命令的事情
  • 是的,为每个用户创建一个单独的变量绝对不是您想要做的。您只需遍历所需的用户并执行您想要的操作。我认为您的问题更多是关于 javascript 而不是不和谐。如果您的 javascript 代码有一些特定问题,我建议您为此提交一个问题。记得使用 javascript 标签。

标签: discord discord.js


【解决方案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)

【讨论】:

    猜你喜欢
    • 2010-12-30
    • 1970-01-01
    • 2012-07-09
    • 2021-09-20
    • 2020-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-21
    相关资源
    最近更新 更多