2018-01-18 22:51:29 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Discord;
|
|
|
|
|
using Discord.Commands;
|
|
|
|
|
using Geekbot.net.Lib;
|
2018-01-19 23:46:11 +01:00
|
|
|
|
using StackExchange.Redis;
|
|
|
|
|
|
2018-01-18 22:51:29 +01:00
|
|
|
|
namespace Geekbot.net.Commands
|
|
|
|
|
{
|
|
|
|
|
public class Slap : ModuleBase
|
|
|
|
|
{
|
|
|
|
|
private readonly IErrorHandler _errorHandler;
|
|
|
|
|
private readonly Random _random;
|
2018-01-19 23:46:11 +01:00
|
|
|
|
private readonly IDatabase _redis;
|
2018-01-18 22:51:29 +01:00
|
|
|
|
|
2018-01-19 23:46:11 +01:00
|
|
|
|
public Slap(IErrorHandler errorHandler, Random random, IDatabase redis)
|
2018-01-18 22:51:29 +01:00
|
|
|
|
{
|
|
|
|
|
_errorHandler = errorHandler;
|
|
|
|
|
_random = random;
|
2018-01-19 23:46:11 +01:00
|
|
|
|
_redis = redis;
|
2018-01-18 22:51:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Command("slap", RunMode = RunMode.Async)]
|
|
|
|
|
[Remarks(CommandCategories.Fun)]
|
|
|
|
|
[Summary("slap someone")]
|
|
|
|
|
public async Task Slapper([Summary("@user")] IUser user)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2018-01-19 23:46:11 +01:00
|
|
|
|
if (user.Id == Context.User.Id)
|
|
|
|
|
{
|
|
|
|
|
await ReplyAsync("Why would you slap yourself?");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-18 22:51:29 +01:00
|
|
|
|
var things = new List<string>()
|
|
|
|
|
{
|
|
|
|
|
"thing",
|
2018-01-19 23:46:11 +01:00
|
|
|
|
"rubber chicken",
|
2018-01-18 22:51:29 +01:00
|
|
|
|
"leek stick",
|
|
|
|
|
"large trout",
|
|
|
|
|
"flat hand",
|
|
|
|
|
"strip of bacon",
|
|
|
|
|
"feather",
|
2018-01-18 23:40:38 +01:00
|
|
|
|
"piece of pizza",
|
|
|
|
|
"moldy banana",
|
|
|
|
|
"sharp retort",
|
|
|
|
|
"printed version of wikipedia",
|
|
|
|
|
"panda paw",
|
|
|
|
|
"spiked sledgehammer",
|
|
|
|
|
"monstertruck",
|
|
|
|
|
"dirty toilet brush",
|
|
|
|
|
"sleeping seagull",
|
2018-01-19 23:46:11 +01:00
|
|
|
|
"sunflower",
|
|
|
|
|
"mousepad",
|
|
|
|
|
"lolipop",
|
|
|
|
|
"bottle of rum"
|
2018-01-18 22:51:29 +01:00
|
|
|
|
};
|
2018-01-19 23:46:11 +01:00
|
|
|
|
|
|
|
|
|
_redis.HashIncrement($"{Context.Guild.Id}:SlapsRecieved", user.Id.ToString());
|
|
|
|
|
_redis.HashIncrement($"{Context.Guild.Id}:SlapsGiven", Context.User.Id.ToString());
|
|
|
|
|
|
2018-01-18 22:51:29 +01:00
|
|
|
|
await ReplyAsync($"{Context.User.Username} slapped {user.Username} with a {things[_random.Next(things.Count - 1)]}");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
_errorHandler.HandleCommandException(e, Context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|