geekbot/Geekbot.net/Commands/Slap.cs

70 lines
2.3 KiB
C#
Raw Normal View History

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;
2018-01-19 23:46:11 +01:00
private readonly IDatabase _redis;
2018-01-18 22:51:29 +01:00
public Slap(IErrorHandler errorHandler, IDatabase redis)
2018-01-18 22:51:29 +01:00
{
_errorHandler = errorHandler;
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());
await ReplyAsync($"{Context.User.Username} slapped {user.Username} with a {things[new Random().Next(things.Count - 1)]}");
2018-01-18 22:51:29 +01:00
}
catch (Exception e)
{
_errorHandler.HandleCommandException(e, Context);
}
}
}
}