Merge branch 'wip' of https://github.com/Kwoth/NadekoBot into wip
This commit is contained in:
		@@ -106,11 +106,60 @@ namespace NadekoBot.Modules.Administration
 | 
			
		||||
            [OwnerOnly]
 | 
			
		||||
            public async Task LogEvents()
 | 
			
		||||
            {
 | 
			
		||||
                _service.GuildLogSettings.TryGetValue(Context.Guild.Id, out LogSetting l);
 | 
			
		||||
                var str = string.Join("\n", Enum.GetNames(typeof(LogType))
 | 
			
		||||
                    .Select(x =>
 | 
			
		||||
                    {
 | 
			
		||||
                        var val = l == null ? null : GetLogProperty(l, Enum.Parse<LogType>(x));
 | 
			
		||||
                        if (val != null)
 | 
			
		||||
                            return $"{Format.Bold(x)} <#{val}>";
 | 
			
		||||
                        return Format.Bold(x);
 | 
			
		||||
                    }));
 | 
			
		||||
 | 
			
		||||
                await Context.Channel.SendConfirmAsync(Format.Bold(GetText("log_events")) + "\n" +
 | 
			
		||||
                                                       $"```fix\n{string.Join(", ", Enum.GetNames(typeof(LogType)).Cast<string>())}```")
 | 
			
		||||
                    str)
 | 
			
		||||
                    .ConfigureAwait(false);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            private ulong? GetLogProperty(LogSetting l, LogType type)
 | 
			
		||||
            {
 | 
			
		||||
                switch (type)
 | 
			
		||||
                {
 | 
			
		||||
                    case LogType.Other:
 | 
			
		||||
                        return l.LogOtherId;
 | 
			
		||||
                    case LogType.MessageUpdated:
 | 
			
		||||
                        return l.MessageUpdatedId;
 | 
			
		||||
                    case LogType.MessageDeleted:
 | 
			
		||||
                        return l.MessageDeletedId;
 | 
			
		||||
                    case LogType.UserJoined:
 | 
			
		||||
                        return l.UserJoinedId;
 | 
			
		||||
                    case LogType.UserLeft:
 | 
			
		||||
                        return l.UserLeftId;
 | 
			
		||||
                    case LogType.UserBanned:
 | 
			
		||||
                        return l.UserBannedId;
 | 
			
		||||
                    case LogType.UserUnbanned:
 | 
			
		||||
                        return l.UserUnbannedId;
 | 
			
		||||
                    case LogType.UserUpdated:
 | 
			
		||||
                        return l.UserUpdatedId;
 | 
			
		||||
                    case LogType.ChannelCreated:
 | 
			
		||||
                        return l.ChannelCreatedId;
 | 
			
		||||
                    case LogType.ChannelDestroyed:
 | 
			
		||||
                        return l.ChannelDestroyedId;
 | 
			
		||||
                    case LogType.ChannelUpdated:
 | 
			
		||||
                        return l.ChannelUpdatedId;
 | 
			
		||||
                    case LogType.UserPresence:
 | 
			
		||||
                        return l.LogUserPresenceId;
 | 
			
		||||
                    case LogType.VoicePresence:
 | 
			
		||||
                        return l.LogVoicePresenceId;
 | 
			
		||||
                    case LogType.VoicePresenceTTS:
 | 
			
		||||
                        return l.LogVoicePresenceTTSId;
 | 
			
		||||
                    case LogType.UserMuted:
 | 
			
		||||
                        return l.UserMutedId;
 | 
			
		||||
                    default:
 | 
			
		||||
                        return null;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            [NadekoCommand, Usage, Description, Aliases]
 | 
			
		||||
            [RequireContext(ContextType.Guild)]
 | 
			
		||||
            [RequireUserPermission(GuildPermission.Administrator)]
 | 
			
		||||
 
 | 
			
		||||
@@ -20,14 +20,16 @@ namespace NadekoBot.Modules.Gambling
 | 
			
		||||
            private readonly IImageCache _images;
 | 
			
		||||
            private readonly IBotConfigProvider _bc;
 | 
			
		||||
            private readonly CurrencyService _cs;
 | 
			
		||||
 | 
			
		||||
            private readonly DbService _db;
 | 
			
		||||
            private static readonly NadekoRandom rng = new NadekoRandom();
 | 
			
		||||
 | 
			
		||||
            public FlipCoinCommands(IDataCache data, CurrencyService cs, IBotConfigProvider bc)
 | 
			
		||||
            public FlipCoinCommands(IDataCache data, CurrencyService cs,
 | 
			
		||||
                IBotConfigProvider bc, DbService db)
 | 
			
		||||
            {
 | 
			
		||||
                _images = data.LocalImages;
 | 
			
		||||
                _bc = bc;
 | 
			
		||||
                _cs = cs;
 | 
			
		||||
                _db = db;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            [NadekoCommand, Usage, Description, Aliases]
 | 
			
		||||
@@ -86,7 +88,18 @@ namespace NadekoBot.Modules.Gambling
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            [NadekoCommand, Usage, Description, Aliases]
 | 
			
		||||
            public async Task Betflip(int amount, BetFlipGuess guess)
 | 
			
		||||
            public Task Betflip(Allin _, BetFlipGuess guess)
 | 
			
		||||
            {
 | 
			
		||||
                long cur;
 | 
			
		||||
                using (var uow = _db.UnitOfWork)
 | 
			
		||||
                {
 | 
			
		||||
                    cur = uow.Currency.GetUserCurrency(Context.User.Id);
 | 
			
		||||
                }
 | 
			
		||||
                return Betflip(cur, guess);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            [NadekoCommand, Usage, Description, Aliases]
 | 
			
		||||
            public async Task Betflip(long amount, BetFlipGuess guess)
 | 
			
		||||
            {
 | 
			
		||||
                if (amount < _bc.BotConfig.MinimumBetAmount)
 | 
			
		||||
                {
 | 
			
		||||
 
 | 
			
		||||
@@ -278,9 +278,9 @@ namespace NadekoBot.Modules.Gambling
 | 
			
		||||
        //    });
 | 
			
		||||
        //    return Task.CompletedTask;
 | 
			
		||||
        //}
 | 
			
		||||
        public enum Allin { Allin, All }
 | 
			
		||||
 | 
			
		||||
        [NadekoCommand, Usage, Description, Aliases]
 | 
			
		||||
        public async Task BetRoll(long amount)
 | 
			
		||||
        private async Task InternallBetroll(long amount)
 | 
			
		||||
        {
 | 
			
		||||
            if (amount < 1)
 | 
			
		||||
                return;
 | 
			
		||||
@@ -303,24 +303,39 @@ namespace NadekoBot.Modules.Gambling
 | 
			
		||||
                {
 | 
			
		||||
                    str += GetText("br_win", (amount * _bc.BotConfig.Betroll67Multiplier) + CurrencySign, 66);
 | 
			
		||||
                    await _cs.AddAsync(Context.User, "Betroll Gamble",
 | 
			
		||||
                        (int) (amount * _bc.BotConfig.Betroll67Multiplier), false).ConfigureAwait(false);
 | 
			
		||||
                        (int)(amount * _bc.BotConfig.Betroll67Multiplier), false).ConfigureAwait(false);
 | 
			
		||||
                }
 | 
			
		||||
                else if (rnd < 100)
 | 
			
		||||
                {
 | 
			
		||||
                    str += GetText("br_win", (amount * _bc.BotConfig.Betroll91Multiplier) + CurrencySign, 90);
 | 
			
		||||
                    await _cs.AddAsync(Context.User, "Betroll Gamble",
 | 
			
		||||
                        (int) (amount * _bc.BotConfig.Betroll91Multiplier), false).ConfigureAwait(false);
 | 
			
		||||
                        (int)(amount * _bc.BotConfig.Betroll91Multiplier), false).ConfigureAwait(false);
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    str += GetText("br_win", (amount * _bc.BotConfig.Betroll100Multiplier) + CurrencySign, 99) + " 👑";
 | 
			
		||||
                    await _cs.AddAsync(Context.User, "Betroll Gamble",
 | 
			
		||||
                        (int) (amount * _bc.BotConfig.Betroll100Multiplier), false).ConfigureAwait(false);
 | 
			
		||||
                        (int)(amount * _bc.BotConfig.Betroll100Multiplier), false).ConfigureAwait(false);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            await Context.Channel.SendConfirmAsync(str).ConfigureAwait(false);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [NadekoCommand, Usage, Description, Aliases]
 | 
			
		||||
        public Task BetRoll(long amount)
 | 
			
		||||
            => InternallBetroll(amount);
 | 
			
		||||
 | 
			
		||||
        [NadekoCommand, Usage, Description, Aliases]
 | 
			
		||||
        public Task BetRoll(Allin _)
 | 
			
		||||
        {
 | 
			
		||||
            long cur;
 | 
			
		||||
            using (var uow = _db.UnitOfWork)
 | 
			
		||||
            {
 | 
			
		||||
                cur = uow.Currency.GetUserCurrency(Context.User.Id);
 | 
			
		||||
            }
 | 
			
		||||
            return InternallBetroll(cur);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [NadekoCommand, Usage, Description, Aliases]
 | 
			
		||||
        public async Task Leaderboard(int page = 1)
 | 
			
		||||
        {
 | 
			
		||||
 
 | 
			
		||||
@@ -15,16 +15,31 @@ namespace NadekoBot.Modules.Gambling
 | 
			
		||||
        {
 | 
			
		||||
            private readonly CurrencyService _cs;
 | 
			
		||||
            private readonly IBotConfigProvider _bc;
 | 
			
		||||
            private readonly DbService _db;
 | 
			
		||||
 | 
			
		||||
            public WheelOfFortuneCommands(CurrencyService cs, IBotConfigProvider bc)
 | 
			
		||||
            public WheelOfFortuneCommands(CurrencyService cs, IBotConfigProvider bc,
 | 
			
		||||
                DbService db)
 | 
			
		||||
            {
 | 
			
		||||
                _cs = cs;
 | 
			
		||||
                _bc = bc;
 | 
			
		||||
                _db = db;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            public enum Allin { Allin, All }
 | 
			
		||||
 | 
			
		||||
            [NadekoCommand, Usage, Description, Aliases]
 | 
			
		||||
            public Task WheelOfFortune(Allin _)
 | 
			
		||||
            {
 | 
			
		||||
                long cur;
 | 
			
		||||
                using (var uow = _db.UnitOfWork)
 | 
			
		||||
                {
 | 
			
		||||
                    cur = uow.Currency.GetUserCurrency(Context.User.Id);
 | 
			
		||||
                }
 | 
			
		||||
                return WheelOfFortune(cur);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            [NadekoCommand, Usage, Description, Aliases]
 | 
			
		||||
            [RequireContext(ContextType.Guild)]
 | 
			
		||||
            public async Task WheelOfFortune(int bet)
 | 
			
		||||
            public async Task WheelOfFortune(long bet)
 | 
			
		||||
            {
 | 
			
		||||
                const int minBet = 10;
 | 
			
		||||
                if (bet < minBet)
 | 
			
		||||
 
 | 
			
		||||
@@ -101,6 +101,7 @@ namespace NadekoBot.Modules.Xp
 | 
			
		||||
 | 
			
		||||
        [NadekoCommand, Usage, Description, Aliases]
 | 
			
		||||
        [RequireContext(ContextType.Guild)]
 | 
			
		||||
        [OwnerOnly]
 | 
			
		||||
        public async Task XpCurrencyReward(int level, int amount=0)
 | 
			
		||||
        {
 | 
			
		||||
            if (level < 1 || amount < 0)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user