我正在嘗試讓我的機器人使用嵌入訊息,但是它不起作用,因為我不斷收到訊息未定義錯誤
我試過只使用author.bot,但后來出現未定義作者,需要提一下,我正在使用DiscordJS指南提供的命令處理程式,然后我嘗試使用DiscordJS Guide for Embeds,但它沒有用,基本上我就是這樣結束的
下面的代碼
const { SlashCommandBuilder } = require('@discordjs/builders');
const { MessageEmbed } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('embed')
.setDescription('A W.I.P Embed'),
async execute(interaction) {
const Embed1 = new MessageEmbed().setTitle('Some title');
if (message.author.bot) {
Embed1.setColor('#7289da');
}
}
};```
uj5u.com熱心網友回復:
這是因為當匯出的專案為:時您正在使用一個message物件:interaction。
改變:
if (message.author.bot) {
Embed1.setColor('#7289da');
}
到:
if (interaction.user.bot) {
Embed1.setColor('#7289da');
}
沒有interaction.author而且只有一個interaction.user,因此是檢查它是否是機器人的唯一方法。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/443020.html
