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
friedβ€’4y ago
looks great
vladdy
vladdyOPβ€’4y ago
how in the mcfuck did you read that document so fast
fried
friedβ€’4y ago
um bulgarian genetics
RealShadowNova
RealShadowNovaβ€’4y ago
pepeBritish
fried
friedβ€’4y ago
registry cool
fried
friedβ€’4y ago
its like windows actually when i started to read it
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
fried
friedβ€’4y ago
looks pretty good
vladdy
vladdyOPβ€’4y 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 Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
24
24β€’4y ago
overrideBehaviorOnDuplicate maybe?
π–„π–šπ–Œπ–Šπ–“
So The store is a Store? A sapphire pieces store?
fried
friedβ€’4y ago
i like stores
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
vladdy
vladdyOPβ€’4y ago
no the RegistryStore is a store of registries, not a piece Namings ASoof
bitomic
bitomicβ€’4y 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
vladdyOPβ€’4y ago
NAMING ASIDE
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
vladdy
vladdyOPβ€’4y ago
I'll search a better name for the registry store ideally as little as possible
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
Favna
Favnaβ€’4y 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 Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
π–„π–šπ–Œπ–Šπ–“
Released when?
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
vladdy
vladdyOPβ€’4y 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
Favnaβ€’4y 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.
Favna
Favnaβ€’4y ago
nickk please keep the thread serious
vladdy
vladdyOPβ€’4y ago
when most people are happy
fried
friedβ€’4y ago
ok well i dont really understand this registry thing
24
24β€’4y ago
Then don't participate.
fried
friedβ€’4y ago
ok
Favna
Favnaβ€’4y ago
.
fried
friedβ€’4y ago
oh so its like an in depth command
vladdy
vladdyOPβ€’4y ago
Please explain whats confusing about it :D
fried
friedβ€’4y ago
idk long words
Favna
Favnaβ€’4y 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 Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
fried
friedβ€’4y ago
actionWhenCommandIsPresentButNotIdentical thats a really long one
vladdy
vladdyOPβ€’4y ago
Permissions are undergoing changes at Discord's level, so, at this time, no
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
Favna
Favnaβ€’4y ago
Then get a dictionary and disect every word @friedxd. We're not a primary school here.
fried
friedβ€’4y ago
😦
vladdy
vladdyOPβ€’4y ago
well yes and not, they mean different things both for us internally and you externally
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
fried
friedβ€’4y ago
OHHHH this is for like application commands that looks great
vladdy
vladdyOPβ€’4y ago
Highly unlikely to happen due to the fact people may want to, for instance, intl their description sweats know it's annoying
Favna
Favnaβ€’4y ago
then they override it? or they dont set the option? I never said the option should default to true
vladdy
vladdyOPβ€’4y ago
Hmm
Favna
Favnaβ€’4y ago
Default it to false in fact if you want, that's fine by me writing code...
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
24
24β€’4y 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
vladdyOPβ€’4y 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
Favnaβ€’4y 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
vladdyOPβ€’4y ago
how would you provide the registerbehavior Is it a default to overwrite?
Favna
Favnaβ€’4y ago
ninja'd it in
vladdy
vladdyOPβ€’4y ago
log to console?
Favna
Favnaβ€’4y ago
uh didn't you write in the notion the default is warn rn?
vladdy
vladdyOPβ€’4y ago
Well yes trying to see if I missed anyone else's message sweats
RedS
RedSβ€’4y ago
pogey
vladdy
vladdyOPβ€’4y 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
bitomicβ€’4y 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
vladdyOPβ€’4y 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
bitomicβ€’4y ago
something like this could be great, from my opinion
vladdy
vladdyOPβ€’4y ago
pepeHands of that, are there any questions, suggestions, requests, issues, broken dreams?
24
24β€’4y 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
vladdyOPβ€’4y ago
Well I wanna get it right the first time
24
24β€’4y 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
bitomicβ€’4y ago
"CommandThingy", "StoringThingy", "UnnamedThing2" (?)
vladdy
vladdyOPβ€’4y ago
Yean names are elongatedbois rn its pain How does whenCommandIsPresentButNotIdentical sound? @Favna @daimond113 @twenty_four
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
24
24β€’4y ago
better... commandOverrideStrategy?
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
24
24β€’4y ago
I see it being vague... override what??
vladdy
vladdyOPβ€’4y ago
override is vague
24
24β€’4y ago
commandAmbiguityStrategy
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
24
24β€’4y ago
2 characters longer than mind... smh
vladdy
vladdyOPβ€’4y ago
ifCommandPresentButNotIdentical
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
24
24β€’4y ago
ifCommandPresentNotIdentical no buts here boys
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
24
24β€’4y ago
whatToDoOnCommandMatch
vladdy
vladdyOPβ€’4y ago
whenPresentButNotIdentical
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
vladdy
vladdyOPβ€’4y ago
technically uk practically idk
24
24β€’4y ago
whatToWithIdenticalCommand
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
vladdy
vladdyOPβ€’4y ago
behaviorWhenNotIdentical
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
24
24β€’4y ago
I think that works
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
24
24β€’4y ago
minus the obviously wrong british spelling (usa strong)
vladdy
vladdyOPβ€’4y ago
well I'm not bri'ish so its the us spelling
24
24β€’4y ago
well thank god for that
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
24
24β€’4y ago
no we don't test here
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
24
24β€’4y ago
yeah, no worries here bud (note: not responsible for test deletion)
vladdy
vladdyOPβ€’4y ago
current line/total lines
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
24
24β€’4y ago
not when you have DI just .get it
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
π–„π–šπ–Œπ–Šπ–“
Plenty broken dreams
vladdy
vladdyOPβ€’4y 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
vladdyOPβ€’4y ago
@here waketh up πŸ™
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
24
24β€’4y ago
no
fried
friedβ€’4y ago
im wacthig
vladdy
vladdyOPβ€’4y ago
already solved its at the bottom of the notion
RedS
RedSβ€’4y ago
mad
24
24β€’4y ago
think this system works
vladdy
vladdyOPβ€’4y ago
the faster I get feedback, the faster the progress
fried
friedβ€’4y ago
its cool do it as it is nopw
24
24β€’4y ago
LGTM.
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
vladdy
vladdyOPβ€’4y ago
What about them I already explained they handle different things internally eyess
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
vladdy
vladdyOPβ€’4y ago
you mean..an..array..of register calls?
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
vladdy
vladdyOPβ€’4y ago
is that REALLY needed
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
vladdy
vladdyOPβ€’4y ago
I say you can DIY it with an array and calling the method
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
μ‹ κΈ°ν•˜λ‹€
That's what I thought
vladdy
vladdyOPβ€’4y ago
aight time to get to coding
Unknown User
Unknown Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
μ‹ κΈ°ν•˜λ‹€
they're options so I would presume they'll be handled as such unaware of actual intentions though
vladdy
vladdyOPβ€’4y 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 Userβ€’4y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server