diff --git a/Marco/Commands/MacroCommand.cs b/Marco/Commands/MacroCommand.cs index 01d2551..02db2fa 100644 --- a/Marco/Commands/MacroCommand.cs +++ b/Marco/Commands/MacroCommand.cs @@ -1,4 +1,5 @@ -using DSharpPlus.SlashCommands; +using DSharpPlus.Entities; +using DSharpPlus.SlashCommands; using DSharpPlus.SlashCommands.Attributes; using Marco.AutocompleteProviders; using Marco.Data; @@ -22,7 +23,8 @@ public MacroCommand(MacroService macroService) [SlashCommand("macro", "Executes a macro.")] [SlashRequireGuild] public async Task MacroAsync(InteractionContext context, - [Option("macro", "The name of the macro.", true)] [Autocomplete(typeof(MacroAutocompleteProvider))] string macroName) + [Option("macro", "The name of the macro.", true)] [Autocomplete(typeof(MacroAutocompleteProvider))] + string macroName) { if (!_macroService.TryGetMacro(context.Guild, macroName, out Macro? macro)) { @@ -36,6 +38,16 @@ public async Task MacroAsync(InteractionContext context, return; } - await context.CreateResponseAsync(macro.Response).ConfigureAwait(false); + var builder = new DiscordInteractionResponseBuilder(); + string response = macro.Response; + + if (response.StartsWith("@silent ")) + { + response = response[8..]; + builder.SuppressNotifications(); + } + + builder.WithContent(response); + await context.CreateResponseAsync(builder).ConfigureAwait(false); } } diff --git a/Marco/Services/MacroListeningService.cs b/Marco/Services/MacroListeningService.cs index 974dbee..f37f6bb 100644 --- a/Marco/Services/MacroListeningService.cs +++ b/Marco/Services/MacroListeningService.cs @@ -124,7 +124,18 @@ private async Task OnMessageCreated(DiscordClient sender, MessageCreateEventArgs guild, user = (DiscordMember) e.Message.Author });*/ - await channel.SendMessageAsync(macro.Response).ConfigureAwait(false); + + var builder = new DiscordMessageBuilder(); + string response = macro.Response; + + if (response.StartsWith("@silent ")) + { + response = response[8..]; + builder.SuppressNotifications(); + } + + builder.WithContent(response); + await channel.SendMessageAsync(builder).ConfigureAwait(false); } } else