conversion of ApplicationCommand to SlashCommandBuilder object
is there a way to convert
ApplicationCommand
to SlashCommandBuilder
object?
coz the object received from fetching the API and the locally created ones won't match when I directly compare them after serialization28 Replies
• What's your exact discord.js
npm list discord.js
and node node -v
version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.For example converting this:
to this:
also don't mind the command action 😅 they are renamed in non-spammy intervals
Use the slashcommandbuilder
On the applicationcommand
how if the scb constructor doesn't take arguments?
What exactly is your use case?
check system to decide whether to deploy all/new local commands if the commands fetch from the API don't match the local ones
Well, use the methods
You don't have to do it for each an every application command, you can use a map
💀 if I use the methods, it would be another adventure in rewrite my own slash command builder
so stressful
I thought it was to like, viewthe application command object as a slashcommandbuilder object
Maybe if I understand thr goal I'd know what to do
I mean even if I do so, how would I access the properties. I'm actually stuck on a way to access properties with the same name easily like:
dmPermission
and dm_permission
I would have gone with iterating them with a for..in
loop but I really doubt the ordering in the object
so my only option is to access them by their namesI thought that's what the slash command builder was for, to make all the objects alike and compare, comparing names may be easier though since slash command names are unique
I'm trying to compare the whole object and see if there's any difference, in relation to the other
if I serialize it and compare, it will always be false coz the API data contains more properties than the builder object does
not to forget the differences in values and names of properties
Oh then, try converting the builder to json
That should give an applicationcommand object
nah.. it's the same
I wish the slash command builder used the same property names as the API does
It does, the ApplicationCommand object discord.js returns has its properties in pascalCase
Thats the one you are getting
I'm not sure how you'd convert a slashcommandbuilder object to that though
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
it's the opposite, I want the ApplicationCommand -> SlashCommandBuilder object
it's weird that APIApplicationCommand is the same as builder object tho 🤔
The slash command builder is what you use to deploy commands, the applicationcommand object is from like, fetching commands or getting commands from the cache
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
ya but like having the same property names would be easier coz the only work left would be matching mutual properties in both objects
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Yeah that's why it has the same properties as the apiapplicationcommand object
But you said you wanna convert the application command object to a slashcommandbuilder object, why doesn't the builder work for you again?
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
because I'll have to manually pass each property and who knows how many transformations I'd have to do to each property I guess it's time to move to raw json
It is alot of work but I can't think of another way, since the builder doesn't provide a method for this nor can you use the constructor so
ikr! :pepehands:
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
ohh