Some formats
This commit is contained in:
parent
f18d56e805
commit
068fafeb09
@ -74,7 +74,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
var name = e.GetArg("name");
|
||||
if (!NadekoBot.Config.CustomReactions.ContainsKey(name))
|
||||
{
|
||||
await e.Channel.SendMessage("Could not find given key");
|
||||
await e.Channel.SendMessage("Could not find given commandname");
|
||||
return;
|
||||
}
|
||||
string message = "";
|
||||
|
@ -5,6 +5,7 @@ using Discord.Modules;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Modules.Permissions.Classes;
|
||||
using NadekoBot.Extensions;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace NadekoBot.Modules.CustomReactions
|
||||
{
|
||||
@ -20,19 +21,16 @@ namespace NadekoBot.Modules.CustomReactions
|
||||
|
||||
cgb.AddCheck(PermissionChecker.Instance);
|
||||
Random range = new Random();
|
||||
Dictionary<string, Func<CommandEventArgs, string>> MyFuncs = new Dictionary<string, Func<CommandEventArgs, string>>
|
||||
Dictionary<string, Func<CommandEventArgs, string>> commandFuncs = new Dictionary<string, Func<CommandEventArgs, string>>
|
||||
{
|
||||
{"%rng%", (e) => range.Next().ToString()},
|
||||
{"%mention%", (e) => NadekoBot.BotMention },
|
||||
{"%user%", e => e.User.Mention },
|
||||
{"%target%", e =>
|
||||
{
|
||||
var arg = e.GetArg("args");
|
||||
return string.IsNullOrWhiteSpace(arg) ? "" : arg;
|
||||
} }
|
||||
|
||||
{"%target%", e => e.GetArg("args")?.Trim() ?? "" },
|
||||
};
|
||||
|
||||
|
||||
|
||||
foreach (var command in NadekoBot.Config.CustomReactions)
|
||||
{
|
||||
var commandName = command.Key.Replace("%mention%", NadekoBot.BotMention);
|
||||
@ -43,7 +41,7 @@ namespace NadekoBot.Modules.CustomReactions
|
||||
c.Do(async e =>
|
||||
{
|
||||
string str = command.Value[range.Next(0, command.Value.Count())];
|
||||
MyFuncs.Keys.ForEach(k => str = str.Replace(k, MyFuncs[k](e)));
|
||||
commandFuncs.Keys.ForEach(k => str = str.Replace(k, commandFuncs[k](e)));
|
||||
await e.Channel.SendMessage(str).ConfigureAwait(false);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user