geekbot/Geekbot.net/Commands/Roll.cs

43 lines
1.4 KiB
C#
Raw Normal View History

using System;
using System.Threading.Tasks;
2017-04-12 22:43:52 +02:00
using Discord.Commands;
2017-10-12 16:34:10 +02:00
using Geekbot.net.Lib;
using StackExchange.Redis;
2017-04-12 22:43:52 +02:00
namespace Geekbot.net.Commands
2017-04-12 22:43:52 +02:00
{
public class Roll : ModuleBase
{
private readonly IDatabase redis;
private readonly Random rnd;
2017-09-15 22:56:03 +02:00
public Roll(IDatabase redis, Random RandomClient)
{
this.redis = redis;
2017-09-15 22:56:03 +02:00
rnd = RandomClient;
}
2017-09-15 22:56:03 +02:00
[Command("roll", RunMode = RunMode.Async)]
2017-10-12 16:34:10 +02:00
[Remarks(CommandCategories.Fun)]
[Summary("Guess which number the bot will roll (1-100")]
public async Task RollCommand([Remainder] [Summary("guess")] string stuff = "noGuess")
2017-04-12 22:43:52 +02:00
{
var number = rnd.Next(1, 100);
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!");
redis.HashIncrement($"{Context.Guild.Id}:Rolls", Context.User.Id.ToString());
}
}
else
{
await ReplyAsync(Context.Message.Author.Mention + ", you rolled " + number);
}
2017-04-12 22:43:52 +02:00
}
}
}