Add slap counter
This commit is contained in:
parent
fdb38192fe
commit
efadbe9a21
1 changed files with 20 additions and 3 deletions
|
@ -4,17 +4,21 @@ using System.Threading.Tasks;
|
||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Geekbot.net.Lib;
|
using Geekbot.net.Lib;
|
||||||
|
using StackExchange.Redis;
|
||||||
|
|
||||||
namespace Geekbot.net.Commands
|
namespace Geekbot.net.Commands
|
||||||
{
|
{
|
||||||
public class Slap : ModuleBase
|
public class Slap : ModuleBase
|
||||||
{
|
{
|
||||||
private readonly IErrorHandler _errorHandler;
|
private readonly IErrorHandler _errorHandler;
|
||||||
private readonly Random _random;
|
private readonly Random _random;
|
||||||
|
private readonly IDatabase _redis;
|
||||||
|
|
||||||
public Slap(IErrorHandler errorHandler, Random random)
|
public Slap(IErrorHandler errorHandler, Random random, IDatabase redis)
|
||||||
{
|
{
|
||||||
_errorHandler = errorHandler;
|
_errorHandler = errorHandler;
|
||||||
_random = random;
|
_random = random;
|
||||||
|
_redis = redis;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Command("slap", RunMode = RunMode.Async)]
|
[Command("slap", RunMode = RunMode.Async)]
|
||||||
|
@ -24,10 +28,16 @@ namespace Geekbot.net.Commands
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (user.Id == Context.User.Id)
|
||||||
|
{
|
||||||
|
await ReplyAsync("Why would you slap yourself?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var things = new List<string>()
|
var things = new List<string>()
|
||||||
{
|
{
|
||||||
"thing",
|
"thing",
|
||||||
"rubber duck",
|
"rubber chicken",
|
||||||
"leek stick",
|
"leek stick",
|
||||||
"large trout",
|
"large trout",
|
||||||
"flat hand",
|
"flat hand",
|
||||||
|
@ -42,8 +52,15 @@ namespace Geekbot.net.Commands
|
||||||
"monstertruck",
|
"monstertruck",
|
||||||
"dirty toilet brush",
|
"dirty toilet brush",
|
||||||
"sleeping seagull",
|
"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)]}");
|
await ReplyAsync($"{Context.User.Username} slapped {user.Username} with a {things[_random.Next(things.Count - 1)]}");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
Loading…
Reference in a new issue