mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 09:18:27 -04:00
- Removed GuildConfigs repository, moved to extensions - Moved StreamSettings extension to GuildConfig extensions - namespace NadekoBot.Core has been simplified to NadekoBot in many places (more to come) - Replaced some raw delete queries with simple linqtodb queries
61 lines
2.5 KiB
C#
61 lines
2.5 KiB
C#
using NadekoBot.Common.Attributes;
|
|
using NadekoBot.Modules.Gambling.Services;
|
|
using System.Threading.Tasks;
|
|
using Discord;
|
|
using NadekoBot.Extensions;
|
|
using System.Linq;
|
|
using Discord.Commands;
|
|
using NadekoBot.Modules.Gambling.Common;
|
|
using NadekoBot.Core.Common;
|
|
|
|
namespace NadekoBot.Modules.Gambling
|
|
{
|
|
public partial class Gambling
|
|
{
|
|
public class CurrencyRaffleCommands : GamblingSubmodule<CurrencyRaffleService>
|
|
{
|
|
public enum Mixed { Mixed }
|
|
|
|
public CurrencyRaffleCommands(GamblingConfigService gamblingConfService) : base(gamblingConfService)
|
|
{
|
|
}
|
|
|
|
[NadekoCommand, Usage, Description, Aliases]
|
|
[RequireContext(ContextType.Guild)]
|
|
[Priority(0)]
|
|
public Task RaffleCur(Mixed _, ShmartNumber amount) =>
|
|
RaffleCur(amount, true);
|
|
|
|
[NadekoCommand, Usage, Description, Aliases]
|
|
[RequireContext(ContextType.Guild)]
|
|
[Priority(1)]
|
|
public async Task RaffleCur(ShmartNumber amount, bool mixed = false)
|
|
{
|
|
if (!await CheckBetMandatory(amount).ConfigureAwait(false))
|
|
return;
|
|
async Task OnEnded(IUser arg, long won)
|
|
{
|
|
await ctx.Channel.SendConfirmAsync(GetText("rafflecur_ended", CurrencyName, Format.Bold(arg.ToString()), won + CurrencySign)).ConfigureAwait(false);
|
|
}
|
|
var res = await _service.JoinOrCreateGame(ctx.Channel.Id,
|
|
ctx.User, amount, mixed, OnEnded)
|
|
.ConfigureAwait(false);
|
|
|
|
if (res.Item1 != null)
|
|
{
|
|
await ctx.Channel.SendConfirmAsync(GetText("rafflecur", res.Item1.GameType.ToString()),
|
|
string.Join("\n", res.Item1.Users.Select(x => $"{x.DiscordUser} ({x.Amount})")),
|
|
footer: GetText("rafflecur_joined", ctx.User.ToString())).ConfigureAwait(false);
|
|
}
|
|
else
|
|
{
|
|
if (res.Item2 == CurrencyRaffleService.JoinErrorType.AlreadyJoinedOrInvalidAmount)
|
|
await ReplyErrorLocalizedAsync("rafflecur_already_joined").ConfigureAwait(false);
|
|
else if (res.Item2 == CurrencyRaffleService.JoinErrorType.NotEnoughCurrency)
|
|
await ReplyErrorLocalizedAsync("not_enough", CurrencySign).ConfigureAwait(false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|