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");
|
var name = e.GetArg("name");
|
||||||
if (!NadekoBot.Config.CustomReactions.ContainsKey(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;
|
return;
|
||||||
}
|
}
|
||||||
string message = "";
|
string message = "";
|
||||||
|
@ -5,6 +5,7 @@ using Discord.Modules;
|
|||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using NadekoBot.Modules.Permissions.Classes;
|
using NadekoBot.Modules.Permissions.Classes;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.CustomReactions
|
namespace NadekoBot.Modules.CustomReactions
|
||||||
{
|
{
|
||||||
@ -20,19 +21,16 @@ namespace NadekoBot.Modules.CustomReactions
|
|||||||
|
|
||||||
cgb.AddCheck(PermissionChecker.Instance);
|
cgb.AddCheck(PermissionChecker.Instance);
|
||||||
Random range = new Random();
|
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()},
|
{"%rng%", (e) => range.Next().ToString()},
|
||||||
{"%mention%", (e) => NadekoBot.BotMention },
|
{"%mention%", (e) => NadekoBot.BotMention },
|
||||||
{"%user%", e => e.User.Mention },
|
{"%user%", e => e.User.Mention },
|
||||||
{"%target%", e =>
|
{"%target%", e => e.GetArg("args")?.Trim() ?? "" },
|
||||||
{
|
|
||||||
var arg = e.GetArg("args");
|
|
||||||
return string.IsNullOrWhiteSpace(arg) ? "" : arg;
|
|
||||||
} }
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach (var command in NadekoBot.Config.CustomReactions)
|
foreach (var command in NadekoBot.Config.CustomReactions)
|
||||||
{
|
{
|
||||||
var commandName = command.Key.Replace("%mention%", NadekoBot.BotMention);
|
var commandName = command.Key.Replace("%mention%", NadekoBot.BotMention);
|
||||||
@ -43,7 +41,7 @@ namespace NadekoBot.Modules.CustomReactions
|
|||||||
c.Do(async e =>
|
c.Do(async e =>
|
||||||
{
|
{
|
||||||
string str = command.Value[range.Next(0, command.Value.Count())];
|
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);
|
await e.Channel.SendMessage(str).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user