Ben855 - How are most of y'all using IDhints in pr...

How are most of y'all using IDhints in production? Are you just manually hard coding them every time you decided to add a command or is there a better option?
29 Replies
Photon
Photon2y ago
That’s what I do too, hardcode it 😦
Ben
Ben2y ago
oof
Photon
Photon2y ago
There’s no way to inject it somehow too which is hard sometime
Ben
Ben2y ago
wdym buy that? If I have a map or something that was setup before the bot is constructed, wouldn't I be able to set the IDhint to map.get('some other id that I use in places')?
Photon
Photon2y ago
Yeah you gotta override a lot of things then, when the registry calls start
Ben
Ben2y ago
Why would that be the case though? If the hint resolves before the registry even exists why would that matter.
Photon
Photon2y ago
If you resolve the hint before the registry exists then in that case you will have to hardcode the Id again Because you won’t like to make the API call twice One from sapphires side and one from yours side to get the command ids
Ben
Ben2y ago
I'm not following you. Why would the API get called before the client is instantiated?
Photon
Photon2y ago
When the Ids aren’t hardcoded and you want to resolve it dynamically Else it will be justi what it’s now
Ben
Ben2y ago
Right but I'm not resolving it from the API. I'm planning to resolve them from my database before the client is instantiated.
Photon
Photon2y ago
Then you can just make a custom command class and inject the id from there I think
Ben
Ben2y ago
ooh thats a good idea. If its injected in the command constructor that will be before any registry calls are made right?
Photon
Photon2y ago
Yeah, I do that to register the command using decorator. Pretty quick setup, you can see the implementation here https://github.com/r-priyam/goblin/blob/main/src/lib/extensions/GoblinCommand.ts
Ben
Ben2y ago
I've already got a custom command class set up for some global permissions and global subcommand stuff. I can probably add the id hint resolution there as long as the constructor runs to completion before any registry api calls are made.
Photon
Photon2y ago
I use it to register the command for myself so that I don’t have to call an extra method lol
Ben
Ben2y ago
Yeah that probably would work. I'll give it a shot I guess.
Photon
Photon2y ago
Cool
Sawako
Sawako2y ago
I use environment blobsapphiredark
Ben
Ben2y ago
One environment var for every command? Thats a lot of environment variables.
Sawako
Sawako2y ago
well, not in my case because I use group of subcommands And well, in the case of individual commands, well, that would be enough if you have enough commands, but this way you can update the id hints without having to change your code
Ben
Ben2y ago
Yeah thats gonna be a hard pass.
Sawako
Sawako2y ago
pepeThink
Ben
Ben2y ago
I marked as a solution mostly to make Answer Overflow happy and because thats what I'm currently attempting to do. I'm still very much open to any ideas though. Okay heres my final solution for anyone wondering. About a minute and a half after my bot starts, I save all command IDs (not discord snowflakes, just identifiers I have for each command that wont change even if the name changes) and their interaction IDs into my database. This way any new commands are always saved after they are created. Before bot startup, I populate a map with that information from the DB and make it accessible on container. I then can use that map when registering commands to get any idHints for that specific command. So far this has worked pretty well in testing.
Sawako
Sawako2y ago
Or use env vars It seems to me a very complex system for that
Ben
Ben2y ago
almost 40 commands remember
Sawako
Sawako2y ago
Well in my opinion I don't see the problem of having several environment pepeHmm
Ben
Ben2y ago
and more to be added on later. This way I dont have to start my bot in prod, get the id once its registered, add it to my env vars, and then restart my bot to have it actually take affect. Its a whole lot of manual work in what I currently have as a completely automated build and deployment process. Having a lot is only a minor issue to me tbh. Its more that I want something automatic since everything else about my deployments doesnt require any manual intervention other than a single commit.
Sawako
Sawako2y ago
Remember that the ids do not change, that is, it is something that you will only do once And you don't need to restart your bot to see the new ids, you can use apps (https://slash-commands-gui.androz2091.fr/) to manage your slash commands and see their ids Then put it in the environment variables and that's it.
Ben
Ben2y ago
* once every time I slashify a command or add a new one. So thats already almost 40 times with more to come in the future. It might not be a ton of effort but its more than my new no effort setup. Now I just never have to worry about it. They should always just work™️ on startup.