Application Command Registry Interface v1

@here Your feedback is required again! We're inching closer and closer to having application commands in Sapphire, but there's still places where polishing is required, and most importantly, your POGYOUPOINT feedback is wanted! As you're hopefully used to already, here's the notion doc with examples: https://vladfrangu.notion.site/Current-code-examples-for-registering-Application-Commands-in-Sapphire-6720eeb8f8be4cfa92292c44f1db9a2c Please note that these are samples. They may change per your feedback, and at the end, I will create a repository showing it off in an actual code base for those that have uncertainties! So hit me in the thread attached to this message - thoughts? Like it? Dislike it? Why? What would you want to see different?
Vlad Frangu's Notion on Notion
Current code examples for registering Application Commands in Sapphire
Per the vote in the thread, I've been drafting code samples with how you can register commands in Sapphire. Feedback is important, so please reply in the thread attached to this with your thoughts.
135 Replies
fried
fried4y ago
looks great
vladdy
vladdyOP4y ago
how in the mcfuck did you read that document so fast
fried
fried4y ago
um bulgarian genetics
fried
fried4y ago
registry cool
𝖄𝖚𝖌𝖊𝖓
looks great
fried
fried4y ago
its like windows actually when i started to read it
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
fried
fried4y ago
looks pretty good
vladdy
vladdyOP4y ago
For context, to me this feels like the cleanest way to register what command classes can handle what slash commands (and also handle things like guild commands that are supposed to run the same code, etc) This will also handle registering it with Discord for you!
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
24
244y ago
overrideBehaviorOnDuplicate maybe?
𝖄𝖚𝖌𝖊𝖓
So The store is a Store? A sapphire pieces store?
fried
fried4y ago
i like stores
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
vladdy
vladdyOP4y ago
no the RegistryStore is a store of registries, not a piece Namings ASoof
bitomic
bitomic4y ago
the registry stuff feels kinda weird compared to the rest of sapphire's stuff not something bad per se, tho
𝖄𝖚𝖌𝖊𝖓
Yeh might wanna avoid that Because if it was a store. The container property makes no sense. But since its not. The name makes no sense Haha Only feedback I got
vladdy
vladdyOP4y ago
NAMING ASIDE
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
vladdy
vladdyOP4y ago
I'll search a better name for the registry store ideally as little as possible
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
Favna
Favna4y ago
@vladdy can you make it so registerApplicationCommands is automatically called by setting a CommandOption? such as registerChatInputCommand: boolean which then uses the defaults of this.name and this.description, and default_permission to true (also default, no need to specify that one) This will save on having to override and implement that method either on every command or force everyone to create their own command class that extends command to do the same.
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
𝖄𝖚𝖌𝖊𝖓
Released when?
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
vladdy
vladdyOP4y ago
registerApplicationCommands is automatically called if it's present no matter what. However, I am against the defaults part, especially with some upcoming features for application commands
Favna
Favna4y ago
no I don't meean if it's present. I don't want to have it to be present at all in my code.
𝖄𝖚𝖌𝖊𝖓
Nick shutup
Favna
Favna4y ago
nickk please keep the thread serious
vladdy
vladdyOP4y ago
when most people are happy
fried
fried4y ago
ok well i dont really understand this registry thing
24
244y ago
Then don't participate.
fried
fried4y ago
ok
Favna
Favna4y ago
.
fried
fried4y ago
oh so its like an in depth command
vladdy
vladdyOP4y ago
Please explain whats confusing about it :D
fried
fried4y ago
idk long words
Favna
Favna4y ago
I don't know what Vladdy's plans are per se but Permissions v2 will deprecate mostly anything of what we would make.
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
fried
fried4y ago
actionWhenCommandIsPresentButNotIdentical thats a really long one
vladdy
vladdyOP4y ago
Permissions are undergoing changes at Discord's level, so, at this time, no
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
Favna
Favna4y ago
Then get a dictionary and disect every word @friedxd. We're not a primary school here.
fried
fried4y ago
😦
vladdy
vladdyOP4y ago
well yes and not, they mean different things both for us internally and you externally
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
fried
fried4y ago
OHHHH this is for like application commands that looks great
vladdy
vladdyOP4y ago
Highly unlikely to happen due to the fact people may want to, for instance, intl their description sweats know it's annoying
Favna
Favna4y ago
then they override it? or they dont set the option? I never said the option should default to true
vladdy
vladdyOP4y ago
Hmm
Favna
Favna4y ago
Default it to false in fact if you want, that's fine by me writing code...
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
24
244y ago
const store: ApplicationCommandRegistryStore = container.applicationCommandRegistryStore;

// Get the registry for a command by name
// NOTE: this refers to the Command#name property in your commands that are present
// in the commands folder.
const registry = store.acquire('ping');
const store: ApplicationCommandRegistryStore = container.applicationCommandRegistryStore;

