嗨,我想让机器人向加入服务器的新用户发送直接/私人消息。它可以在频道上发布欢迎信息,但当我在私人信息中发布时它不起作用。
const Discord = require('discord.js');
const config = require('./config.json');
const bot = new Discord.Client();
const prefix = '*';
bot.on('ready', () => {
console.log('Bot Démarré');
bot.user.setActivity('Chill \'N Code (*help)', { type: 'WATCHING' });
bot.user.setStatus('online');
})
bot.on('guildMemberAdd', member => {
console.log(member.user.username + " a rejoint le serveur");
const embed = new Discord.MessageEmbed()
.setTitle("<EARLY_SUPPORTER:840512953928515595> Bienvenue " + member.user.username + " !")
.setImage('https://i.imgur.com/Kbl451j.gif')
.setDescription("__**Voici quelques informations utiles :**__")
.addFields(
{ name: '\u200B', value: '\u200B' },
{ name: '<:channel:840513546416554045> **Règlement**', value: 'Nous T\'invitions à lire le [règlement](https://discord.com/channels/836947422122344448/836947422173200410/836962049484390449]', inline: false },
{ name: '<:add_reaction:840512848266657792> **Rôles**', value: 'Tu peux prendre tes rôles [ici](https://discord.com/channels/836947422122344448/836947422617141290/837022973830496286)', inline: false },
{ name: '<:moderation:840528469317517333> **Devenir Staff**', value: 'Tu peux devenir staff [ici](https://forms.gle/rGV26bZytcx5atG28)', inline: false },
{ name: '\u200B', value: '\u200B' },
{ name: 'Github', value: '[Github](https://github.com/chillncode)', inline: false },
{ name: 'Twitter', value: '[Twitter](https://twitter.com/ChillNCode1)', inline: false }
)
.setFooter('Chill \'N Code', 'https://cdn.discordapp.com/icons/836947422122344448/d27317d317a5b260d0365f6ca0da5455.png');
member.send(embed);
console.log("message envoyé");
})
答案 0 :(得分:1)
确保您在 Discord Developer Portal 中启用了 SERVER MEMBERS INTENT