How do I unregister commands to reregister them with updates?
How do I unregister commands to reregister them with updates?
97 Replies
get the command object from Discord and call
.delete()
but you don't have to do that if you're just updating a command
you can just create it againIt's not updating
I'm running this and it doesn't update
did you wait an hour before checking that?
global commands can take a while to be evicted from the client's cache
No, ah I remember that's a thing... IIRC you can do it on each guild and its instant right?
guild ones are usually instant yeah
How can I get access to all guilds we're in?
kord.guilds
current shard only I think
you seem like you're writing a framework, are you sure you wouldn't prefer to use an existing one?do I call that after .login or anywhere in particular? And wdym a framework?
I'm just copying the docs
ah, I see
kord provides the protocol implementation, frameworks provide the abstractions on top for actually writing the bot
and you'd have to call it after your guilds have been received
you might be better off reacting to the guild creation event
kord is just a wrapper of the discord API, and there are other higher level frameworks built on kord that would make my life easier?
pretty much yeah
Would you recommend any?
I maintain kordex so I'd rec that, but there's a comparison table here https://docs.kordex.dev/framework-comparison.html
Kord Extensions Help
Framework Comparison | Kord Extensions
Is it well documented?
well, that's the documentation site
it's not finished but a good chunk of the important stuff is done
What's this? never seen this in my life
gradle/libs.versions.toml
that's a version catalog
Optional?
https://docs.gradle.org/current/userguide/platforms.html#sub:conventional-dependencies-toml
don't ask me why this is the url
it's optional yeah, it's just one of a few ways of specifying dependencies
man those gradle doc urls suck lmao
is that a linter?
Just IDEA
oh yeah, mine complains as well
odd, that's new
It doesn't like the newlines
Wants it all on same line
hm, odd, was fine when I wrote that
no biggie tho, just remove the newlines
there's a template here if you prefer https://github.com/kord-extensions/template
lmao this library is kotlin af
I love it
lmao, well that was the idea, idiomatic api
Okay so I followed the guide to register a command and I still don't see it
How do I add to to every guild in this framework
you want to add global commands to every guild?
Just for testing purposes rn, yes
or, what, you want all commands to be guild commands?
It's just so I can iterate on the command fast
if you're testing, I'd recommend registering all global commands to a single guild
Yea sure
you can set a default guild in the application commands builder
https://docs.kordex.dev/config-commands.html#application-command-functions
you could do like
And it will automatically register commands to that guild?
yep
for example
or just hardcode it, whatever, you know what you're doing
ah yeah I've seen this, one sec
when it came up on the kordex server, it turned out to be a discord caching problem solved by kicking and re-adding the bot
just checked
not really sure why it happens, I wasn't able to reproduce it
Yea that solved it, thanks
no worries
are there docs around retrieving attachments?
in what context?
like, receiving an attachment as a slash command argument?
Yes
yeah, just add an argument for it
have you made an Arguments subtype yet?
for your command's arguments
one of these https://docs.kordex.dev/commands.html#arguments-classes
ah jeez, it autoformatted out my indents again
writerside is pain sometimes
I have this
that looks correct
So I'm guessing somewhere in my action I can grab the image
yeah,
arguments.image
😮
lmao
you can tell I beat the type system into submission with that one
When people try and argue java is a better language I'm going to show them this framework
Can I do my processing in action {} ?
you probably could do something similar in java
you'd just need a lot more boilerplate
yeah, it's a coroutine, do what you need
you can always use a dispatcher if it's really a problem, but it should be fine
Does it get uploaded to a URL or do I have an access to the bytes?
it has a url property
Gotcha
I don't recall if we provide a quick download
let me see
Can I group arguments or should I create a separate command with separate arguments?
yes,
.download
and .downloadToFile
or .downloadToFolder
E.g (IMAGE or (NAME and RARITY and ATTRIBUTES))
you can use command groups if you feel like it'd make the UX better
each subcommand would need its own arguments class though
it really depends on what you think would be more intuitive for your users
there's subcommands and command groups, https://docs.kordex.dev/slash-commands.html#subcommands
I want either
discord doesn't really support that
I'll do it as separate commands then
you could have
/price image <attachment>
and /price data ...
tho
so you'd define your root command as normal, don't provide an arguments class or an action block, and then use the subCommand builders inside itJust curious, why do we have the set the name here? Couldn't you grab it from the delegate?
in theory yes, but KordEx has built-in support for i18n, so you could eg provide a translation key for the name
can't really have dots in a property name
Ahhh yes makes sense
what I meant earlier
took me a minute haha
the type of the parent command doesn't matter if you're using subcommands
it feels a bit odd but it didn't make sense to have a separate type for groups imo
if you define checks on a parent command, they'll be inherited by subcommands as well
I feel like I'm taking the piss now, can you have "map" parameters somehow?
key-value parameters? not really, no
Fuck
container-based parameters don't make sense given how discord's done slash commands
you could theoretically support your own delimiter and split on it with a string argument
Yea, would that work with autocomplete though
It's pretty important from a UX perspective autocomplete is there
you could make it work
I saw you can say its autocomplete prefixes
you can provide an autocomplete callback that provides suggestions
it's up to you what those suggestions are
you have access to the provided value, of course
Oh really , is
suggestStringCollection
something you've created for convience?yes
https://docs.kordex.dev/converters.html#settings-all-autocomplete
the suggestion functions filter the collection based on the provided value and filtering strategy
and then provide the matching values as separate suggestions
Oohh I have an idea actually
you can have up to 25 suggestions
Can we do dynamic parameters?
That would be mcuh better
what do you mean by that?
Bare with
Essentially, based on the
name
parameter, other arguments become available, you would not be suggested MoveSpeed on Longsword, in this case.command registration requires you to specify all arguments and their types to Discord in advance unfortunately
And there are no conditional args
no
but
by overriding a property in the arguments class, you can get at earlier argument values in the autocomplete builder for later arguments
so you could, I suppose, have a bunch of optional arguments and then use autocomplete to tell the user the argument isn't applicable
seems janky though
you can only have 25 arguments as well
I could register each item as sub command?
you could do that, but again, 25 subcommands
ðŸ˜
discord's command system isn't really made for this haha
I suppose you could have separate commands for modifying each attribute but that makes things more cumbersome
honestly maybe the kind of thing a web interface would be better for
but that module isn't done yet /lh
Can I have a repeated argument
there are no collection arguments for slash commands
That's surprising
you'd have to duplicate it with a different name each time
that's discord for ya
you could probably collapse that into a list using a
by lazy
property I guess, still cumbersome though
probably worth mentioning that there's nothing particularly special about the properties on your arguments class, you can add whatever you need there
the converter functions (used to define arguments) add each argument to a list in the background, that's how they get filled haha
I'm gonna be shutting down my PC now (it's late) but your IDE and the docs site both have searches if you need them
tho writerside's search is.. not amazing. but it'll get you there.Thanks for your help
I'll see what I can do
No worries, gl with it
There's a separate KordEx server linked in the docs if you need that as well