我想让我的机器人在加入公会时发送欢迎消息,但我不知道怎么做,试图做点什么,但没有奏效。我该怎么做?
不起作用的代码:
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');
});
尝试
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');
});
或者只是这样做!
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');
});