admin管理员组文章数量:1277884
I tried on googling but all of the errors was "is not a function", that's because i'm using discord.js V12? I can't find it on google, there is less question about this one. This was my code.
var serverArray = client.guilds.array();
for(i = 0; i < serverArray.length; i++) {
console.log("Server ID: " + serverArray[i].id);
}
I tried on googling but all of the errors was "is not a function", that's because i'm using discord.js V12? I can't find it on google, there is less question about this one. This was my code.
var serverArray = client.guilds.array();
for(i = 0; i < serverArray.length; i++) {
console.log("Server ID: " + serverArray[i].id);
}
Share
Improve this question
edited Jun 26, 2020 at 20:23
randomname123
asked Jun 26, 2020 at 20:13
randomname123randomname123
551 gold badge1 silver badge6 bronze badges
2 Answers
Reset to default 8client.guilds.cache.forEach(guild => {
console.log(`${guild.name} | ${guild.id}`);
})
let clientguilds = client.guilds.cache()
console.log(clientguilds.map(g => g.id) || "None")
This should do the trick! It's going to cache all the guilds your bot is in and then it will map the guilds as an array. We then get the id of each guild or, if it's not in any guilds "none".
版权声明:本文标题:javascript - How can I list the all Discord servers ID where my bot are in the console? | discord.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741255069a2366512.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论