簡體   English   中英

Discord Js - Bot 不發送嵌入

[英]Discord Js - Bot not sending embed

嗨,我需要一些幫助,機器人給出了一個錯誤,即你的 ID、productownerid、productname 未在最后一步中定義我嘗試了很多代碼,但沒有人為我工作,如果有人能幫助我,謝謝

  if(interaction.customId == 'evv'){
    let yourid = interaction.fields.getTextInputValue('ask_1')
    let productownerid = interaction.fields.getTextInputValue('ask_2')
    let productname = interaction.fields.getTextInputValue('ask_3')
    let evalmsg = interaction.fields.getTextInputValue('ask_4')
    const exampleEmbed = new MessageEmbed()
    .setColor("RANDOM")
.setFields(
{ name: '**Buyer-Name**', value: `<@${yourid}>`}
{ name: '**Owner Of The Product**', value:`**<@${productownerid}>**`}
{ name: '**Product**', value:`**${productname}**`}
{ name: '**Message**', value: `**${evalmsg}**`}
)
.setFooter(`Requested By ${interaction.user.tag} , ${new Date()}`)
let button25 = new MessageActionRow().addComponents(
  new MessageButton()
      .setCustomId('1')
      .setLabel("تقييم")
      .setStyle('PRIMARY')
      .setEmoji("💖")
)
await interaction.guild.channels.cache.get("1048414164932108289").send({embeds: [exampleEmbed],components:[button25]}) 
  }
the error is from here :

if (interaction.customId == '1'){
  const exampleEmbed2 = new MessageEmbed()
  .setColor("RANDOM")
.setFields(
{ name: '**Buyer-Name**', value: `<@${yourid}>`}
{ name: '**Owner Of The Product**', value:`**<@${productownerid}>**`}
{ name: '**Product**', value:`**${productname}**`}
{ name: '**Message**', value: `**${evalmsg}**`}
{ name: '**Evaluation**', value: `**💖**`}
)
.setFooter(`Requested By ${interaction.user.tag} , ${new Date()}`)
interaction.guild.channels.cache.get("1048414164932108289").send({embeds: [exampleEmbed2],components:[]}) 
}
})```

您可以使用 userMention(yourid) 而不是使用<@${yourid}> ,但我認為這不是問題所在。 我認為問題是您不必執行${new Date()}的日期的 .setFooter 有一個命令:.setTimestamp()。 或者另一個你不能把“RANDOM”放在.setColor中的問題

我使用 new EmbedBuilder() 而不是 messageEmbed()

您還必須在這樣的字段末尾放置“,”:

.setFields(
  { name: '**Buyer-Name**', value: `<@${yourid}>`},
  { name: '**Owner Of The Product**', value:`**<@${productownerid}>**`},
  { name: '**Product**', value:`**${productname}**`},
  { name: '**Message**', value: `**${evalmsg}**`},
  { name: '**Evaluation**', value: `**💖**`},
)

您還必須設置標題 with.setTitle('title')

我看到的最后一個錯誤是搜索我使用的頻道 interaction.guild.channels.fetch('id')

所以我建議你這個更正:

if (interaction.customId == '1'){
  const exampleEmbed2 = new EmbedBuilder()
  .setTitle('title')
  .setColor(15548997)
  .addFields(
    { name: '**Buyer-Name**', value: userMention(yourid)},
    { name: '**Owner Of The Product**', value: '**' + userMention(productownerid) + '**'},
    { name: '**Product**', value:`**${productname}**`},
    { name: '**Message**', value: `**${evalmsg}**`},
    { name: '**Evaluation**', value: `**💖**`},
  )
  .setFooter(`Requested By ${interaction.user.tag}`)
  .setTimestamp()
  interaction.guild.channels.fetch("1048414164932108289").send({embeds: [exampleEmbed2]}) 
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM