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

Discord.js 機器人歡迎會員,分配角色并向他們發送

Discord.js Bot Welcomes Member, Assign a Role and send them a DM(Discord.js 機器人歡迎會員,分配角色并向他們發送 DM)
本文介紹了Discord.js 機器人歡迎會員,分配角色并向他們發送 DM的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

所以當一個新成員加入 Guild [discord 服務器].Bot應該在某個頻道(ID = 766716351007686696)中發送消息,向他們發送直接消息,然后添加角色(人豆).這是我現在擁有的代碼,它不起作用,底部有錯誤

client.on('guildMemberAdd', member =>{const channel = message.guild.channels.cache.find(c => c.id === "766716351007686696")const channelwelcomeEmbed = new Discord.MessageEmbed().setColor('#ffd6d6').setTitle('歡迎!').setDescription(`${member} 剛剛加入不和諧!請務必閱讀#rules!`).setTimestamp();channel.send(channelwelcomeEmbed);const dmwelcomeEmbed = new Discord.MessageEmbed().setColor('#ffd6d6').setTitle('歡迎!').setDescription("For Help Using @Pro Bot#7903, Send the command `!help` In Server").setTimestamp();member.send(dmwelcomeEmbed);let role6 = message.guild.roles.cache.find(role => role.name == "Human Bean");//基本角色,每個人都明白if(!role6) return message.reply(找不到那個角色.")member.roles.add(role6);});

錯誤信息是;

 const channel = message.guild.channels.cache.find(c => c.id === "766716351007686696")^ReferenceError:消息未定義

解決方案

你的代碼看起來很好,問題是事件沒有被觸發.那是因為不和諧關閉了特權意圖".默認情況下.

某些意圖被定義為特權";由于數據的敏感性.這些意圖是:

  • GUILD_PRESENCES
  • GUILD_MEMBERS

其中一個影響是您正在經歷的,即不工作的 guildMemberAdd 事件.

好消息是您可以通過一個簡單的步驟解決此問題.只需在

如果您想了解更多信息

  • Discord.js 官方指南 - 網關意圖
  • Discord 開發者文檔 - 網關意圖
  • 網關更新常見問題解答
  • Discord API Github - 第 1363 期 - 特權意圖
  • Discord 博客 - Discord 上機器人的未來
  • 無我的 discord.js 公會成員事件正在發出,我的用戶緩存基本上是空的,我的函數正在超時?

So When A New Member Joins The Guild [the discord server]. The Bot Should Send A Message In a certain Channel (ID = 766716351007686696), Send Them A Direct Message, And Then Add A Role (Human Bean). This Is The code I Have Now and it isn't working, error at the bottom

client.on('guildMemberAdd', member =>{
    const channel = message.guild.channels.cache.find(c => c.id === "766716351007686696")
    const channelwelcomeEmbed = new Discord.MessageEmbed()
        .setColor('#ffd6d6')
        .setTitle('Welcome!')
        .setDescription(`${member} just joined the discord! Make sure to read #rules!`)
        .setTimestamp();
    channel.send(channelwelcomeEmbed);
    const dmwelcomeEmbed = new Discord.MessageEmbed()
        .setColor('#ffd6d6')
        .setTitle('Welcome!')
        .setDescription("For Help Using @Pro Bot#7903, Send The Command `!help` In Server")
        .setTimestamp();
    member.send(dmwelcomeEmbed);
    let role6 = message.guild.roles.cache.find(role => role.name == "Human Bean"); //BASIC ROLE, EVERYONE GETS IT
    if(!role6) return message.reply("Couldn't find that Role .")
    member.roles.add(role6);
});

Error Message is;

    const channel = message.guild.channels.cache.find(c => c.id === "766716351007686696")
                    ^

ReferenceError: message is not defined

解決方案

Your code looks fine, the problem is that the event isn't triggered. Thats because discord turned off "privileged intents" by default.

Some intents are defined as "Privileged" due to the sensitive nature of the data. Those intents are:

  • GUILD_PRESENCES
  • GUILD_MEMBERS

One effect of that is what you are experiencing, the not working guildMemberAdd event.

The good news is that you can fix this with one easy step. Simply enable Privileged Gateway Intents in the discord developer portal and it should work just fine.

If you want to read more about it

  • Discord.js Official Guide - Gateway Intents
  • Discord Developer Documentation - Gateway Intents
  • Gateway Update FAQ
  • Discord API Github - Issue 1363 - Priviledged Intents
  • Discord Blog - The Future of Bots on Discord
  • None of my discord.js guildmember events are emitting, my user caches are basically empty, and my functions are timing out?

這篇關于Discord.js 機器人歡迎會員,分配角色并向他們發送 DM的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

Using discord.js to detect image and respond(使用 discord.js 檢測圖像并響應)
Check if user ID exists in Discord server(檢查 Discord 服務器中是否存在用戶 ID)
Guild Member Add does not work (discordjs)(公會成員添加不起作用(discordjs))
Creating my first bot using REPLIT but always error Discord.JS(使用 REPLIT 創建我的第一個機器人,但總是錯誤 Discord.JS)
How do I code event/command handlers for my Discord.js bot?(如何為我的 Discord.js 機器人編寫事件/命令處理程序?)
How to find a User ID from a Username in Discord.js?(如何從 Discord.js 中的用戶名中查找用戶 ID?)
主站蜘蛛池模板: 日韩一区二区免费视频 | 亚洲免费在线 | 欧美一级一| 色婷婷影院 | 日本视频一区二区 | 久草久草久草 | 国产精品视频久久久久 | 久久久精品国产 | 99re在线视频观看 | 97超碰成人| 在线成人免费视频 | 亚洲乱码一区二区三区在线观看 | 日韩中文一区二区三区 | 亚洲欧美日韩久久久 | 99久久久国产精品免费消防器 | 国产精品毛片一区二区在线看 | 日本一区二区视频 | 久久成人一区 | 欧美精品一区二区三区在线四季 | 亚洲国产精品一区在线观看 | 天堂在线一区 | 久久99精品久久久水蜜桃 | 久久久久久成人 | 成人在线一区二区三区 | 欧美在线视频不卡 | 久久一区二区av | 午夜影院在线 | 国产在线精品一区二区三区 | 成人性视频在线播放 | 天堂成人国产精品一区 | 亚洲 中文 欧美 日韩 在线观看 | 9999久久| 免费一区二区三区 | 91视频免费视频 | 成人在线视频免费观看 | 草草视频在线观看 | 日韩免费一区 | 91在线影院| 久久天堂 | 久久综合九色综合欧美狠狠 | 国产欧美一区二区三区久久人妖 |