简体   繁体   English

加入 Discord 公会时,如何让我的 Discord.js 机器人说些什么?

[英]How to make my Discord.js bot say something when joning a Discord guild?

I want to make my bot send a welcome message when he joins a Guild, but i don't know how, tried to do something but it didn't worked.我想让我的机器人在他加入公会时发送一条欢迎信息,但我不知道如何,试图做一些事情但没有奏效。 How can I do that?我怎样才能做到这一点?

Code that not worked:无效的代码:

client.on('guildCreate', guild => {
    message.channel.send('¡Hola! Soy el bot de Pepelui85, mi prefix aquí es "*" y mis comandos son: *pc y *llora.');
    message.channel.send('¿Encontraste algun bug? Reportalo en el canal desarrollo de mi servidor de Discord.');
    message.channel.send('https://discord.gg/3taae9');
});

try do尝试做

client.on('guildCreate', guild => {

let SendChannel = guild.channels.get("general") || guild.channels.get("chat");

SendChannel.send('¡Hola! Soy el bot de Pepelui85, mi prefix aquí es "*" y mis comandos son: *pc y *llora.');

Sendchannel.send('¿Encontraste algun bug? Reportalo en el canal desarrollo de mi servidor de Discord.');

SendChannel.send('https://discord.gg/3taae9');

});

or just do this!或者就这样做!

client.on('guildCreate', guild => {

let SendChannel = guild.channels.find("name", "general") || guild.channels.find("name", "chat");

if(SendChannel) SendChannel.send('¡Hola! Soy el bot de Pepelui85, mi prefix aquí es "*" y mis comandos son: *pc y *llora. \n¿Encontraste algun bug? Reportalo en el canal desarrollo de mi servidor de Discord. \nhttps://discord.gg/3taae9');

});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM