diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index 0738414a..1b978535 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -20,6 +20,8 @@ using NadekoBot.Common; using NadekoBot.Common.Attributes; using NadekoBot.Modules.Searches.Common; using NadekoBot.Modules.Searches.Services; +using NadekoBot.Common.Replacements; +using Discord.WebSocket; namespace NadekoBot.Modules.Searches { @@ -34,6 +36,40 @@ namespace NadekoBot.Modules.Searches _google = google; } + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + [RequireUserPermission(GuildPermission.ManageMessages)] + public async Task Say([Remainder]string message) + { + if (string.IsNullOrWhiteSpace(message)) + return; + + var rep = new ReplacementBuilder() + .WithDefault(Context.User, Context.Channel, Context.Guild, (DiscordSocketClient)Context.Client) + .Build(); + + if (CREmbed.TryParse(message, out var embedData)) + { + rep.Replace(embedData); + try + { + await Context.Channel.EmbedAsync(embedData.ToEmbed(), embedData.PlainText?.SanitizeMentions() ?? "").ConfigureAwait(false); + } + catch (Exception ex) + { + _log.Warn(ex); + } + } + else + { + var msg = rep.Replace(message); + if (!string.IsNullOrWhiteSpace(msg)) + { + await Context.Channel.SendConfirmAsync(msg).ConfigureAwait(false); + } + } + } + [NadekoCommand, Usage, Description, Aliases] public async Task Weather([Remainder] string query) { diff --git a/src/NadekoBot/data/command_strings.json b/src/NadekoBot/data/command_strings.json index 6f84d9a0..915af258 100644 --- a/src/NadekoBot/data/command_strings.json +++ b/src/NadekoBot/data/command_strings.json @@ -2995,5 +2995,12 @@ "usage": [ "{0}ecr 123 I'm a magical girl" ] + }, + "say": { + "cmd": "say", + "desc": "Bot will send the message you typed in this channel. Supports embeds.", + "usage": [ + "{0}say hi" + ] } } \ No newline at end of file