From efadbe9a21472473d02af60905ebc47482ffe30c Mon Sep 17 00:00:00 2001 From: runebaas Date: Fri, 19 Jan 2018 23:46:11 +0100 Subject: [PATCH] Add slap counter --- Geekbot.net/Commands/Slap.cs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/Geekbot.net/Commands/Slap.cs b/Geekbot.net/Commands/Slap.cs index 570ddda..134752c 100644 --- a/Geekbot.net/Commands/Slap.cs +++ b/Geekbot.net/Commands/Slap.cs @@ -4,17 +4,21 @@ using System.Threading.Tasks; using Discord; using Discord.Commands; using Geekbot.net.Lib; +using StackExchange.Redis; + namespace Geekbot.net.Commands { public class Slap : ModuleBase { private readonly IErrorHandler _errorHandler; private readonly Random _random; + private readonly IDatabase _redis; - public Slap(IErrorHandler errorHandler, Random random) + public Slap(IErrorHandler errorHandler, Random random, IDatabase redis) { _errorHandler = errorHandler; _random = random; + _redis = redis; } [Command("slap", RunMode = RunMode.Async)] @@ -24,10 +28,16 @@ namespace Geekbot.net.Commands { try { + if (user.Id == Context.User.Id) + { + await ReplyAsync("Why would you slap yourself?"); + return; + } + var things = new List() { "thing", - "rubber duck", + "rubber chicken", "leek stick", "large trout", "flat hand", @@ -42,8 +52,15 @@ namespace Geekbot.net.Commands "monstertruck", "dirty toilet brush", "sleeping seagull", - "sunflower" + "sunflower", + "mousepad", + "lolipop", + "bottle of rum" }; + + _redis.HashIncrement($"{Context.Guild.Id}:SlapsRecieved", user.Id.ToString()); + _redis.HashIncrement($"{Context.Guild.Id}:SlapsGiven", Context.User.Id.ToString()); + await ReplyAsync($"{Context.User.Username} slapped {user.Username} with a {things[_random.Next(things.Count - 1)]}"); } catch (Exception e)