簡體   English   中英

加入 Discord 公會時,如何讓我的 Discord.js 機器人說些什么?

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

我想讓我的機器人在他加入公會時發送一條歡迎信息,但我不知道如何,試圖做一些事情但沒有奏效。 我怎樣才能做到這一點?

無效的代碼:

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');

});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM