Dad jokes are nice

This commit is contained in:
Deukhoofd 2018-06-09 13:35:26 +02:00
parent ed7e22cfed
commit b0d55bf77e
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
1 changed files with 30 additions and 0 deletions

View File

@ -24,6 +24,7 @@ namespace DeukBot4.MessageHandlers
HandlePrivateMessage(message);
ImageBackupHandler.Backup(message);
DeltaHandler(message);
DadJokeHandler(message);
#pragma warning restore 4014
}
catch (Exception e)
@ -75,5 +76,34 @@ namespace DeukBot4.MessageHandlers
}
}
private static async Task DadJokeHandler(SocketMessage message)
{
if (!(message.Author is IGuildUser guildUser))
return;
string newName;
var lower = message.Content.ToLowerInvariant();
if (lower.StartsWith("i'm "))
{
newName = message.Content.Remove(0, 4);
}
else if (lower.StartsWith("im "))
{
newName = message.Content.Remove(0, 3);
}
else if (lower.StartsWith("i am "))
{
newName = message.Content.Remove(0, 5);
}
else
{
return;
}
await message.Channel.SendMessageAsync($"Hi {newName}, i'm Deukbot");
await guildUser.ModifyAsync(user => user.Nickname = newName);
}
}
}