[英]Discord Js - Bot not sending embed
hi please i need some help the bot is giving an error which is yourid, productownerid, productname is not defined in last steps i tried many codes but no one worked for me if anyone can help me please and thank you嗨,我需要一些帮助,机器人给出了一个错误,即你的 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:[]})
}
})```
Instead of using <@${yourid}>
, you can use userMention(yourid) but i don't think it's the problem.您可以使用 userMention(yourid) 而不是使用
<@${yourid}>
,但我认为这不是问题所在。 I think the probleme is the.setFooter for the date you don't have to do ${new Date()}
there is a command for this: .setTimestamp().我认为问题是您不必执行
${new Date()}
的日期的 .setFooter 有一个命令:.setTimestamp()。 Or another problem you can't put "RANDOM" in.setColor或者另一个你不能把“RANDOM”放在.setColor中的问题
And I use new EmbedBuilder() instead of messageEmbed()我使用 new EmbedBuilder() 而不是 messageEmbed()
You also have to put "," at the end of a field like this:您还必须在这样的字段末尾放置“,”:
.setFields(
{ name: '**Buyer-Name**', value: `<@${yourid}>`},
{ name: '**Owner Of The Product**', value:`**<@${productownerid}>**`},
{ name: '**Product**', value:`**${productname}**`},
{ name: '**Message**', value: `**${evalmsg}**`},
{ name: '**Evaluation**', value: `**💖**`},
)
You also have to set a Title with.setTitle('title')您还必须设置标题 with.setTitle('title')
The last error i saw is for search a channel I use interaction.guild.channels.fetch('id')我看到的最后一个错误是搜索我使用的频道 interaction.guild.channels.fetch('id')
So i propose you this correction:所以我建议你这个更正:
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.