diff --git a/.nuget/NuGet.config b/.nuget/NuGet.config
index 4a4e2f52b4..f672dcab53 100644
--- a/.nuget/NuGet.config
+++ b/.nuget/NuGet.config
@@ -1,11 +1,12 @@
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/Directory.Build.props b/Directory.Build.props
index 63fb1b5f0e..f38df2a939 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -1,10 +1,11 @@
+
-
-
-
+
+
+
- true
+ true
diff --git a/DisCatSharp.ApplicationCommands/ApplicationCommandsExtension.cs b/DisCatSharp.ApplicationCommands/ApplicationCommandsExtension.cs
index 8b36f5e5a3..750b2af07a 100644
--- a/DisCatSharp.ApplicationCommands/ApplicationCommandsExtension.cs
+++ b/DisCatSharp.ApplicationCommands/ApplicationCommandsExtension.cs
@@ -88,7 +88,8 @@ public sealed class ApplicationCommandsExtension : BaseExtension
public IReadOnlyList>> RegisteredCommands
=> s_registeredCommands.Select(guild =>
new KeyValuePair>(guild.Key, guild.Value
- .Select(parent => new RegisteredDiscordApplicationCommand(parent)).ToList())).ToList();
+ .Select(parent => new RegisteredDiscordApplicationCommand(parent)).ToList())).ToList();
+
private static List>> s_registeredCommands = new();
///
@@ -96,6 +97,7 @@ public sealed class ApplicationCommandsExtension : BaseExtension
///
public IReadOnlyList GlobalCommands
=> GlobalCommandsInternal;
+
internal static List GlobalCommandsInternal = new();
///
@@ -103,6 +105,7 @@ public IReadOnlyList GlobalCommands
///
public IReadOnlyDictionary> GuildCommands
=> GuildCommandsInternal;
+
internal static Dictionary> GuildCommandsInternal = new();
///
@@ -150,7 +153,6 @@ internal static LogLevel ApplicationCommandsLogLevel
///
internal bool StartupFinished { get; set; } = false;
-
///
/// Gets the service provider this module was configured with.
///
@@ -168,7 +170,7 @@ public IServiceProvider Services
/// The configuration.
internal ApplicationCommandsExtension(ApplicationCommandsConfiguration configuration = null)
{
- configuration ??= new ApplicationCommandsConfiguration();
+ configuration ??= new();
Configuration = configuration;
DebugEnabled = configuration?.DebugStartup ?? false;
CheckAllGuilds = configuration?.CheckAllGuilds ?? false;
@@ -189,14 +191,14 @@ protected internal override void Setup(DiscordClient client)
this.Client = client;
Logger = client.Logger;
- this._slashError = new AsyncEvent("SLASHCOMMAND_ERRORED", TimeSpan.Zero, null);
- this._slashExecuted = new AsyncEvent("SLASHCOMMAND_EXECUTED", TimeSpan.Zero, null);
- this._contextMenuErrored = new AsyncEvent("CONTEXTMENU_ERRORED", TimeSpan.Zero, null);
- this._contextMenuExecuted = new AsyncEvent("CONTEXTMENU_EXECUTED", TimeSpan.Zero, null);
- this._applicationCommandsModuleReady = new AsyncEvent("APPLICATION_COMMANDS_MODULE_READY", TimeSpan.Zero, null);
- this._applicationCommandsModuleStartupFinished = new AsyncEvent("APPLICATION_COMMANDS_MODULE_STARTUP_FINISHED", TimeSpan.Zero, null);
- this._globalApplicationCommandsRegistered = new AsyncEvent("GLOBAL_COMMANDS_REGISTERED", TimeSpan.Zero, null);
- this._guildApplicationCommandsRegistered = new AsyncEvent("GUILD_COMMANDS_REGISTERED", TimeSpan.Zero, null);
+ this._slashError = new("SLASHCOMMAND_ERRORED", TimeSpan.Zero, null);
+ this._slashExecuted = new("SLASHCOMMAND_EXECUTED", TimeSpan.Zero, null);
+ this._contextMenuErrored = new("CONTEXTMENU_ERRORED", TimeSpan.Zero, null);
+ this._contextMenuExecuted = new("CONTEXTMENU_EXECUTED", TimeSpan.Zero, null);
+ this._applicationCommandsModuleReady = new("APPLICATION_COMMANDS_MODULE_READY", TimeSpan.Zero, null);
+ this._applicationCommandsModuleStartupFinished = new("APPLICATION_COMMANDS_MODULE_STARTUP_FINISHED", TimeSpan.Zero, null);
+ this._globalApplicationCommandsRegistered = new("GLOBAL_COMMANDS_REGISTERED", TimeSpan.Zero, null);
+ this._guildApplicationCommandsRegistered = new("GUILD_COMMANDS_REGISTERED", TimeSpan.Zero, null);
this.Client.GuildDownloadCompleted += (c, e) =>
{
@@ -233,6 +235,7 @@ private void FinishedRegistration()
this.Client.InteractionCreated += this.InteractionHandler;
this.Client.ContextMenuInteractionCreated += this.ContextMenuHandler;
}
+
///
/// Cleans the module for a new start of the bot.
/// DO NOT USE IF YOU DON'T KNOW WHAT IT DOES.
@@ -309,7 +312,7 @@ public void RegisterGlobalCommands(Assembly assembly)
/// The guild id to register it on.
/// A callback to setup translations with.
public void RegisterGuildCommands(ulong guildId, Action translationSetup = null) where T : ApplicationCommandsModule
- => this._updateList.Add(new KeyValuePair(guildId, new ApplicationCommandsModuleConfiguration(typeof(T), translationSetup)));
+ => this._updateList.Add(new(guildId, new(typeof(T), translationSetup)));
///
/// Registers a command class with optional translation setup for a guild.
@@ -321,7 +324,8 @@ public void RegisterGuildCommands(Type type, ulong guildId, Action(guildId, new ApplicationCommandsModuleConfiguration(type, translationSetup)));
+
+ this._updateList.Add(new(guildId, new(type, translationSetup)));
}
///
@@ -330,7 +334,7 @@ public void RegisterGuildCommands(Type type, ulong guildId, ActionThe command class to register.
/// A callback to setup translations with.
public void RegisterGlobalCommands(Action translationSetup = null) where T : ApplicationCommandsModule
- => this._updateList.Add(new KeyValuePair(null, new ApplicationCommandsModuleConfiguration(typeof(T), translationSetup)));
+ => this._updateList.Add(new(null, new(typeof(T), translationSetup)));
///
/// Registers a command class with optional translation setup globally.
@@ -341,7 +345,8 @@ public void RegisterGlobalCommands(Type type, Action(null, new ApplicationCommandsModuleConfiguration(type, translationSetup)));
+
+ this._updateList.Add(new(null, new(type, translationSetup)));
}
///
@@ -352,6 +357,7 @@ public event AsyncEventHandler this._applicationCommandsModuleReady.Register(value);
remove => this._applicationCommandsModuleReady.Unregister(value);
}
+
private AsyncEvent _applicationCommandsModuleReady;
///
@@ -362,8 +368,8 @@ public event AsyncEventHandler this._applicationCommandsModuleStartupFinished.Register(value);
remove => this._applicationCommandsModuleStartupFinished.Unregister(value);
}
- private AsyncEvent _applicationCommandsModuleStartupFinished;
+ private AsyncEvent _applicationCommandsModuleStartupFinished;
///
/// Fired when guild commands are registered on a guild.
@@ -373,6 +379,7 @@ public event AsyncEventHandler this._guildApplicationCommandsRegistered.Register(value);
remove => this._guildApplicationCommandsRegistered.Unregister(value);
}
+
private AsyncEvent _guildApplicationCommandsRegistered;
///
@@ -383,6 +390,7 @@ public event AsyncEventHandler this._globalApplicationCommandsRegistered.Register(value);
remove => this._globalApplicationCommandsRegistered.Unregister(value);
}
+
private AsyncEvent _globalApplicationCommandsRegistered;
///
@@ -446,15 +454,16 @@ internal async Task UpdateAsync()
//Default should be to add the help and slash commands can be added without setting any configuration
//so this should still add the default help
- if (Configuration is null || (Configuration is not null && Configuration.EnableDefaultHelp))
+ if (Configuration is null || Configuration is not null && Configuration.EnableDefaultHelp)
{
- updateList.Add(new KeyValuePair
- (null, new ApplicationCommandsModuleConfiguration(typeof(DefaultHelpModule))));
+ updateList.Add(new(null, new(typeof(DefaultHelpModule))));
commandsPending = updateList.Select(x => x.Key).Distinct().ToList();
- } else {
- try {
- updateList.Remove(new KeyValuePair
- (null, new ApplicationCommandsModuleConfiguration(typeof(DefaultHelpModule))));
+ }
+ else
+ {
+ try
+ {
+ updateList.Remove(new(null, new(typeof(DefaultHelpModule))));
}
catch
{ }
@@ -473,12 +482,13 @@ internal async Task UpdateAsync()
this.Client.Logger.Log(ApplicationCommandsLogLevel, "Found guild {guild} in shard {shard}!", key.Value, this.Client.ShardId);
this.Client.Logger.Log(ApplicationCommandsLogLevel, "Registering");
}
+
await this.RegisterCommands(updateList.Where(x => x.Key == key).Select(x => x.Value).ToList(), key).ConfigureAwait(false);
}
this._missingScopeGuildIds = new(failedGuilds);
- await this._applicationCommandsModuleReady.InvokeAsync(this, new ApplicationCommandsModuleReadyEventArgs(Configuration?.ServiceProvider)
+ await this._applicationCommandsModuleReady.InvokeAsync(this, new(Configuration?.ServiceProvider)
{
GuildsWithoutScope = failedGuilds
}).ConfigureAwait(false);
@@ -519,9 +529,7 @@ private async Task RegisterCommands(List
//Add module to classes list if it's a group
var extremeNestedGroup = false;
if (module.GetCustomAttribute() != null)
- {
classes.Add(module);
- }
else if (module.GetMembers(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static).Any(x => x.IsDefined(typeof(SlashCommandGroupAttribute))))
{
//Otherwise add the extreme nested groups
@@ -531,19 +539,15 @@ private async Task RegisterCommands(List
extremeNestedGroup = true;
}
else
- {
//Otherwise add the nested groups
classes = module.DeclaredNestedTypes.Where(x => x.GetCustomAttribute() != null).ToList();
- }
if (module.GetCustomAttribute() != null || extremeNestedGroup)
{
List groupTranslations = null;
if (!string.IsNullOrEmpty(ctx.GroupTranslations))
- {
groupTranslations = JsonConvert.DeserializeObject>(ctx.GroupTranslations);
- }
var slashGroupsTuple = await NestedCommandWorker.ParseSlashGroupsAsync(type, classes, guildId, groupTranslations).ConfigureAwait(false);
@@ -555,7 +559,6 @@ private async Task RegisterCommands(List
var cgwsgs = new List();
var cgs2 = new List();
foreach (var cmd in slashGroupsTuple.applicationCommands)
- {
if (cmd.Type == ApplicationCommandType.ChatInput)
{
var cgs = new List();
@@ -563,28 +566,24 @@ private async Task RegisterCommands(List
{
var cs = new List();
foreach (var sc in scg.Options)
- {
if (sc.Options == null || !sc.Options.Any())
- cs.Add(new Command(sc.Name, sc.Description, null, null));
+ cs.Add(new(sc.Name, sc.Description, null, null));
else
- cs.Add(new Command(sc.Name, sc.Description, sc.Options.ToList(), null));
- }
- cgs.Add(new CommandGroup(scg.Name, scg.Description, cs, null));
+ cs.Add(new(sc.Name, sc.Description, sc.Options.ToList(), null));
+ cgs.Add(new(scg.Name, scg.Description, cs, null));
}
- cgwsgs.Add(new CommandGroupWithSubGroups(cmd.Name, cmd.Description, cgs, ApplicationCommandType.ChatInput));
+
+ cgwsgs.Add(new(cmd.Name, cmd.Description, cgs, ApplicationCommandType.ChatInput));
var cs2 = new List();
foreach (var sc2 in cmd.Options.Where(x => x.Type == ApplicationCommandOptionType.SubCommand))
- {
if (sc2.Options == null || !sc2.Options.Any())
- cs2.Add(new Command(sc2.Name, sc2.Description, null, null));
+ cs2.Add(new(sc2.Name, sc2.Description, null, null));
else
- cs2.Add(new Command(sc2.Name, sc2.Description, sc2.Options.ToList(), null));
- }
- cgs2.Add(new CommandGroup(cmd.Name, cmd.Description, cs2, ApplicationCommandType.ChatInput));
-
+ cs2.Add(new(sc2.Name, sc2.Description, sc2.Options.ToList(), null));
+ cgs2.Add(new(cmd.Name, cmd.Description, cs2, ApplicationCommandType.ChatInput));
}
- }
+
if (cgwsgs.Any())
foreach (var cgwsg in cgwsgs)
groupTranslation.Add(JsonConvert.DeserializeObject(JsonConvert.SerializeObject(cgwsg)));
@@ -613,9 +612,7 @@ private async Task RegisterCommands(List
List commandTranslations = null;
if (!string.IsNullOrEmpty(ctx.SingleTranslations))
- {
commandTranslations = JsonConvert.DeserializeObject>(ctx.SingleTranslations);
- }
//Slash commands
var methods = module.DeclaredMethods.Where(x => x.GetCustomAttribute() != null);
@@ -632,10 +629,11 @@ private async Task RegisterCommands(List
if (cmd.Type == ApplicationCommandType.ChatInput && (cmd.Options == null || !cmd.Options.Any(x => x.Type == ApplicationCommandOptionType.SubCommand || x.Type == ApplicationCommandOptionType.SubCommandGroup)))
{
if (cmd.Options == null || !cmd.Options.Any())
- cs.Add(new Command(cmd.Name, cmd.Description, null, ApplicationCommandType.ChatInput));
+ cs.Add(new(cmd.Name, cmd.Description, null, ApplicationCommandType.ChatInput));
else
- cs.Add(new Command(cmd.Name, cmd.Description, cmd.Options.ToList(), ApplicationCommandType.ChatInput));
+ cs.Add(new(cmd.Name, cmd.Description, cmd.Options.ToList(), ApplicationCommandType.ChatInput));
}
+
if (cs.Any())
foreach (var c in cs)
translation.Add(JsonConvert.DeserializeObject(JsonConvert.SerializeObject(c)));
@@ -661,7 +659,7 @@ private async Task RegisterCommands(List
var cs = new List();
foreach (var cmd in contextCommands.applicationCommands)
if (cmd.Type == ApplicationCommandType.Message || cmd.Type == ApplicationCommandType.User)
- cs.Add(new Command(cmd.Name, null, null, cmd.Type));
+ cs.Add(new(cmd.Name, null, null, cmd.Type));
if (cs.Any())
foreach (var c in cs)
translation.Add(JsonConvert.DeserializeObject(JsonConvert.SerializeObject(c)));
@@ -686,9 +684,7 @@ private async Task RegisterCommands(List
catch (Exception ex)
{
if (ex is BadRequestException brex)
- {
this.Client.Logger.LogCritical(brex, @"There was an error registering application commands: {res}", brex.WebResponse.Response);
- }
else
{
if (ex.InnerException is not null && ex.InnerException is BadRequestException brex1)
@@ -696,9 +692,11 @@ private async Task RegisterCommands(List
else
this.Client.Logger.LogCritical(ex, @"There was an error parsing the application commands");
}
+
s_errored = true;
}
}
+
if (!s_errored)
{
updateList = updateList.DistinctBy(x => x.Name).ToList();
@@ -708,7 +706,6 @@ private async Task RegisterCommands(List
this.CheckRegistrationStartup(ManOr, translation, groupTranslation);
}
else
- {
try
{
List commands = new();
@@ -725,9 +722,7 @@ private async Task RegisterCommands(List
GlobalCommandsInternal.AddRange(actualCommands);
}
else
- {
foreach (var cmd in GlobalDiscordCommands)
- {
try
{
await this.Client.DeleteGlobalApplicationCommandAsync(cmd.Id).ConfigureAwait(false);
@@ -736,8 +731,6 @@ private async Task RegisterCommands(List
{
this.Client.Logger.Log(ApplicationCommandsLogLevel, "Could not delete global command {cmdId}. Please clean up manually", cmd.Id);
}
- }
- }
}
else
{
@@ -756,9 +749,7 @@ private async Task RegisterCommands(List
{ }
}
else
- {
foreach (var cmd in GuildDiscordCommands.First(x => x.Key == guildId.Value).Value)
- {
try
{
await this.Client.DeleteGuildApplicationCommandAsync(guildId.Value, cmd.Id).ConfigureAwait(false);
@@ -767,8 +758,6 @@ private async Task RegisterCommands(List
{
this.Client.Logger.Log(ApplicationCommandsLogLevel, "Could not delete guild command {cmdId} in guild {guildId}. Please clean up manually", cmd.Id, guildId.Value);
}
- }
- }
}
}
catch (UnauthorizedException ex)
@@ -776,6 +765,7 @@ private async Task RegisterCommands(List
this.Client.Logger.LogError("Could not register application commands for guild {guildId}.\nError: {exc}", guildId, ex.JsonMessage);
return;
}
+
//Creates a guild command if a guild id is specified, otherwise global
//Checks against the ids and adds them to the command method lists
foreach (var command in commands)
@@ -796,7 +786,7 @@ private async Task RegisterCommands(List
SubGroupCommands.AddRange(subGroupCommands.DistinctBy(x => x.Name));
ContextMenuCommands.AddRange(contextMenuCommands.DistinctBy(x => x.Name));
- s_registeredCommands.Add(new KeyValuePair>(guildId, commands.ToList()));
+ s_registeredCommands.Add(new(guildId, commands.ToList()));
foreach (var command in commandMethods)
{
@@ -806,22 +796,15 @@ private async Task RegisterCommands(List
this.Client.Logger.Log(ApplicationCommandsLogLevel, "Expected Count: {exp}\nCurrent Count: {cur}", s_expectedCount, s_registrationCount);
if (guildId.HasValue)
- {
- await this._guildApplicationCommandsRegistered.InvokeAsync(this, new GuildApplicationCommandsRegisteredEventArgs(Configuration?.ServiceProvider)
+ await this._guildApplicationCommandsRegistered.InvokeAsync(this, new(Configuration?.ServiceProvider)
{
- Handled = true,
- GuildId = guildId.Value,
- RegisteredCommands = GuildCommandsInternal.Any(c => c.Key == guildId.Value) ? GuildCommandsInternal.FirstOrDefault(c => c.Key == guildId.Value).Value : null
+ Handled = true, GuildId = guildId.Value, RegisteredCommands = GuildCommandsInternal.Any(c => c.Key == guildId.Value) ? GuildCommandsInternal.FirstOrDefault(c => c.Key == guildId.Value).Value : null
}).ConfigureAwait(false);
- }
else
- {
- await this._globalApplicationCommandsRegistered.InvokeAsync(this, new GlobalApplicationCommandsRegisteredEventArgs(Configuration?.ServiceProvider)
+ await this._globalApplicationCommandsRegistered.InvokeAsync(this, new(Configuration?.ServiceProvider)
{
- Handled = true,
- RegisteredCommands = GlobalCommandsInternal
+ Handled = true, RegisteredCommands = GlobalCommandsInternal
}).ConfigureAwait(false);
- }
s_registrationCount++;
this.CheckRegistrationStartup(ManOr);
@@ -833,9 +816,7 @@ private async Task RegisterCommands(List
catch (Exception ex)
{
if (ex is BadRequestException brex)
- {
this.Client.Logger.LogCritical(brex, @"There was an error registering application commands: {res}", brex.WebResponse.Response);
- }
else
{
if (ex.InnerException is not null && ex.InnerException is BadRequestException brex1)
@@ -843,9 +824,9 @@ private async Task RegisterCommands(List
else
this.Client.Logger.LogCritical(ex, @"There was an general error registering application commands");
}
+
s_errored = true;
}
- }
}
}
@@ -855,12 +836,9 @@ private async void CheckRegistrationStartup(bool man = false, List
{
@@ -1028,11 +1005,17 @@ private Task InteractionHandler(DiscordClient client, InteractionCreateEventArgs
}
}
- await this._slashExecuted.InvokeAsync(this, new SlashCommandExecutedEventArgs(this.Client.ServiceProvider) { Context = context }).ConfigureAwait(false);
+ await this._slashExecuted.InvokeAsync(this, new(this.Client.ServiceProvider)
+ {
+ Context = context
+ }).ConfigureAwait(false);
}
catch (Exception ex)
{
- await this._slashError.InvokeAsync(this, new SlashCommandErrorEventArgs(this.Client.ServiceProvider) { Context = context, Exception = ex }).ConfigureAwait(false);
+ await this._slashError.InvokeAsync(this, new(this.Client.ServiceProvider)
+ {
+ Context = context, Exception = ex
+ }).ConfigureAwait(false);
this.Client.Logger.LogError(ex, "Error in slash interaction");
}
@@ -1082,7 +1065,10 @@ private Task InteractionHandler(DiscordClient client, InteractionCreateEventArgs
EntitlementSkuIds = e.Interaction.EntitlementSkuIds
};
- var choices = await ((Task>) providerMethod.Invoke(providerInstance, new[] { context })).ConfigureAwait(false);
+ var choices = await ((Task>)providerMethod.Invoke(providerInstance, new[]
+ {
+ context
+ })).ConfigureAwait(false);
await e.Interaction.CreateResponseAsync(InteractionResponseType.AutoCompleteResult, new DiscordInteractionResponseBuilder().AddAutoCompleteChoices(choices)).ConfigureAwait(false);
}
@@ -1115,7 +1101,10 @@ private Task InteractionHandler(DiscordClient client, InteractionCreateEventArgs
EntitlementSkuIds = e.Interaction.EntitlementSkuIds
};
- var choices = await ((Task>) providerMethod.Invoke(providerInstance, new[] { context })).ConfigureAwait(false);
+ var choices = await ((Task>)providerMethod.Invoke(providerInstance, new[]
+ {
+ context
+ })).ConfigureAwait(false);
await e.Interaction.CreateResponseAsync(InteractionResponseType.AutoCompleteResult, new DiscordInteractionResponseBuilder().AddAutoCompleteChoices(choices)).ConfigureAwait(false);
}
@@ -1149,7 +1138,10 @@ private Task InteractionHandler(DiscordClient client, InteractionCreateEventArgs
EntitlementSkuIds = e.Interaction.EntitlementSkuIds
};
- var choices = await ((Task>) providerMethod.Invoke(providerInstance, new[] { context })).ConfigureAwait(false);
+ var choices = await ((Task>)providerMethod.Invoke(providerInstance, new[]
+ {
+ context
+ })).ConfigureAwait(false);
await e.Interaction.CreateResponseAsync(InteractionResponseType.AutoCompleteResult, new DiscordInteractionResponseBuilder().AddAutoCompleteChoices(choices)).ConfigureAwait(false);
}
}
@@ -1171,9 +1163,10 @@ private ApplicationCommandFinalType GetInteractionType(DiscordInteractionData da
if (data.Options == null!)
return ApplicationCommandFinalType.Command;
if (data.Options.All(x =>
- x.Type is not ApplicationCommandOptionType.SubCommand
- and not ApplicationCommandOptionType.SubCommandGroup))
+ x.Type is not ApplicationCommandOptionType.SubCommand
+ and not ApplicationCommandOptionType.SubCommandGroup))
return ApplicationCommandFinalType.Command;
+
if (data.Options.Any(x => x.Type is ApplicationCommandOptionType.SubCommandGroup))
type = ApplicationCommandFinalType.SubCommandGroup;
else if (data.Options.Any(x => x.Type is ApplicationCommandOptionType.SubCommand))
@@ -1239,13 +1232,22 @@ private Task ContextMenuHandler(DiscordClient client, ContextMenuInteractionCrea
throw new InvalidOperationException("A context menu command was executed, but no command was registered for it.");
}
- await this.RunCommandAsync(context, method.Method, new[] { context }).ConfigureAwait(false);
+ await this.RunCommandAsync(context, method.Method, new[]
+ {
+ context
+ }).ConfigureAwait(false);
- await this._contextMenuExecuted.InvokeAsync(this, new ContextMenuExecutedEventArgs(this.Client.ServiceProvider) { Context = context }).ConfigureAwait(false);
+ await this._contextMenuExecuted.InvokeAsync(this, new(this.Client.ServiceProvider)
+ {
+ Context = context
+ }).ConfigureAwait(false);
}
catch (Exception ex)
{
- await this._contextMenuErrored.InvokeAsync(this, new ContextMenuErrorEventArgs(this.Client.ServiceProvider) { Context = context, Exception = ex }).ConfigureAwait(false);
+ await this._contextMenuErrored.InvokeAsync(this, new(this.Client.ServiceProvider)
+ {
+ Context = context, Exception = ex
+ }).ConfigureAwait(false);
}
});
@@ -1284,7 +1286,7 @@ internal async Task RunCommandAsync(BaseContext context, MethodInfo method, IEnu
break;
default:
- throw new Exception($"An unknown {nameof(ApplicationCommandModuleLifespanAttribute)} scope was specified on command {context.CommandName}");
+ throw new($"An unknown {nameof(ApplicationCommandModuleLifespanAttribute)} scope was specified on command {context.CommandName}");
}
ApplicationCommandsModule module = null;
@@ -1307,6 +1309,7 @@ internal async Task RunCommandAsync(BaseContext context, MethodInfo method, IEnu
await (module?.AfterSlashExecutionAsync(slashContext) ?? Task.CompletedTask).ConfigureAwait(false);
}
}
+
// Context menus
if (context is ContextMenuContext contextMenuContext)
{
@@ -1394,11 +1397,13 @@ internal static object CreateInstance(Type t, IServiceProvider services)
/// The options.
private async Task> ResolveInteractionCommandParameters(InteractionCreateEventArgs e, InteractionContext context, MethodInfo method, IEnumerable options)
{
- var args = new List