.say command added. Requires manage messages permission
This commit is contained in:
		| @@ -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) | ||||
|         { | ||||
|   | ||||
| @@ -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" | ||||
|     ] | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user