// Get the registry for a command by name
// NOTE: this refers to the Command#name property in your commands that are present
// in the commands folder.
const registry = store.acquire('ping');
Why are we deviating from "store.get"?
vladdy
vladdyOP4y ago
Because you can use it without the ping command having a registry already I can consider a registerChatInputCommandWithDefaults I suppose, but it's definitely not my priority rn. I'd need to think of a name, deal with the default_permissions headache, options too, just.. its really not something that I see as a need due to most commands having at least an arg But noted
Favna
Favna4y ago
@ApplyOptions<CommandOptions>({
description: 'This is a ping command',
registerChatInputCommand: true,
registryBehaviour: RegisterBehavior.Overwrite
})
export class PingCommand extends Command {
public async override chatInputRun(interaction: CommandInteraction) {
// do the ping
}
}
@ApplyOptions<CommandOptions>({
description: 'This is a ping command',
registerChatInputCommand: true,
registryBehaviour: RegisterBehavior.Overwrite
})
export class PingCommand extends Command {
public async override chatInputRun(interaction: CommandInteraction) {
// do the ping
}
}
This is very clean and concise. Much more so than
@ApplyOptions<CommandOptions>({
description: "This is a ping command"
})
export class PingCommand extends Command {
public override registerApplicationCommands(
registry: ApplicationCommandRegistry
) {
registry.registerChatInputCommand(
{ name: this.name, description: this.description },
{ actionWhenCommandIsPresentButNotIdentical: RegisterBehavior.Overwrite }
);
}

public override async chatInputRun(interaction: CommandInteraction) {
// do the ping
}
}
@ApplyOptions<CommandOptions>({
description: "This is a ping command"
})
export class PingCommand extends Command {
public override registerApplicationCommands(
registry: ApplicationCommandRegistry
) {
registry.registerChatInputCommand(
{ name: this.name, description: this.description },
{ actionWhenCommandIsPresentButNotIdentical: RegisterBehavior.Overwrite }
);
}

public override async chatInputRun(interaction: CommandInteraction) {
// do the ping
}
}
vladdy
vladdyOP4y ago
how would you provide the registerbehavior Is it a default to overwrite?
Favna
Favna4y ago
ninja'd it in
vladdy
vladdyOP4y ago
log to console?
Favna
Favna4y ago
uh didn't you write in the notion the default is warn rn?
vladdy
vladdyOP4y ago
Well yes trying to see if I missed anyone else's message sweats
RedS
RedS4y ago
pogey
vladdy
vladdyOP4y ago
What's confusing you the most? These methods separate how we route the interactions we get to the right file/method, hence why there's a split between chat input and context menu commands, even if they look like they do the same thing This will mean we must make command descriptions required. Thats an annoyance for non-chat input command users, I guess I can make it required only for those that use the options but still.. sweats
bitomic
bitomic4y ago
Maybe that it isn't a piece, while everything else is a piece? Although I understand the hot mess that would be handling the command registering from Command class at the same time you handle everything else
vladdy
vladdyOP4y ago
The registry is simply a fancy ui for a map of what goes where. Ignore the store in the name of the ApplicationCommandRegistryStore
bitomic
bitomic4y ago
something like this could be great, from my opinion
vladdy
vladdyOP4y ago
pepeHands of that, are there any questions, suggestions, requests, issues, broken dreams?
24
244y ago
honestly I want to see how this pans out I want to see how this integrates with existing sapphire applications, and see how it works
vladdy
vladdyOP4y ago
Well I wanna get it right the first time
24
244y ago
I think accepting both builders is a great thing, and I kinda think the syntax is fine... maybe bloated, but works I don't know if I'd change the names though.
bitomic
bitomic4y ago
"CommandThingy", "StoringThingy", "UnnamedThing2" (?)
vladdy
vladdyOP4y ago
Yean names are elongatedbois rn its pain How does whenCommandIsPresentButNotIdentical sound? @Favna @daimond113 @twenty_four
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
24
244y ago
better... commandOverrideStrategy?
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
24
244y ago
I see it being vague... override what??
vladdy
vladdyOP4y ago
override is vague
24
244y ago
commandAmbiguityStrategy
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
24
244y ago
2 characters longer than mind... smh
vladdy
vladdyOP4y ago
ifCommandPresentButNotIdentical
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
24
244y ago
ifCommandPresentNotIdentical no buts here boys
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
24
244y ago
whatToDoOnCommandMatch
vladdy
vladdyOP4y ago
whenPresentButNotIdentical
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
vladdy
vladdyOP4y ago
technically uk practically idk
24
244y ago
whatToWithIdenticalCommand
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
vladdy
vladdyOP4y ago
behaviorWhenNotIdentical
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
24
244y ago
I think that works
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
24
244y ago
minus the obviously wrong british spelling (usa strong)
vladdy
vladdyOP4y ago
well I'm not bri'ish so its the us spelling
24
244y ago
well thank god for that
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
24
244y ago
no we don't test here
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
24
244y ago
yeah, no worries here bud (note: not responsible for test deletion)
vladdy
vladdyOP4y ago
current line/total lines
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
24
244y ago
not when you have DI just .get it
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
𝖄𝖚𝖌𝖊𝖓
Plenty broken dreams
vladdy
vladdyOP4y ago
So, people here, other than the feedback you gave me about the 3 things, is there anything else? I wanna know before I work on the implementation
𝖄𝖚𝖌𝖊𝖓
Nah. Just naming (:
vladdy
vladdyOP4y ago
@here waketh up 🙏
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
24
244y ago
no
fried
fried4y ago
im wacthig
vladdy
vladdyOP4y ago
already solved its at the bottom of the notion
RedS
RedS4y ago
mad
24
244y ago
think this system works
vladdy
vladdyOP4y ago
the faster I get feedback, the faster the progress
fried
fried4y ago
its cool do it as it is nopw
24
244y ago
LGTM.
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
vladdy
vladdyOP4y ago
What about them I already explained they handle different things internally eyess
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
vladdy
vladdyOP4y ago
you mean..an..array..of register calls?
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
vladdy
vladdyOP4y ago
is that REALLY needed
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
adrian
adrian4y ago
For
vladdy
vladdyOP4y ago
I say you can DIY it with an array and calling the method
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
adrian
adrian4y ago
That's what I thought
vladdy
vladdyOP4y ago
aight time to get to coding
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
adrian
adrian4y ago
they're options so I would presume they'll be handled as such unaware of actual intentions though
vladdy
vladdyOP4y ago
well right now you get a generic discord.js CommandInteraction/ContextMenuInteraction, so I assume the plugins will update to give a nicer support too
Unknown User
Unknown User4y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server