Hi’ I’ve been trying to code an embed for my bot to send but I keep getting the same error “(intermediate value).setTitle(…).setDescription(…).setThumbnail(…).addFields(…).setImage(…).setTimeStamp is not a function”
I’ve looked online for answers but all people who had the same problem had errors in their code in areas mine doesn’t, I’ve been looking for hours and I have no idea what’s wrong. this is my code:
const { SlashCommandBuilder } = require('@discordjs/builders');
const { MessageEmbed, MessageAttachment} = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('information')
.setDescription('Returns info based on input')
.addSubcommand(subcommand =>
subcommand
.setName("user")
.setDescription("Gets information of a user mentioned")
.addUserOption(option => option.setName("target").setDescription("The user mentioned")))
.addSubcommand(subcommand =>
subcommand
.setName('server')
.setDescription("Gets information about the server")),
async execute(interaction, client) {
if (interaction.options.getSubcommand() === "user") {
const user = interaction.options.getUser("target");
if (user) {
const file = new MessageAttachment("./src/images/mayancoin.png");
const userEmbed = new MessageEmbed()
.setTitle(`${user.username} Information:`)
.setDescription("test")
.setThumbnail(client.user.displayAvatarURL())
.addFields(
{ name: `Username:`, value: `Username is: ${user.username}`, inline: true},
{ name: `u200B`, value: `u200B`, inline: true },
{ name: `Tag:`, value: `Tag is: #${user.discriminator}`, inline: true }
)
.setImage("attachment://mayancoin.png")
.setTimeStamp()
.setColor("#009988")
.setFooter(client.user.tag, client.user.displayAvatarURL());
await interaction.reply({ embeds: [userEmbed], files: [file] });
} else {
await interaction.reply(`Username: ${interaction.user.username}nYour ID: ${interaction.user.id}`);
}
} else if (interaction.options.getSubcommand() === "server") {
await interaction.reply(`Server Name: ${interaction.guild.name}nTotal Members: ${interaction.guild.memberCount}`);
} else {
await interaction.reply("No sub command was used");
}
},
};
Any help is appreciated