.say command added. Requires manage messages permission
This commit is contained in:
parent
94fb819232
commit
99a2c46038
@ -20,6 +20,8 @@ using NadekoBot.Common;
|
|||||||
using NadekoBot.Common.Attributes;
|
using NadekoBot.Common.Attributes;
|
||||||
using NadekoBot.Modules.Searches.Common;
|
using NadekoBot.Modules.Searches.Common;
|
||||||
using NadekoBot.Modules.Searches.Services;
|
using NadekoBot.Modules.Searches.Services;
|
||||||
|
using NadekoBot.Common.Replacements;
|
||||||
|
using Discord.WebSocket;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Searches
|
namespace NadekoBot.Modules.Searches
|
||||||
{
|
{
|
||||||
@ -34,6 +36,40 @@ namespace NadekoBot.Modules.Searches
|
|||||||
_google = google;
|
_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]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
public async Task Weather([Remainder] string query)
|
public async Task Weather([Remainder] string query)
|
||||||
{
|
{
|
||||||
|
@ -2995,5 +2995,12 @@
|
|||||||
"usage": [
|
"usage": [
|
||||||
"{0}ecr 123 I'm a magical girl"
|
"{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"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user