当有人加入服务器时,我的不和谐机器人不发送欢迎消息

时间:2021-01-21 13:42:42

标签: javascript node.js discord discord.js

bot.on('guildMemberAdd', async member => {
    const sohbet = await client.channels.cache.find(x => x.id == "801461330674057247")
    client.channels.get("801461330674057247").send("testing")
})

这是我的代码

1 个答案:

答案 0 :(得分:1)

尝试全局设置 ChannelText,以便可以在脚本/应用程序的任何位置访问它。

    var ChannelText = undefined;
    bot.on('ready', async () => {
        ChannelText = bot.channels.cache.get("801461330674057247");
        ChannelText.SendMessage("test test test!");
    });
    bot.on('guildMemberAdd', async () => {
        ChannelText.SendMessage("OH WOW IT'S WORKING!!! BUT CAN I GET THE USERNAME NOW?");
    });