Can you use variable in embedBuilder name and description?

I have a embedBuilder instance and It doesn't seem to work. const embed = new EmbedBuilder() .setTitle(name) .setDescription(description) .setColor('#0099ff'); The error is as follows: R:\Developer\Discord bots\Foxia\Foxia Events\node_modules@sapphire\shapeshift\dist\cjs\index.cjs:1854 return Result.err(new CombinedError(errors)); ^ CombinedError: Received one or more errors at _UnionValidator.handle (R:\Developer\Discord bots\Foxia\Foxia Events\node_modules@sapphire\shapeshift\dist\cjs\index.cjs:1854:23) at _UnionValidator.parse (R:\Developer\Discord bots\Foxia\Foxia Events\node_modules@sapphire\shapeshift\dist\cjs\index.cjs:939:90) at EmbedBuilder.setTitle (R:\Developer\Discord bots\Foxia\Foxia Events\node_modules@discordjs\builders\dist\index.js:373:20) at sendEventEmbed (R:\Developer\Discord bots\Foxia\Foxia Events\src\functions\event\eventEmbed.js:24:10) at Object.<anonymous> (R:\Developer\Discord bots\Foxia\Foxia Events\index.js:13:83) at Module._compile (node:internal/modules/cjs/loader:1256:14) at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) at Module.load (node:internal/modules/cjs/loader:1119:32) at Module._load (node:internal/modules/cjs/loader:960:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) { errors: [ ExpectedValidationError: Expected values to be equals at _LiteralValidator.handle (R:\Developer\Discord bots\Foxia\Foxia Events\node_modules@sapphire\shapeshift\dist\cjs\index.cjs:1485:76) at _LiteralValidator.run (R:\Developer\Discord bots\Foxia\Foxia Events\node_modules@sapphire\shapeshift\dist\cjs\index.cjs:925:23) at _UnionValidator.handle (R:\Developer\Discord bots\Foxia\Foxia Events\node_modules@sapphire\shapeshift\dist\cjs\index.cjs:1849:32) at _UnionValidator.parse (R:\Developer\Discord bots\Foxia\Foxia Events\node_modules@sapphire\shapeshift\dist\cjs\index.cjs:939:90) at EmbedBuilder.setTitle (R:\Developer\Discord bots\Foxia\Foxia Events\node_modules@discordjs\builders\dist\index.js:373:20) at sendEventEmbed (R:\Developer\Discord bots\Foxia\Foxia Events\src\functions\event\eventEmbed.js:24:10) at Object.<anonymous> (R:\Developer\Discord bots\Foxia\Foxia Events\index.js:13:83) at Module._compile (node:internal/modules/cjs/loader:1256:14) at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) at Module.load (node:internal/modules/cjs/loader:1119:32) { validator: 's.literal(V)', given: undefined, expected: null }, ValidationError: Expected a string primitive at _StringValidator.handle (R:\Developer\Discord bots\Foxia\Foxia Events\node_modules@sapphire\shapeshift\dist\cjs\index.cjs:2473:70) at _StringValidator.run (R:\Developer\Discord bots\Foxia\Foxia Events\node_modules@sapphire\shapeshift\dist\cjs\index.cjs:925:23) at _UnionValidator.handle (R:\Developer\Discord bots\Foxia\Foxia Events\node_modules@sapphire\shapeshift\dist\cjs\index.cjs:1849:32) at _UnionValidator.parse (R:\Developer\Discord bots\Foxia\Foxia Events\node_modules@sapphire\shapeshift\dist\cjs\index.cjs:939:90) at EmbedBuilder.setTitle (R:\Developer\Discord bots\Foxia\Foxia Events\node_modules@discordjs\builders\dist\index.js:373:20) at sendEventEmbed (R:\Developer\Discord bots\Foxia\Foxia Events\src\functions\event\eventEmbed.js:24:10) at Object.<anonymous> (R:\Developer\Discord bots\Foxia\Foxia Events\index.js:13:83) at Module._compile (node:internal/modules/cjs/loader:1256:14) at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) at Module.load (node:internal/modules/cjs/loader:1119:32) { validator: 's.string', given: undefined } ] } Node.js v18.17.1
5 Replies
d.js toolkit
d.js toolkit3mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Acemavie
Acemavie3mo ago
Discordjs version: discord.js@14.14.1
Spaxter
Spaxter3mo ago
Log the values of your variables. You're probably passing undefined instead of a string
Acemavie
Acemavie3mo ago
I think I fixed but I have a quick question. If I define a slash command /event in one file. And then have a subcommand in a another file like this: (attachement). Will it work? Cause I tried and it didn't work. Or am I just doing something wrong? I tried defining the base command in all of my 3 files that make subcommands to that but It gave me a error that all commands must be unique
No description
Acemavie
Acemavie3mo ago
So I cant have /event info in one file and /event 123 in a another file?