【问题标题】:Redirect to a channel as well as ping a role then post a message using args重定向到频道以及 ping 角色,然后使用 args 发布消息
【发布时间】:2021-08-01 11:58:19
【问题描述】:

我正在为我的机器人发出公告命令,并希望它自动进入公告频道,然后 ping 提到的第一个角色,最后显示消息。

现在我将它作为占位符使用人员命令以使其工作,这不起作用或引发错误。它正确地对角色执行 ping 操作,但之后什么也没有出现,甚至是“调试”。我错过了什么。我已经看到频道部分工作,但它不适合我,我在网上找不到消息本身的类似情况。

module.exports.run = async (client, message, args) => {
    if (message.author.bot) return;
    let prefix = config.prefix;
    if(!message.content.startsWith(prefix)) return;

    const channel = message.guild.channels.cache.find(c => c.name === '????|staff-cmds');

    let pingRole = message.mentions.roles.first(); 
    let messageContent = args.slice(1).join(' ');

      channel.send(pingRole, messageContent, "Debug");

This is what happens when the command is run

【问题讨论】:

    标签: discord discord.js


    【解决方案1】:

    试试这个channel.send(`${pingRole} ${messageContent}`) channel.send() 函数只需要两个参数“内容”和“选项”,您可以阅读更多关于它的信息here

    【讨论】:

    • 谢谢,完全跳过了文档中的内容。
    猜你喜欢
    • 1970-01-01
    • 2019-01-31
    • 2020-12-28
    • 2021-07-14
    • 2020-03-20
    • 1970-01-01
    • 1970-01-01
    • 2020-09-05
    • 1970-01-01
    相关资源
    最近更新 更多