“標題”:${interaction.user.username}'s Profile
ReferenceError:未定義互動
const { SlashCommandBuilder } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
const profileEmbed = {
"type": "rich",
"color": 0x00fff0,
"title": `${interaction.user.username}'s Profile`
"avatar": ?
}
module.exports = {
data: new SlashCommandBuilder()
.setName('profile')
.setDescription('Replies with your profile!'),
async execute(interaction) {
await interaction.reply({embeds: [profileEmbed]});
},
};
有沒有辦法可以在“標題”和“頭像”中使用互動?運行 node deploy-commands.js 檔案時出現“未定義互動”錯誤
uj5u.com熱心網友回復:
您始終可以將profileEmbed
物件轉換為回傳物件的函式,然后傳入互動。
function profileEmbed(interaction) {
return {
"type": "rich",
"color": 0x00fff0,
"title": `${interaction.user.username}'s Profile`
"avatar": ?
}
}
await interaction.reply({embeds: [profileEmbed(interaction)]})
就風格而言,這可能不是您要尋找的,但它應該可以完成您想要做的事情。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/508431.html
標籤:javascript 不和谐.js 命令 削减