Fix regex for dadjoke
This commit is contained in:
parent
8ecace27b3
commit
7ef36732c3
|
@ -10,7 +10,7 @@ namespace DeukBot4.MessageHandlers.JokeHandling
|
||||||
public string Id => "dad";
|
public string Id => "dad";
|
||||||
public string Name => "Hi I'm dad";
|
public string Name => "Hi I'm dad";
|
||||||
|
|
||||||
private readonly Regex _regex = new Regex(@".*i['| a]*m ([\w\s]{3,15})$",
|
private readonly Regex _regex = new Regex(@".*i('| a)m (?<word>[\w\s]{3,15})$",
|
||||||
RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
||||||
|
|
||||||
public async Task Run(SocketMessage message)
|
public async Task Run(SocketMessage message)
|
||||||
|
@ -21,7 +21,7 @@ namespace DeukBot4.MessageHandlers.JokeHandling
|
||||||
var match = _regex.Match(content);
|
var match = _regex.Match(content);
|
||||||
if (match.Success)
|
if (match.Success)
|
||||||
{
|
{
|
||||||
var newName = match.Groups[1].Value;
|
var newName = match.Groups["word"].Value;
|
||||||
await message.Channel.SendMessageAsync($"Hi {newName}, i'm Deukbot");
|
await message.Channel.SendMessageAsync($"Hi {newName}, i'm Deukbot");
|
||||||
await guildUser.ModifyAsync(user => user.Nickname = newName);
|
await guildUser.ModifyAsync(user => user.Nickname = newName);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue