NadekoBot/NadekoBot.Modules.Gambling/CurrencyEventsCommands.cs

92 lines
3.2 KiB
C#
Raw Normal View History

2017-01-15 14:09:48 +00:00
using Discord;
using Discord.Commands;
using NadekoBot.Extensions;
using NadekoBot.Core.Services;
2017-01-15 14:09:48 +00:00
using System.Threading.Tasks;
2017-01-30 05:26:47 +00:00
using Discord.WebSocket;
2017-07-17 19:42:36 +00:00
using NadekoBot.Common.Attributes;
2017-10-09 22:04:02 +00:00
using NadekoBot.Modules.Gambling.Common;
using NadekoBot.Modules.Gambling.Services;
using NadekoBot.Modules.Gambling.Common.CurrencyEvents;
2017-01-15 14:09:48 +00:00
namespace NadekoBot.Modules.Gambling
{
public partial class Gambling
{
[Group]
2017-10-09 22:04:02 +00:00
public class CurrencyEventsCommands : NadekoSubmodule<CurrencyEventsService>
2017-01-15 14:09:48 +00:00
{
public enum CurrencyEvent
{
Reaction,
2017-01-30 05:26:47 +00:00
SneakyGameStatus
2017-01-15 14:09:48 +00:00
}
2017-01-30 05:26:47 +00:00
private readonly DiscordSocketClient _client;
private readonly IBotConfigProvider _bc;
private readonly CurrencyService _cs;
2017-05-24 20:28:16 +00:00
public CurrencyEventsCommands(DiscordSocketClient client, IBotConfigProvider bc, CurrencyService cs)
2017-05-24 20:28:16 +00:00
{
_client = client;
_bc = bc;
_cs = cs;
2017-05-24 20:28:16 +00:00
}
2017-01-30 05:26:47 +00:00
2017-01-15 14:09:48 +00:00
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
[OwnerOnly]
2017-01-30 05:26:47 +00:00
public async Task StartEvent(CurrencyEvent e, int arg = -1)
2017-01-15 14:09:48 +00:00
{
2017-02-14 13:30:21 +00:00
switch (e)
2017-01-15 14:09:48 +00:00
{
case CurrencyEvent.Reaction:
2017-09-18 07:24:42 +00:00
await ReactionEvent(Context, arg).ConfigureAwait(false);
2017-02-14 13:30:21 +00:00
break;
case CurrencyEvent.SneakyGameStatus:
await SneakyGameStatusEvent(Context, arg).ConfigureAwait(false);
break;
2017-01-15 14:09:48 +00:00
}
}
2017-10-09 22:04:02 +00:00
private async Task SneakyGameStatusEvent(ICommandContext context, int num)
2017-01-30 05:26:47 +00:00
{
2017-10-09 22:04:02 +00:00
if (num < 10 || num > 600)
2017-01-30 05:26:47 +00:00
num = 60;
2017-10-09 22:04:02 +00:00
var ev = new SneakyEvent(_cs, _client, _bc, num);
if (!await _service.StartSneakyEvent(ev, context.Message, context))
2017-01-30 05:26:47 +00:00
return;
try
{
2017-02-15 10:41:32 +00:00
var title = GetText("sneakygamestatus_title");
2017-10-09 22:04:02 +00:00
var desc = GetText("sneakygamestatus_desc",
Format.Bold(100.ToString()) + _bc.BotConfig.CurrencySign,
Format.Bold(num.ToString()));
await context.Channel.SendConfirmAsync(title, desc)
.ConfigureAwait(false);
2017-01-30 05:26:47 +00:00
}
2017-02-14 13:30:21 +00:00
catch
{
// ignored
}
2017-01-30 05:26:47 +00:00
}
2017-01-15 14:09:48 +00:00
2017-09-18 07:24:42 +00:00
public async Task ReactionEvent(ICommandContext context, int amount)
2017-02-15 10:41:32 +00:00
{
if (amount <= 0)
amount = 100;
var title = GetText("reaction_title");
var desc = GetText("reaction_desc", _bc.BotConfig.CurrencySign, Format.Bold(amount.ToString()) + _bc.BotConfig.CurrencySign);
var footer = GetText("reaction_footer", 24);
2017-10-09 22:04:02 +00:00
var re = new ReactionEvent(_bc.BotConfig, _client, _cs, amount);
2017-02-15 10:41:32 +00:00
var msg = await context.Channel.SendConfirmAsync(title,
desc, footer: footer)
.ConfigureAwait(false);
2017-10-09 22:04:02 +00:00
await re.Start(msg, context);
2017-01-15 14:09:48 +00:00
}
}
}
}