久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

檢查用戶是否在特定的公會中 discord.js

check if an user is in a specific guild discord.js(檢查用戶是否在特定的公會中 discord.js)
本文介紹了檢查用戶是否在特定的公會中 discord.js的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我不知道這是否可能,但我正在嘗試讓我的機器人返回它與用戶共享的所有服務器.

I don't know if it's possible, but I'm trying to make my bot returning all the servers it shares with an user.

所以我從 bot 所在的公會那里獲得了所有 id,以及來自用戶的 id.

So I got all the ids from the guilds' where the bot is, and the id from the user.

而且我不知道如何檢查每個公會是否有用戶的 id.

And I don't know how to check for each guild if the user's id is on it or not.

我嘗試過這樣做:

let user_id = message.author.id;

let guild_list = [];

client.guilds.cache.forEach(guild => {
    guild_list.push(guild.id);
    })

for (let i = 0; i < guild_list.length; i++){

    let thisGuild = client.guilds.cache.get(guild_list[i]);

    if(thisGuild.member(user_id)){

        message.channel.send("Shared server : " + guild_list[i]);

    }

}

但是 Guildmember 類只檢查運行命令的服務器上的用戶 ID.我不知道這是否可能,而且我在文檔中找不到任何可以幫助我的東西.

But the Guildmember class only checks the user's id on the server where the command is run. I don't know if it's possible, and I don't find anything that could help me in the documentation.

推薦答案

很有可能...

我們可以使用 Collector#filter 方法,因為我們想要過濾 bot 和作者所在的公會.

We can use the Collector#filter method for this since we would want to filter the guild(s) the bot and the author is.

const mutualGuilds = client.guilds.cache.filter((guild) => {
   return guild.members.cache.has(message.author.id);
});

    // This will log the mutual guild(s) the bot and the author is in, of course you can change it however you'd like.
console.log(mutualGuilds);

就這么簡單.

這篇關于檢查用戶是否在特定的公會中 discord.js的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機器人提及發出該機器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復必須使用導入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務器時的歡迎消息)
主站蜘蛛池模板: 鲁一鲁资源影视 | 欧美国产一区二区三区 | 免费看a| 久久久国产一区二区三区四区小说 | 网页av | 欧美日韩国产一区二区三区 | 亚洲免费在线观看 | 亚洲444kkkk在线观看最新 | 久久毛片| 日韩精品成人一区二区三区视频 | 国产探花在线观看视频 | av大全在线 | 色婷婷综合网 | 欧美一级视频免费看 | 日韩欧美三区 | 亚洲一区二区电影网 | 精品美女在线观看 | 国产精品国产三级国产aⅴ无密码 | 国产99久久 | 91激情电影| 久久久久国产精品一区二区 | 精品少妇一区二区三区在线播放 | 亚洲成人一区二区三区 | 久久福利电影 | 精品国产伦一区二区三区观看方式 | 欧美1区2区| 中文字幕亚洲视频 | 波多野结衣精品 | 国产精品日日摸夜夜添夜夜av | 日韩欧美不卡 | 国产精品久久久久久久久久 | 伊人伊成久久人综合网站 | wwwww在线观看 | 欧美日韩大片 | 亚洲日日 | 91国产精品在线 | 亚洲最大看片网站 | 欧美日韩电影在线 | 精品综合久久久 | 亚洲bt 欧美bt 日本bt | 中文字幕1区2区 |