Esempio n. 1
0
        public async Task AddToGang([Summary("SLAM EM BOYS")][Remainder] string gangName)
        {
            var gang = await _gangRepo.GetGangAsync(gangName, Context.Guild.Id);

            if (gang.Members.Length == 4)
            {
                ReplyError("This gang is already full!");
            }

            var leader = await(Context.Guild as IGuild).GetUserAsync(gang.LeaderId);

            if (leader != null)
            {
                var leaderDM = await leader.CreateDMChannelAsync();

                var key = Config.RAND.Next();
                await leaderDM.SendAsync($"{Context.User} has requested to join your gang. Please respond with \"{key}\" within 5 minutes to add this user to your gang.");

                await ReplyAsync($"The leader of {gang.Name} has been informed of your request to join their gang.");

                var answer = await _interactiveService.WaitForMessage(leaderDM, x => x.Content == key.ToString(), TimeSpan.FromMinutes(5));

                if (answer != null)
                {
                    if (await _gangRepo.InGangAsync(Context.GUser))
                    {
                        await leaderDM.SendAsync("This user has already joined a different gang.");
                    }
                    else if ((await _gangRepo.GetGangAsync(leader)).Members.Length == 4)
                    {
                        await leaderDM.SendAsync("Your gang is already full.");
                    }
                    else
                    {
                        await _gangRepo.AddMemberAsync(gang, Context.User.Id);

                        await leaderDM.SendAsync($"You have successfully added {Context.User} as a member of your gang.");

                        await Context.User.Id.DMAsync(Context.Client, $"Congrats! {leader} has accepted your request to join {gang.Name}!");
                    }
                }
            }
            else
            {
                await ReplyAsync("The leader of that gang is no longer in this server. ***RIP GANG ROFL***");
            }
        }
Esempio n. 2
0
        public async Task InitializeAsync()
        {
            DbUser = await _userRepo.GetUserAsync(GUser);

            DbGuild = await _guildRepo.GetGuildAsync(Guild.Id);

            Gang = await _gangRepo.GetGangAsync(GUser);

            Prefix = DbGuild.Prefix;
            Cash   = DbUser.Cash;
        }
