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

從客戶端狀態(tài)的成員計(jì)數(shù)中過濾掉機(jī)器人

Filter out bots from member count in client status(從客戶端狀態(tài)的成員計(jì)數(shù)中過濾掉機(jī)器人)
本文介紹了從客戶端狀態(tài)的成員計(jì)數(shù)中過濾掉機(jī)器人的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我想讓我的機(jī)器人活動說 觀看 + 成員計(jì)數(shù)(不包括機(jī)器人)".

I want to make my bot activity say "Watching + Member Count (not include bots)".

我做了一些步驟,這是我的代碼:

I did some steps, here is my code:

client.once('ready', () => { 
        setInterval(() => {
          targetGuild = client.guilds.cache.get('My Guild ID Here')
          client.user.setPresence({ 
            activities: [{ name: `${targetGuild.memberCount} Users`, type: 'WATCHING' }], 
            status: 'online'
            });
        }, 1000 * 60 * 5);
    
    });

我需要設(shè)置一個(gè)過濾器,它只計(jì)算成員,而不是機(jī)器人.

The thing that I need is to set a filter that it calculate members only, not bots.

推薦答案

使用 GuildMemberManager#fetch() 獲取所有成員,然后使用 Collection#partition() 將成員集合拆分為 botshumans.使用 humans.size 按您的意愿顯示用戶數(shù).你也可以Collection#filter()將成員集合過濾給人類,但是我在此示例中使用分區(qū)來在一個(gè)函數(shù)調(diào)用中訪問雙方.

Use GuildMemberManager#fetch() to fetch all members, then use Collection#partition() to split the member collection into bots and humans. Use humans.size to display the user count as you intend. You can also Collection#filter() to filter the member collection to just the humans, however I use partition in this example to have access to both parties in one function call.

client.once('ready', async() => { 
   targetGuild = client.guilds.cache.get('My Guild ID Here');
   try {
      const [bots, humans] = (await targetGuild.members.fetch())
         .partition(member => member.user.bot);
      setInterval(() => {
         client.user.setPresence({ 
            activities: [
               { 
                  name: `${humans.size} Users`, 
                  type: 'WATCHING' 
               }
            ], 
            status: 'online'
         });
      }, 1000 * 60 * 5);
   } catch (err) {
      console.error(err);
   }
});

這篇關(guān)于從客戶端狀態(tài)的成員計(jì)數(shù)中過濾掉機(jī)器人的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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ù)器時(shí)的歡迎消息)
主站蜘蛛池模板: 国产精品一二区 | 天天操操操操操 | 全免一级毛片 | 午夜免费看 | 成年免费大片黄在线观看一级 | 亚洲aⅴ一区二区 | av激情在线 | 97精品一区二区 | 福利片在线观看 | 中文字幕av第一页 | 色片在线观看 | 91精品一区 | 成人免费大片黄在线播放 | 午夜精品视频在线观看 | 在线观看国产h | 欧美激情a∨在线视频播放 成人免费共享视频 | 亚洲成av人片在线观看 | 亚洲小视频| 91精品国产一区二区三区蜜臀 | 狠狠干网站 | 成人二区 | 中文字幕亚洲一区 | 成人av大全| 国产成人免费视频 | 亚洲一区二区在线免费观看 | 欧美一级全黄 | 欧美日韩亚洲一区 | 日韩影音 | 久久综合伊人 | 操久久| 免费人成激情视频在线观看冫 | 亚洲欧洲在线视频 | 久久人人爽人人爽人人片av免费 | 中文字幕在线精品 | 国产乱码精品一品二品 | 亚洲精品日日夜夜 | 国产色网| 国产精品久久久乱弄 | 国精日本亚洲欧州国产中文久久 | 欧美一区永久视频免费观看 | 毛片99 |