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

Discord.js 帳戶創(chuàng)建后的天數(shù)

Discord.js days since account creation(Discord.js 帳戶創(chuàng)建后的天數(shù))
本文介紹了Discord.js 帳戶創(chuàng)建后的天數(shù)的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

如果用戶注冊(cè)discord不到10天,有什么方法可以在用戶加入服務(wù)器時(shí)賦予他們特定的角色.

Is there any way to give a user a certain role when they join the server, if they have been registered to discord for less than 10 days.

推薦答案

使用 User 的 .createdAt 屬性來(lái)確定他們的帳戶年齡

Use the .createdAt property of User to determine their account age

當(dāng) guildMemberAdd 事件觸發(fā)時(shí),檢查加入成員的 .createdAt 屬性.然后你可以使用 .addRole() 給他們一個(gè)角色.

When the guildMemberAdd event triggers, check the joining member's .createdAt property. You can then use .addRole() to give them a role.

// assuming you already have the `role` object or id
client.on("guildMemberAdd", member => {
  if (Date.now() - member.user.createdAt < 1000*60*60*24*10) {
    member.addRole(role);
  }
});

更詳細(xì)的解釋:

  • guildMemberAdd 將在每次有人加入服務(wù)器時(shí)觸發(fā),這將傳遞 member 對(duì)象.
  • 我們使用該成員的 user 對(duì)象來(lái)確定帳戶是何時(shí)通過(guò) .createdAt 創(chuàng)建的.
  • 時(shí)間戳以毫秒為單位存儲(chǔ),因此 10 天相當(dāng)于 1000*60*60*24*10 毫秒.
  • 比較這兩個(gè)時(shí)間戳,如果他們的帳戶年齡較低,那么你就給他們一個(gè)角色.
  • 我們假設(shè)您已經(jīng)擁有 role 對(duì)象.否則,Guild.roles.get() 是通過(guò) ID 查找角色的好方法.
  • guildMemberAdd will fire every time someone joins a server, this will pass on the member object.
  • We use the user object from that member to determine when the account was created via .createdAt.
  • Timestamps are stored in milliseconds, so 10 days is equivalent to 1000*60*60*24*10 milliseconds.
  • Compare these two timestamps, and if their account age is lower, then you give them a role.
  • We're assuming you already have the role object. Otherwise Guild.roles.get() is a good way to find a role by its ID.

這篇關(guān)于Discord.js 帳戶創(chuàng)建后的天數(shù)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(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)入來(lái)加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來(lái)自特定服務(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í)的歡迎消息)
主站蜘蛛池模板: 国产wwwcom | 国产一区二区黑人欧美xxxx | 国产专区在线 | 综合久久一区 | 中文字幕国产在线 | 精品一区二区三区四区外站 | 国产剧情一区 | 亚洲精品视频在线看 | 颜色网站在线观看 | 国产欧美一区二区精品忘忧草 | 久久99精品久久久久久国产越南 | 日日爱av | 午夜伊人 | 国产精品不卡视频 | 久久久久久久国产精品 | 美女天堂 | 国产日产欧产精品精品推荐蛮挑 | 瑞克和莫蒂第五季在线观看 | 成人精品视频在线观看 | 精品国产精品三级精品av网址 | 久久九九色 | 精久久久久 | 欧美在线色视频 | 精品久久久久一区二区国产 | 国产午夜精品一区二区三区四区 | 久久久免费 | 超碰超碰 | 午夜电影网| 在线观看av网站永久 | 国产视频精品在线 | 国产一区二区三区高清 | 欧洲尺码日本国产精品 | 午夜影院在线观看 | 在线第一页 | 99精品99 | 日韩三级在线观看 | 国产精品视频偷伦精品视频 | 国产高清视频在线观看 | 国产成人啪免费观看软件 | 免费观看黄a一级视频 | 成人免费观看男女羞羞视频 |