【问题标题】:Is there a way to send a discord.js message into a specfic channel?有没有办法将 discord.js 消息发送到特定频道?
【发布时间】:2021-03-22 05:03:57
【问题描述】:

我找到了这个,但它不起作用并说发送未定义。有人知道为什么吗?

client.channels.cache.get("channelidwashere").send(sellembed1)

【问题讨论】:

    标签: javascript node.js discord discord.js


    【解决方案1】:

    如果我没记错的话,您尝试发送消息的方式已经过时了

    试试这个:

    const channel = await client.channels.fetch('youridhere');
    await channel.send(embed1);
    

    编辑:我从这里的文档中得到它:https://discord.js.org/#/docs/main/stable/class/ChannelManager client.channels 返回一个 ChannelManager,因此您应该能够调用您在此页面上找到的方法。

    【讨论】:

    • 用户的方法并没有完全过时,而是通道很可能未缓存。不过,您的回答将解决问题。
    猜你喜欢
    • 2021-08-21
    • 2020-04-04
    • 2021-10-19
    • 2021-02-11
    • 2021-08-09
    • 2020-05-22
    • 2021-05-21
    • 2021-06-10
    相关资源
    最近更新 更多