K
Kord•5mo ago
Shaun

How do I unregister commands to reregister them with updates?

How do I unregister commands to reregister them with updates?
97 Replies
gdude
gdude•5mo ago
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 again
Shaun
ShaunOP•5mo ago
It's not updating
kord.createGlobalChatInputCommand("item", "Estimates a price for a given item") {
attachment("image", "A screenshot of the popup when you hover the item") {
required = true
}
}
kord.createGlobalChatInputCommand("item", "Estimates a price for a given item") {
attachment("image", "A screenshot of the popup when you hover the item") {
required = true
}
}
I'm running this and it doesn't update
gdude
gdude•5mo ago
did you wait an hour before checking that? global commands can take a while to be evicted from the client's cache
Shaun
ShaunOP•5mo ago
No, ah I remember that's a thing... IIRC you can do it on each guild and its instant right?
gdude
gdude•5mo ago
guild ones are usually instant yeah
Shaun
ShaunOP•5mo ago
How can I get access to all guilds we're in?
gdude
gdude•5mo ago
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?
Shaun
ShaunOP•5mo ago
do I call that after .login or anywhere in particular? And wdym a framework? I'm just copying the docs
gdude
gdude•5mo ago
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
Shaun
ShaunOP•5mo ago
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?
gdude
gdude•5mo ago
pretty much yeah
Shaun
ShaunOP•5mo ago
Would you recommend any?
gdude
gdude•5mo ago
I maintain kordex so I'd rec that, but there's a comparison table here https://docs.kordex.dev/framework-comparison.html
Shaun
ShaunOP•5mo ago
Is it well documented?
gdude
gdude•5mo ago
well, that's the documentation site it's not finished but a good chunk of the important stuff is done
Shaun
ShaunOP•5mo ago
What's this? never seen this in my life gradle/libs.versions.toml
gdude
gdude•5mo ago
that's a version catalog
Shaun
ShaunOP•5mo ago
Optional?
gdude
gdude•5mo ago
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
Shaun
ShaunOP•5mo ago
No description
gdude
gdude•5mo ago
is that a linter?
Shaun
ShaunOP•5mo ago
Just IDEA
gdude
gdude•5mo ago
oh yeah, mine complains as well odd, that's new
Shaun
ShaunOP•5mo ago
It doesn't like the newlines Wants it all on same line
gdude
gdude•5mo ago
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
Shaun
ShaunOP•5mo ago
lmao this library is kotlin af I love it
gdude
gdude•5mo ago
lmao, well that was the idea, idiomatic api
Shaun
ShaunOP•5mo ago
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
gdude
gdude•5mo ago
you want to add global commands to every guild?
Shaun
ShaunOP•5mo ago
Just for testing purposes rn, yes
gdude
gdude•5mo ago
or, what, you want all commands to be guild commands?
Shaun
ShaunOP•5mo ago
It's just so I can iterate on the command fast
gdude
gdude•5mo ago
if you're testing, I'd recommend registering all global commands to a single guild
Shaun
ShaunOP•5mo ago
Yea sure
gdude
gdude•5mo ago
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
Shaun
ShaunOP•5mo ago
And it will automatically register commands to that guild?
gdude
gdude•5mo ago
yep
applicationCommands {
defaultGuild(envOrNull("TEST_GUILD_ID"))
}
applicationCommands {
defaultGuild(envOrNull("TEST_GUILD_ID"))
}
for example
Shaun
ShaunOP•5mo ago
No description
gdude
gdude•5mo ago
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
Shaun
ShaunOP•5mo ago
Yea that solved it, thanks
gdude
gdude•5mo ago
no worries
Shaun
ShaunOP•5mo ago
are there docs around retrieving attachments?
gdude
gdude•5mo ago
in what context? like, receiving an attachment as a slash command argument?
Shaun
ShaunOP•5mo ago
Yes
gdude
gdude•5mo ago
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
Shaun
ShaunOP•5mo ago
inner class PredictPriceArgs : Arguments() {
val image by attachment {
name = "image"
description = "A screenshot of the item popup"
}
}
inner class PredictPriceArgs : Arguments() {
val image by attachment {
name = "image"
description = "A screenshot of the item popup"
}
}
I have this
gdude
gdude•5mo ago
that looks correct
Shaun
ShaunOP•5mo ago
So I'm guessing somewhere in my action I can grab the image
gdude
gdude•5mo ago
yeah, arguments.image
Shaun
ShaunOP•5mo ago
😮
gdude
gdude•5mo ago
lmao you can tell I beat the type system into submission with that one
Shaun
ShaunOP•5mo ago
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 {} ?
gdude
gdude•5mo ago
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
Shaun
ShaunOP•5mo ago
Does it get uploaded to a URL or do I have an access to the bytes?
gdude
gdude•5mo ago
it has a url property
Shaun
ShaunOP•5mo ago
Gotcha
gdude
gdude•5mo ago
I don't recall if we provide a quick download let me see
Shaun
ShaunOP•5mo ago
Can I group arguments or should I create a separate command with separate arguments?
gdude
gdude•5mo ago
yes, .download and .downloadToFile or .downloadToFolder
Shaun
ShaunOP•5mo ago
E.g (IMAGE or (NAME and RARITY and ATTRIBUTES))
gdude
gdude•5mo ago
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
Shaun
ShaunOP•5mo ago
I want either
/price image_attachment:attachment
/price name:string rarity:string attributes:List<String>
/price image_attachment:attachment
/price name:string rarity:string attributes:List<String>
gdude
gdude•5mo ago
discord doesn't really support that
Shaun
ShaunOP•5mo ago
I'll do it as separate commands then
gdude
gdude•5mo ago
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 it
Shaun
ShaunOP•5mo ago
Just curious, why do we have the set the name here? Couldn't you grab it from the delegate?
No description
gdude
gdude•5mo ago
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
Shaun
ShaunOP•5mo ago
Ahhh yes makes sense
gdude
gdude•5mo ago
publicSlashCommand {
name = "price"
description = "..."

publicSubCommand {
name = "image"
// ...
}

// ...
}
publicSlashCommand {
name = "price"
description = "..."

publicSubCommand {
name = "image"
// ...
}

// ...
}
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
Shaun
ShaunOP•5mo ago
I feel like I'm taking the piss now, can you have "map" parameters somehow?
gdude
gdude•5mo ago
key-value parameters? not really, no
Shaun
ShaunOP•5mo ago
Fuck
gdude
gdude•5mo ago
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
Shaun
ShaunOP•5mo ago
Yea, would that work with autocomplete though It's pretty important from a UX perspective autocomplete is there
gdude
gdude•5mo ago
you could make it work
Shaun
ShaunOP•5mo ago
I saw you can say its autocomplete prefixes
gdude
gdude•5mo ago
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
Shaun
ShaunOP•5mo ago
Oh really , is suggestStringCollection something you've created for convience?
gdude
gdude•5mo ago
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
Shaun
ShaunOP•5mo ago
Oohh I have an idea actually
gdude
gdude•5mo ago
you can have up to 25 suggestions
Shaun
ShaunOP•5mo ago
Can we do dynamic parameters? That would be mcuh better
gdude
gdude•5mo ago
what do you mean by that?
Shaun
ShaunOP•5mo ago
Bare with
/price name:"Longsword" Damage:20 BonusTrueDamage:1
/price name:"Boots" MoveSpeed:20 BonusTrueDamage:1
/price name:"Longsword" Damage:20 BonusTrueDamage:1
/price name:"Boots" MoveSpeed:20 BonusTrueDamage:1
Essentially, based on the name parameter, other arguments become available, you would not be suggested MoveSpeed on Longsword, in this case.
gdude
gdude•5mo ago
command registration requires you to specify all arguments and their types to Discord in advance unfortunately
Shaun
ShaunOP•5mo ago
And there are no conditional args
gdude
gdude•5mo ago
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
Shaun
ShaunOP•5mo ago
I could register each item as sub command?
gdude
gdude•5mo ago
you could do that, but again, 25 subcommands
Shaun
ShaunOP•5mo ago
😭
gdude
gdude•5mo ago
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
Shaun
ShaunOP•5mo ago
Can I have a repeated argument
gdude
gdude•5mo ago
there are no collection arguments for slash commands
Shaun
ShaunOP•5mo ago
That's surprising
gdude
gdude•5mo ago
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.
Shaun
ShaunOP•5mo ago
Thanks for your help I'll see what I can do
gdude
gdude•5mo ago
No worries, gl with it There's a separate KordEx server linked in the docs if you need that as well
Want results from more Discord servers?
Add your server