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