2017-04-25 17:27:11 +02:00
|
|
|
|
using System.Threading.Tasks;
|
2017-04-12 22:43:52 +02:00
|
|
|
|
using Discord.Commands;
|
2017-04-22 23:41:15 +02:00
|
|
|
|
using Geekbot.net.Lib;
|
2017-04-25 17:27:11 +02:00
|
|
|
|
using Geekbot.net.Lib.IClients;
|
2017-04-12 22:43:52 +02:00
|
|
|
|
|
|
|
|
|
namespace Geekbot.net.Modules
|
|
|
|
|
{
|
|
|
|
|
public class Roll : ModuleBase
|
|
|
|
|
{
|
2017-04-22 23:41:15 +02:00
|
|
|
|
private readonly IRedisClient redis;
|
2017-04-25 17:27:11 +02:00
|
|
|
|
private readonly IRandomClient rnd;
|
|
|
|
|
public Roll(IRedisClient redisClient, IRandomClient randomClient)
|
2017-04-22 23:41:15 +02:00
|
|
|
|
{
|
|
|
|
|
redis = redisClient;
|
2017-04-25 17:27:11 +02:00
|
|
|
|
rnd = randomClient;
|
2017-04-22 23:41:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-25 20:59:38 +02:00
|
|
|
|
[Command("roll", RunMode = RunMode.Async), Summary("Roll a number between 1 and 100.")]
|
2017-04-17 23:58:43 +02:00
|
|
|
|
public async Task RollCommand([Remainder, Summary("stuff...")] string stuff = "nothing")
|
2017-04-12 22:43:52 +02:00
|
|
|
|
{
|
2017-04-25 17:27:11 +02:00
|
|
|
|
var number = rnd.Client.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-04-22 23:41:15 +02:00
|
|
|
|
var key = $"{Context.Guild.Id}-{Context.User.Id}-correctRolls";
|
|
|
|
|
var messages = (int)redis.Client.StringGet(key);
|
|
|
|
|
redis.Client.StringSet(key, (messages + 1).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
|
|
|
|
}
|
|
|
|
|
|
2017-04-25 20:59:38 +02:00
|
|
|
|
[Command("dice", RunMode = RunMode.Async), Summary("Roll a dice")]
|
2017-04-17 16:58:48 +02:00
|
|
|
|
public async Task DiceCommand([Summary("The highest number on the dice")] int max = 6)
|
2017-04-12 22:43:52 +02:00
|
|
|
|
{
|
2017-04-25 17:27:11 +02:00
|
|
|
|
var number = rnd.Client.Next(1, max);
|
2017-04-12 22:43:52 +02:00
|
|
|
|
await ReplyAsync(Context.Message.Author.Mention + ", you rolled " + number);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|