Haize
Haize
DIAdiscord.js - Imagine an app
Created by Haize on 7/10/2023 in #djs-questions
Expected a string primitive
Keep getting this from my embed fields input.value | | ValidationError > s.string | | Expected a string primitive | | | | Received: | | | 720
const embed = new EmbedBuilder()
.setColor(0xFF6122)
.setTitle(answer.username)
.setURL(userlink)
.setThumbnail(answer.avatar)
.setTimestamp()
.setFooter({
text: `Project Athena`,
})
.addFields([
{
name: 'Nickname',
value: answer.name
},
{
name: 'Creation Date',
value: answer.createDate
},
{
name: 'Following',
value: answer.numFollowing
},
{
name: 'Followers',
value: answer.numFollowers
},
{
name: 'Reading Lists',
value: answer.numLists
},
{
name: 'Works',
value: answer.numStoriesPublished
},
]);


const embed = new EmbedBuilder()
.setColor(0xFF6122)
.setTitle(answer.username)
.setURL(userlink)
.setThumbnail(answer.avatar)
.setTimestamp()
.setFooter({
text: `Project Athena`,
})
.addFields([
{
name: 'Nickname',
value: answer.name
},
{
name: 'Creation Date',
value: answer.createDate
},
{
name: 'Following',
value: answer.numFollowing
},
{
name: 'Followers',
value: answer.numFollowers
},
{
name: 'Reading Lists',
value: answer.numLists
},
{
name: 'Works',
value: answer.numStoriesPublished
},
]);


15 replies
DIAdiscord.js - Imagine an app
Created by Haize on 12/31/2022 in #djs-questions
TypeError Cannot read properties of undefined (reading 'cache')
I'm trying to make a user info command that returns the user's roles, however I seem to be running into that error when I try to run the command. This is my code:
const {SlashCommandBuilder} = require('discord.js');
const { EmbedBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName ('userinfo')
.setDescription ('Get information about a user.')
.addUserOption((option) =>
option
.setName('user')
.setDescription('The user you want to get info about')
.setRequired(true)

),
async execute(interaction) {
const user = interaction.options.getUser('user');
const roles = user.roles.cache;

const infoEmbed = new EmbedBuilder()
.setColor(0xd66fe1)
.setTitle('User Info')
.setDescription('Display info about a selected user')
.addFields( [
{
name: 'Username',
value: `${interaction.user.username}`
},


{
name: 'Roles',
value: `${roles}`
}

],

)

await interaction.reply({
embeds: [infoEmbed]

})

}
}
const {SlashCommandBuilder} = require('discord.js');
const { EmbedBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName ('userinfo')
.setDescription ('Get information about a user.')
.addUserOption((option) =>
option
.setName('user')
.setDescription('The user you want to get info about')
.setRequired(true)

),
async execute(interaction) {
const user = interaction.options.getUser('user');
const roles = user.roles.cache;

const infoEmbed = new EmbedBuilder()
.setColor(0xd66fe1)
.setTitle('User Info')
.setDescription('Display info about a selected user')
.addFields( [
{
name: 'Username',
value: `${interaction.user.username}`
},


{
name: 'Roles',
value: `${roles}`
}

],

)

await interaction.reply({
embeds: [infoEmbed]

})

}
}
8 replies