[英]Embed Message discord.js by module
I use module to create the command and then I want to use embed massage on there.There are my code我使用模块来创建命令,然后我想在那里使用嵌入按摩。有我的代码
const { MessageEmbed } = require('discord.js')
module.exports = {
data: new SlashCommandBuilder()
.setName('info')
.setDescription('Check info'),
data: new MessageEmbed()
.setTitle('Hello'),
async execute(interaction) {
await interaction.reply(`User info ${interaction.user.tag}\n Userid${interaction.user.id}\n Create Time ${interaction.user.createdAt}`);
},
}
When I run the command,I get this.How I can fix it当我运行命令时,我得到了这个。我该如何解决它
0.name[BASE_TYPE_REQUIRED]: This field is required
0.type[NUMBER_TYPE_COERCE]: Value "rich" is not int.
rawError: {
code: 50035,
errors: { '0': [Object] },
message: 'Invalid Form Body'
}
You are declaring the data
key twice, which is probably what you don't want to do.您两次声明
data
键,这可能是您不想做的。 Try this:尝试这个:
const { MessageEmbed } = require('discord.js')
module.exports = {
data: new SlashCommandBuilder()
.setName('info')
.setDescription('Check info'),
async execute(interaction) {
await interaction.reply({
embeds: [
new MessageEmbed().setTitle("Title").setDescription("Description...")
]
});
},
}
You can try this:你可以试试这个:
const { MessageEmbed } = require('discord.js')
module.exports = {
data: new SlashCommandBuilder()
.setName('info')
.setDescription('Check info'),
async execute(interaction) {
let embed = new MessageEmbed()
.setTitle("Title...")
.setDescription("Description...")
await interaction.reply({ embeds: [embed] });
},
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.