Esempio n. 3
0
        public override async Task <PreconditionResult> CheckPermissions(ICommandContext context, CommandInfo command, IServiceProvider serviceProvider)
        {
            _serviceProvider   = serviceProvider;
            _credentials       = _serviceProvider.GetService <Credentials>();
            _userRepo          = _serviceProvider.GetService <UserRepository>();
            _moderationService = serviceProvider.GetService <ModerationService>();
            _guildRepo         = _serviceProvider.GetService <GuildRepository>();
            _gangRepo          = _serviceProvider.GetService <GangRepository>();

            var guildUser = context.User as IGuildUser;
            var DbUser    = await _userRepo.GetUserAsync(guildUser);

            var DbGuild = await _guildRepo.GetGuildAsync(context.Guild.Id);

            foreach (var attribute in _attributes)
            {
                switch (attribute)
                {
                case Attributes.BotOwner:
                    if (!_credentials.OwnerIds.Any(x => x == context.User.Id))
                    {
                        return(PreconditionResult.FromError("Only an owner of this bot may use this command."));
                    }

                    break;

                case Attributes.ServerOwner:
                    if (context.Guild.OwnerId != guildUser.Id && DbGuild.ModRoles.ElementCount == 0)
                    {
                        return(PreconditionResult.FromError("Only the owners of this server may use this command."));
                    }
                    else if (guildUser.Guild.OwnerId != context.User.Id && DbGuild.ModRoles != null && !guildUser.RoleIds.Any(x => DbGuild.ModRoles.Any(y => y.Name == x.ToString() && y.Value.AsInt32 >= 3)))
                    {
                        return(PreconditionResult.FromError("Only the owners of this server may use this command."));
                    }

                    break;

                case Attributes.Admin:
                    if (!guildUser.GuildPermissions.Administrator && DbGuild.ModRoles.ElementCount == 0)
                    {
                        return(PreconditionResult.FromError("The administrator permission is required to use this command."));
                    }
                    else if (!guildUser.GuildPermissions.Administrator && DbGuild.ModRoles.ElementCount != 0 && !guildUser.RoleIds.Any(x => DbGuild.ModRoles.Any(y => y.Name == x.ToString() && y.Value.AsInt32 >= 2)))
                    {
                        return(PreconditionResult.FromError("The administrator permission is required to use this command."));
                    }

                    break;

                case Attributes.Moderator:
                    if (_moderationService.GetPermLevel(DbGuild, context.User as IGuildUser) == 0)
                    {
                        return(PreconditionResult.FromError("Only a moderator may use this command."));
                    }
                    break;

                case Attributes.Nsfw:
                    if (!DbGuild.Nsfw)
                    {
                        return(PreconditionResult.FromError($"This command may not be used while NSFW is disabled. An administrator may enable with the " +
                                                            $"`{DbGuild.Prefix}ChangeNSFWSettings` command."));
                    }

                    var nsfwChannel = await context.Guild.GetChannelAsync(DbGuild.NsfwChannelId);

                    if (nsfwChannel != null && context.Channel.Id != DbGuild.NsfwChannelId)
                    {
                        return(PreconditionResult.FromError($"You may only use this command in {(nsfwChannel as ITextChannel).Mention}."));
                    }

                    break;

                case Attributes.InGang:
                    if (!await _gangRepo.InGangAsync(guildUser))
                    {
                        return(PreconditionResult.FromError("You must be in a gang to use this command."));
                    }

                    break;

                case Attributes.NoGang:
                    if (await _gangRepo.InGangAsync(guildUser))
                    {
                        return(PreconditionResult.FromError("You may not use this command while in a gang."));
                    }

                    break;

                case Attributes.GangLeader:
                    if ((await _gangRepo.GetGangAsync(guildUser)).LeaderId != context.User.Id)
                    {
                        return(PreconditionResult.FromError("You must be the leader of a gang to use this command."));
                    }

                    break;

                case Attributes.Jump:
                    if (DbUser.Cash < Config.JUMP_REQUIREMENT)
                    {
                        return(PreconditionResult.FromError($"You do not have the permission to use this command.\nRequired cash: {Config.JUMP_REQUIREMENT.USD()}."));
                    }

                    break;

                case Attributes.Steal:
                    if (DbUser.Cash < Config.STEAL_REQUIREMENT)
                    {
                        return(PreconditionResult.FromError($"You do not have the permission to use this command.\nRequired cash: {Config.STEAL_REQUIREMENT.USD()}."));
                    }

                    break;

                case Attributes.Rob:
                    if (DbUser.Cash < Config.ROB_REQUIREMENT)
                    {
                        return(PreconditionResult.FromError($"You do not have the permission to use this command.\nRequired cash: {Config.ROB_REQUIREMENT.USD()}."));
                    }

                    break;

                case Attributes.Bully:
                    if (DbUser.Cash < Config.BULLY_REQUIREMENT)
                    {
                        return(PreconditionResult.FromError($"You do not have the permission to use this command.\nRequired cash: {Config.BULLY_REQUIREMENT.USD()}."));
                    }

                    break;

                case Attributes.FiftyX2:
                    if (DbUser.Cash < Config.FIFTYX2_REQUIREMENT)
                    {
                        return(PreconditionResult.FromError($"You do not have the permission to use this command.\nRequired cash: {Config.FIFTYX2_REQUIREMENT.USD()}."));
                    }

                    break;

                default:
                    return(PreconditionResult.FromError($"ERROR: The {attribute} attribute is not being handled!"));
                }
            }

            return(PreconditionResult.FromSuccess());
        }
Esempio n. 4
0
        public async Task Cooldowns([Remainder] IGuildUser user = null)
        {
            user = user ?? Context.GUser;
            var dbUser = Context.User.Id == user.Id ? Context.DbUser : await _userRepo.GetUserAsync(user);

            var cooldowns = new Dictionary <String, TimeSpan>
            {
                { "W***e", Config.WHORE_COOLDOWN.Subtract(DateTime.UtcNow.Subtract(dbUser.W***e)) },
                { "Jump", Config.JUMP_COOLDOWN.Subtract(DateTime.UtcNow.Subtract(dbUser.Jump)) },
                { "Steal", Config.STEAL_COOLDOWN.Subtract(DateTime.UtcNow.Subtract(dbUser.Steal)) },
                { "Rob", Config.ROB_COOLDOWN.Subtract(DateTime.UtcNow.Subtract(dbUser.Rob)) },
                { "Withdraw", Config.WITHDRAW_COOLDOWN.Subtract(DateTime.UtcNow.Subtract(dbUser.Withdraw)) }
            };

            if (await _gangRepo.InGangAsync(user))
            {
                cooldowns.Add("Raid", Config.RAID_COOLDOWN.Subtract(DateTime.UtcNow.Subtract(Context.User.Id == user.Id ? Context.Gang.Raid : (await _gangRepo.GetGangAsync(user)).Raid)));
            }

            var description = string.Empty;

            foreach (var cooldown in cooldowns)
            {
                if (cooldown.Value.TotalMilliseconds > 0)
                {
                    description += $"{cooldown.Key}: {cooldown.Value.Hours}:{cooldown.Value.Minutes.ToString("D2")}:{cooldown.Value.Seconds.ToString("D2")}\n";
                }
            }

            if (description.Length == 0)
            {
                ReplyError("All commands are available for use!");
            }

            await SendAsync(description, $"All cooldowns for {user}");
        }