Exemplo n.º 1
0
        public async Task ResetUser([Remainder] IGuildUser user = null)
        {
            user = user ?? Context.GUser;

            await _userRepo.Collection.DeleteOneAsync(y => y.UserId == user.Id && y.GuildId == user.GuildId);

            await _rankHandler.HandleAsync(Context.Guild, user, Context.DbGuild, await _userRepo.GetUserAsync(user));

            await SendAsync($"Successfully reset {user.Boldify()}'s data.");
        }
Exemplo n.º 2
0
        public async Task EditCashAsync(Context context, decimal change)
        {
            decimal newCash = Math.Round(context.Cash + change, 2);

            context.Cash        = newCash;
            context.DbUser.Cash = newCash;
            await UpdateAsync(context.DbUser);

            await _RankHandler.HandleAsync(context.GUser, context.DbGuild, context.DbUser);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Modifies a user's cash.
        /// </summary>
        /// <param name="context">The context of the command use.</param>
        /// <param name="change">The +/- change on the user's cash.</param>
        public async Task EditCashAsync(DEAContext context, decimal change)
        {
            var newCash = Math.Round(context.Cash + change, 2);

            context.Cash        = newCash;
            context.DbUser.Cash = newCash;
            await UpdateAsync(context.DbUser);

            await _rankHandler.HandleAsync(context.Guild, context.User as IGuildUser, context.DbGuild, context.DbUser);
        }
Exemplo n.º 4
0
        private Task HandleUserJoined(SocketGuildUser u)
        {
            return(Task.Run(async() =>
            {
                Logger.Log(LogSeverity.Debug, $"Event", "User Joined");
                if ((await _blacklistRepo.AllAsync()).Any(x => x.UserId == u.Id))
                {
                    try
                    {
                        await u.Guild.AddBanAsync(u);
                    }
                    catch
                    {
                        // Ignored.
                    }
                }

                var user = u as IGuildUser;
                var dbGuild = await _guildRepo.GetGuildAsync(user.Guild.Id);

                var mutedRole = user.Guild.GetRole((dbGuild.MutedRoleId));
                if (mutedRole != null && u.Guild.CurrentUser.GuildPermissions.ManageRoles &&
                    mutedRole.Position < u.Guild.CurrentUser.Roles.OrderByDescending(x => x.Position).First().Position)
                {
                    await _RankHandler.HandleAsync(user, dbGuild, await _userRepo.GetUserAsync(user));
                    if (await _muteRepo.IsMutedAsync(user.Id, user.Guild.Id) && mutedRole != null && user != null)
                    {
                        await user.AddRoleAsync(mutedRole);
                    }
                }

                if (!string.IsNullOrWhiteSpace(dbGuild.WelcomeMessage))
                {
                    var channel = _client.GetChannel(dbGuild.WelcomeChannelId);
                    if (channel != null)
                    {
                        try
                        {
                            await(channel as ITextChannel).SendAsync($"{u}, " + dbGuild.WelcomeMessage);
                        }
                        catch
                        {
                            // Ignored.
                        }
                    }
                    else
                    {
                        try
                        {
                            var dmChannel = await u.CreateDMChannelAsync();
                            await dmChannel.SendAsync(dbGuild.WelcomeMessage);
                        }
                        catch
                        {
                            // Ignored.
                        }
                    }
                }
            }));
        }