2017-09-14 22:11:19 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
2017-04-12 22:43:52 +02:00
|
|
|
|
using Discord.Commands;
|
2017-09-14 22:11:19 +02:00
|
|
|
|
using StackExchange.Redis;
|
2017-04-12 22:43:52 +02:00
|
|
|
|
|
2017-10-02 21:57:48 +02:00
|
|
|
|
namespace Geekbot.net.Commands
|
2017-04-12 22:43:52 +02:00
|
|
|
|
{
|
|
|
|
|
public class Roll : ModuleBase
|
|
|
|
|
{
|
2017-09-14 22:11:19 +02:00
|
|
|
|
private readonly IDatabase redis;
|
|
|
|
|
private readonly Random rnd;
|
2017-09-15 22:56:03 +02:00
|
|
|
|
|
2017-09-14 22:11:19 +02:00
|
|
|
|
public Roll(IDatabase redis, Random RandomClient)
|
2017-04-22 23:41:15 +02:00
|
|
|
|
{
|
2017-09-14 22:11:19 +02:00
|
|
|
|
this.redis = redis;
|
2017-09-15 22:56:03 +02:00
|
|
|
|
rnd = RandomClient;
|
2017-04-22 23:41:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-15 22:56:03 +02:00
|
|
|
|
[Command("roll", RunMode = RunMode.Async)]
|
|
|
|
|
[Summary("Roll a number between 1 and 100.")]
|
|
|
|
|
public async Task RollCommand([Remainder] [Summary("stuff...")] string stuff = "nothing")
|
2017-04-12 22:43:52 +02:00
|
|
|
|
{
|
2017-09-14 22:11:19 +02:00
|
|
|
|
var number = rnd.Next(1, 100);
|
2017-04-17 23:58:43 +02:00
|
|
|
|
var guess = 1000;
|
|
|
|
|
int.TryParse(stuff, out guess);
|
|
|
|
|
if (guess <= 100 && guess > 0)
|
|
|
|
|
{
|
|
|
|
|
await ReplyAsync($"{Context.Message.Author.Mention} you rolled {number}, your guess was {guess}");
|
|
|
|
|
if (guess == number)
|
|
|
|
|
{
|
|
|
|
|
await ReplyAsync($"Congratulations {Context.User.Username}, your guess was correct!");
|
2017-09-27 22:48:09 +02:00
|
|
|
|
redis.HashIncrement($"{Context.Guild.Id}:Rolls", Context.User.Id.ToString());
|
2017-04-17 23:58:43 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
await ReplyAsync(Context.Message.Author.Mention + ", you rolled " + number);
|
|
|
|
|
}
|
2017-04-12 22:43:52 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|