【问题标题】:Editing embeds by selecting from a select menu in discord.js V13通过从 discord.js V13 中的选择菜单中进行选择来编辑嵌入
【发布时间】:2022-07-22 22:55:23
【问题描述】:

有没有办法让机器人在从选择菜单中选择一个选项后编辑嵌入的消息? 就像嵌入上的消息是:“Fruit”, 如果您在选择菜单中选择 Mango,嵌入的文本将编辑为 “Mango”。 如果您在选择菜单中选择 Apple,嵌入的文本将编辑为 "Apple"

而且,有关更多信息,嵌入和选择菜单位于同一消息中。

【问题讨论】:

  • 是的,有办法做到这一点。你试过什么吗?你有什么问题?

标签: discord.js


【解决方案1】:

是的,例如,如果您像这样使用interactionCreate 事件:

client.on('interactionCreate', async interaction =>{
 // First we make sure it's the right select menu
  if(interaction.customId !== "your_select_menu_id") return;

 // ...
})

我们可以使用 values 属性来获取选定的选项,该属性是一个数组并获取第一个元素。

let selected = interaction.values[0]

然后我们只需将消息的内容编辑到选定的变量中

await interaction.message.edit({ content : selected })

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-08-17
    • 1970-01-01
    • 2017-06-27
    • 2023-03-17
    • 2014-04-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多