Remora/Remora.Discord

Add options to configure DiscordService to check slash command support and optionally update slash commands.

AraHaan opened this issue · 0 comments

Description

Currently the DiscordService lacks code that when configured to run would check for slash command support and also (if enabled) update the slash commands.

Why This is Needed

Currently in order to do this, one must:

  • Implement their own copy of DiscordService that checks this (register their own service and skip registering DiscordService).

Alternatives Considered

Currently I have not considered any other alternative other than not using DiscordService, which for me and others means more code we have to maintain vs using one from Remora.Discord.

Additional Details

I have experimented with adding this and it seems it can be done (with logging and printing to console (print and log on error)) with only a single additional reference to Remora.Discord.Commands.

A preview on what the changes might look like:

// file header here.

using Remora.Rest.Core;

// namespace here.

/// <summary>
/// Defines a set of options used by the background gateway service.
/// </summary>
/// <param name="TerminateApplicationOnCriticalGatewayErrors">
/// Whether the service should stop the application if a critical gateway error is encountered.
/// </param>
-public record DiscordServiceOptions(bool TerminateApplicationOnCriticalGatewayErrors = true);
+/// <param name="CheckSlashCommandsSupport">
+/// Whether the service should check if slash commands are supported.
+/// </param>
+/// <param name="UpdateSlashCommands">
+/// Whether the service should update slash commands automatically.
+/// </param>
+/// <param name="UpdateSlashGuild">
+/// The guild that the service should update slash commands for.
+/// When null, it updates global commands.
+/// </param>
+public record DiscordServiceOptions(
+    bool TerminateApplicationOnCriticalGatewayErrors = true,
+    bool CheckSlashCommandsSupport = false,
+    bool UpdateSlashCommands = false,
+    Snowflake? UpdateSlashGuild = null);

// changes to DiscordService not shown.