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

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

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

問題描述

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

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 類只檢查運(yùn)行命令的服務(wù)器上的用戶 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);

就這么簡單.

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

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

相關(guān)文檔推薦

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(如何讓我的機(jī)器人提及發(fā)出該機(jī)器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復(fù)必須使用導(dǎo)入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務(wù)器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復(fù)“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務(wù)器時的歡迎消息)
主站蜘蛛池模板: 巨大荫蒂视频欧美另类大 | 久久精品日产第一区二区三区 | 久久久久久国产精品免费免费狐狸 | 欧美黄色免费网站 | 亚洲免费视频一区 | 在线观看亚洲专区 | 国产天堂 | 日韩欧美国产电影 | 久久亚洲欧美日韩精品专区 | 欧美成人第一页 | 综合色婷婷 | 欧美日在线 | 欧美美女一区二区 | 久久久久久久久91 | 精品国产一区二区三区久久 | 欧美一区不卡 | 97精品超碰一区二区三区 | 成人在线播放网站 | av中文天堂 | 中文字幕第7页 | 亚洲欧美综合精品久久成人 | 亚洲网址在线观看 | 福利一区在线观看 | 超碰97免费在线 | 噜噜噜噜狠狠狠7777视频 | 日本在线综合 | 四虎午夜剧场 | 亚州国产 | 国内精品久久影院 | www久久国产 | 久久精品国产一区二区电影 | 亚洲91精品 | 久草视频网站 | 日韩一区精品 | 国产精品99精品久久免费 | 国产99久久久国产精品 | 能看的av | 国产在线中文字幕 | 久久9热| 91久久视频 | 成人国产精品久久 |