【问题标题】:How can I make bot receive DM on Discord js v14?如何让机器人在 Discord js v14 上接收 DM?
【发布时间】:2022-10-04 16:51:21
【问题描述】:
module.exports = {
    name: 'messageCreate',
    execute(message) {
        if (message.channel.type == 'DM') {
            console.log('Dm recieved')
            client.channels.get('1026279100626767924').send(message);
         }

    }
};

我通过参考 Discord JS 指南创建了事件处理。我希望我的机器人接收 DM 并将该消息发送到我的管理员频道。

但机器人无法识别 DM 我应该怎么办

(我正使用翻译器)

【问题讨论】:

    标签: javascript discord discord.js


    【解决方案1】:

    您可以使用消息创建用于收听机器人 DM 的事件。

    client.on("messageCreate", async message => {
        if (message.guild) return;
        console.log(`Someone sent DM to me => ${message.content}`);
        await client.channels.cache.get(CHANNEL_ID).send(messsage.content);
    });
    

    【讨论】:

      猜你喜欢
      • 2021-06-13
      • 2021-05-11
      • 2021-02-20
      • 2021-03-17
      • 2018-08-22
      • 1970-01-01
      • 2020-04-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多