Allow bulk overwriting application commands
Summary
Implemented method for bulk overwriting application commands and added a couple more builders in the context of interactions to facilitate that. The ApplicationCommandBuilder is a bit awkward because I didn't want to make any breaking changes to the existing interface of Bot#register_application_command and Bot#edit_application_command.
Added
Interactions::ApplicationCommandBuilder- needed something to encapsulate all data contained in an application command to facilitate the creation of theApplicationCommandSetBuilder(see below).Interactions::ApplicationCommandSetBuilder- builder that exposes simple DSL to define multiple application commands within a single blockBot#bulk_overwrite_application_commands- public method that allows... well... bulk overwriting application commands. Works as shown in the YARD example.
bot.bulk_overwrite_application_commands(server_id: ENV["TEST_SERVER_ID"]) do |app|
app.command(:ping, "Pong!")
app.command(:echo, "Echo some text") do |cmd|
cmd.string(:text, "Text to echo")
end
end
Changed
API::Application.create_global_commandAPI::Application.edit_global_commandAPI::Application.create_guild_commandAPI::Application.edit_guild_command
All 4 of the above have been updated to take a hash of command parameters instead of separate arguments.
{
name: :test,
description: "some command",
options: [],
default_permission: true,
type: 1
}
This could pose problems with .create_global_command and .create_guild_command as the name and description for those are no longer techincally required. Suggestions on handling this are welcome.
I think this looks good for the most part but I'm not a fan of removing the parameters in favor of a single hash for the API level methods. That's a blocker for getting this merged. If we can get that reverted and some eyes from another contributor on this we should be good to go
I know it's been a while since you've touched this (my apologies), I'm more than happy to make some changes myself to push this through if you've moved on from the feature 🙂
@swarley yeah it has been a minute 😅 I no longer need this myself but I don't mind looking into it again and making the changes. See what I can do tomorrow 😃
@swarley I've updated the PR to not touch existing code outside of a small fix and documentation.
Been cleaning up my PRs. This is too old and probably no longer relevant. Closing.