【问题标题】:Discord.js: [ object Object ]Discord.js:[对象对象]
【发布时间】:2021-12-14 16:12:14
【问题描述】:

我一直在努力改进我的票务系统并遇到了这个问题:

我的代码是:

    await button.clicker.fetch();
    if (!button.clicker.member.roles.cache.has("859507507596230736")) return button.reply.send("Only staff can close the ticket.", true)
    var embed = new Discord.MessageEmbed()
    .setTitle("Are you sure?")
    .setDescription("Are you sure you want to close this ticket?\nThis action cannot be undone.")
    .setFooter(button.guild.name)
    .setColor("RED")
    var bu1tton = new MessageButton()
      .setStyle(`red`)
      .setEmoji(`????`)
      .setLabel(`Proceed anyway`)
      .setID("sure")
    button.reply.send({ component: bu1tton, embed: embed }, true)
  }

在我将button.reply.send({ component: bu1tton, embed: embed }, true) 更改为button.channel.send({ component: bu1tton, embed: embed }) 后,它运行良好,虽然每个人都可以看到。

我知道问题是, true,但我不明白为什么?提前致谢。

【问题讨论】:

  • [object Object] 是当您(或您正在使用的组件)尝试将对象与字符串连接(或其他将对象输出为字符串)时。不清楚这对您有何帮助。
  • 试试button.reply.send({ component: bu1tton, embed: embed, ephemeral: true}),也许对你有帮助
  • 我建议您升级到 discord.js v13,这样您就不需要任何外部软件包来处理这些事情。它还会为您提供类型,这样可以更轻松地查看您可能出错的地方。

标签: javascript node.js discord discord.js bots


【解决方案1】:

您必须使用ephemeral: true 而不是}, true)

代码如下:

button.reply.send({ component: bu1tton, embed: embed, ephemeral: true})

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-01
    • 2021-02-02
    • 2020-12-22
    • 2021-12-19
    • 2021-11-03
    • 2017-07-08
    • 2022-07-17
    相关资源
    最近更新 更多