diff --git a/src/Discord.Net.Interactions/InteractionService.cs b/src/Discord.Net.Interactions/InteractionService.cs
index f57c75a31..793d89cdc 100644
--- a/src/Discord.Net.Interactions/InteractionService.cs
+++ b/src/Discord.Net.Interactions/InteractionService.cs
@@ -426,17 +426,36 @@ namespace Discord.Interactions
/// use . Registering a commands without group names might cause the command traversal to fail.
///
/// The target guild.
+ /// If , this operation will not delete the commands that are missing from .
/// Commands to be registered to Discord.
///
/// A task representing the command registration process. The task result contains the active application commands of the target guild.
///
public async Task> AddCommandsToGuildAsync(IGuild guild, bool deleteMissing = false, params ICommandInfo[] commands)
{
- EnsureClientReady();
-
if (guild is null)
throw new ArgumentNullException(nameof(guild));
+ return await AddCommandsToGuildAsync(guild.Id, deleteMissing, commands).ConfigureAwait(false);
+ }
+
+ ///
+ /// Register Application Commands from to a guild.
+ ///
+ ///
+ /// Commands will be registered as standalone commands, if you want the to take effect,
+ /// use . Registering a commands without group names might cause the command traversal to fail.
+ ///
+ /// The target guild ID.
+ /// If , this operation will not delete the commands that are missing from .
+ /// Commands to be registered to Discord.
+ ///
+ /// A task representing the command registration process. The task result contains the active application commands of the target guild.
+ ///
+ public async Task> AddCommandsToGuildAsync(ulong guildId, bool deleteMissing = false, params ICommandInfo[] commands)
+ {
+ EnsureClientReady();
+
var props = new List();
foreach (var command in commands)
@@ -456,44 +475,60 @@ namespace Discord.Interactions
if (!deleteMissing)
{
- var existing = await RestClient.GetGuildApplicationCommands(guild.Id).ConfigureAwait(false);
+ var existing = await RestClient.GetGuildApplicationCommands(guildId).ConfigureAwait(false);
var missing = existing.Where(x => !props.Any(y => y.Name.IsSpecified && y.Name.Value == x.Name));
props.AddRange(missing.Select(x => x.ToApplicationCommandProps()));
}
- return await RestClient.BulkOverwriteGuildCommands(props.ToArray(), guild.Id).ConfigureAwait(false);
+ return await RestClient.BulkOverwriteGuildCommands(props.ToArray(), guildId).ConfigureAwait(false);
}
///
/// Register Application Commands from modules provided in to a guild.
///
/// The target guild.
+ /// If , this operation will not delete the commands that are missing from .
/// Modules to be registered to Discord.
///
/// A task representing the command registration process. The task result contains the active application commands of the target guild.
///
public async Task> AddModulesToGuildAsync(IGuild guild, bool deleteMissing = false, params ModuleInfo[] modules)
{
- EnsureClientReady();
-
if (guild is null)
throw new ArgumentNullException(nameof(guild));
+ return await AddModulesToGuildAsync(guild.Id, deleteMissing, modules).ConfigureAwait(false);
+ }
+
+ ///
+ /// Register Application Commands from modules provided in to a guild.
+ ///
+ /// The target guild ID.
+ /// If , this operation will not delete the commands that are missing from .
+ /// Modules to be registered to Discord.
+ ///
+ /// A task representing the command registration process. The task result contains the active application commands of the target guild.
+ ///
+ public async Task> AddModulesToGuildAsync(ulong guildId, bool deleteMissing = false, params ModuleInfo[] modules)
+ {
+ EnsureClientReady();
+
var props = modules.SelectMany(x => x.ToApplicationCommandProps(true)).ToList();
if (!deleteMissing)
{
- var existing = await RestClient.GetGuildApplicationCommands(guild.Id).ConfigureAwait(false);
+ var existing = await RestClient.GetGuildApplicationCommands(guildId).ConfigureAwait(false);
var missing = existing.Where(x => !props.Any(y => y.Name.IsSpecified && y.Name.Value == x.Name));
props.AddRange(missing.Select(x => x.ToApplicationCommandProps()));
}
- return await RestClient.BulkOverwriteGuildCommands(props.ToArray(), guild.Id).ConfigureAwait(false);
+ return await RestClient.BulkOverwriteGuildCommands(props.ToArray(), guildId).ConfigureAwait(false);
}
///
/// Register Application Commands from modules provided in as global commands.
///
+ /// If , this operation will not delete the commands that are missing from .
/// Modules to be registered to Discord.
///
/// A task representing the command registration process. The task result contains the active application commands of the target guild.
@@ -521,6 +556,7 @@ namespace Discord.Interactions
/// Commands will be registered as standalone commands, if you want the to take effect,
/// use . Registering a commands without group names might cause the command traversal to fail.
///
+ /// If , this operation will not delete the commands that are missing from .
/// Commands to be registered to Discord.
///
/// A task representing the command registration process. The task result contains the active application commands of the target guild.
@@ -1086,19 +1122,40 @@ namespace Discord.Interactions
///
/// The active command permissions after the modification.
///
- public async Task ModifySlashCommandPermissionsAsync (ModuleInfo module, IGuild guild,
+ public async Task ModifySlashCommandPermissionsAsync(ModuleInfo module, IGuild guild,
params ApplicationCommandPermission[] permissions)
{
+ if (module is null)
+ throw new ArgumentNullException(nameof(module));
+
+ if (guild is null)
+ throw new ArgumentNullException(nameof(guild));
+
+ return await ModifySlashCommandPermissionsAsync(module, guild.Id, permissions).ConfigureAwait(false);
+ }
+
+ ///
+ /// Modify the command permissions of the matching Discord Slash Command.
+ ///
+ /// Module representing the top level Slash Command.
+ /// Target guild ID.
+ /// New permission values.
+ ///
+ /// The active command permissions after the modification.
+ ///
+ public async Task ModifySlashCommandPermissionsAsync(ModuleInfo module, ulong guildId,
+ params ApplicationCommandPermission[] permissions)
+ {
+ if (module is null)
+ throw new ArgumentNullException(nameof(module));
+
if (!module.IsSlashGroup)
throw new InvalidOperationException($"This module does not have a {nameof(GroupAttribute)} and does not represent an Application Command");
if (!module.IsTopLevelGroup)
throw new InvalidOperationException("This module is not a top level application command. You cannot change its permissions");
- if (guild is null)
- throw new ArgumentNullException("guild");
-
- var commands = await RestClient.GetGuildApplicationCommands(guild.Id).ConfigureAwait(false);
+ var commands = await RestClient.GetGuildApplicationCommands(guildId).ConfigureAwait(false);
var appCommand = commands.First(x => x.Name == module.SlashGroupName);
return await appCommand.ModifyCommandPermissions(permissions).ConfigureAwait(false);
@@ -1113,9 +1170,29 @@ namespace Discord.Interactions
///
/// The active command permissions after the modification.
///
- public async Task ModifySlashCommandPermissionsAsync (SlashCommandInfo command, IGuild guild,
- params ApplicationCommandPermission[] permissions) =>
- await ModifyApplicationCommandPermissionsAsync(command, guild, permissions).ConfigureAwait(false);
+ public async Task ModifySlashCommandPermissionsAsync(SlashCommandInfo command, IGuild guild,
+ params ApplicationCommandPermission[] permissions)
+ {
+ if (command is null)
+ throw new ArgumentNullException(nameof(command));
+
+ if (guild is null)
+ throw new ArgumentNullException(nameof(guild));
+
+ return await ModifyApplicationCommandPermissionsAsync(command, guild.Id, permissions).ConfigureAwait(false);
+ }
+
+ ///
+ /// Modify the command permissions of the matching Discord Slash Command.
+ ///
+ /// The Slash Command.
+ /// Target guild ID.
+ /// New permission values.
+ ///
+ /// The active command permissions after the modification.
+ ///
+ public async Task ModifySlashCommandPermissionsAsync(SlashCommandInfo command, ulong guildId,
+ params ApplicationCommandPermission[] permissions) => await ModifyApplicationCommandPermissionsAsync(command, guildId, permissions).ConfigureAwait(false);
///
/// Modify the command permissions of the matching Discord Slash Command.
@@ -1126,20 +1203,40 @@ namespace Discord.Interactions
///
/// The active command permissions after the modification.
///
- public async Task ModifyContextCommandPermissionsAsync (ContextCommandInfo command, IGuild guild,
- params ApplicationCommandPermission[] permissions) =>
- await ModifyApplicationCommandPermissionsAsync(command, guild, permissions).ConfigureAwait(false);
+ public async Task ModifyContextCommandPermissionsAsync(ContextCommandInfo command, IGuild guild,
+ params ApplicationCommandPermission[] permissions)
+ {
+ if (command is null)
+ throw new ArgumentNullException(nameof(command));
+
+ if (guild is null)
+ throw new ArgumentNullException(nameof(guild));
+
+ return await ModifyApplicationCommandPermissionsAsync(command, guild.Id, permissions).ConfigureAwait(false);
+ }
+
+ ///
+ /// Modify the command permissions of the matching Discord Slash Command.
+ ///
+ /// The Context Command.
+ /// Target guild ID.
+ /// New permission values.
+ ///
+ /// The active command permissions after the modification.
+ ///
+ public async Task ModifyContextCommandPermissionsAsync(ContextCommandInfo command, ulong guildId,
+ params ApplicationCommandPermission[] permissions) => await ModifyApplicationCommandPermissionsAsync(command, guildId, permissions).ConfigureAwait(false);
- private async Task ModifyApplicationCommandPermissionsAsync (T command, IGuild guild,
+ private async Task ModifyApplicationCommandPermissionsAsync (T command, ulong guildId,
params ApplicationCommandPermission[] permissions) where T : class, IApplicationCommandInfo, ICommandInfo
{
+ if (command is null)
+ throw new ArgumentNullException(nameof(command));
+
if (!command.IsTopLevelCommand)
throw new InvalidOperationException("This command is not a top level application command. You cannot change its permissions");
- if (guild is null)
- throw new ArgumentNullException("guild");
-
- var commands = await RestClient.GetGuildApplicationCommands(guild.Id).ConfigureAwait(false);
+ var commands = await RestClient.GetGuildApplicationCommands(guildId).ConfigureAwait(false);
var appCommand = commands.First(x => x.Name == ( command as IApplicationCommandInfo ).Name);
return await appCommand.ModifyCommandPermissions(permissions).ConfigureAwait(false);