Ejemplo n.º 1
0
 private async Task OnGuildMembersChunked(GuildMembersChunkEventArgs e)
 {
     if (GuildMembersChunked != null)
     {
         await GuildMembersChunked(e);
     }
 }
Ejemplo n.º 2
0
        private async Task OnGuildMembersChunked(DiscordClient dClient, GuildMembersChunkEventArgs args)
        {
            if (args.Guild.Id != Guilds.SBG)
            {
                return;
            }

            IServiceScope scope = this.scopeFactory.CreateScope();
            BloonContext  db    = scope.ServiceProvider.GetRequiredService <BloonContext>();

            List <RoleMember> roleMembers = await db.RoleMembers
                                            .Where(r => args.Members.Select(m => m.Id).Contains(r.MemberId))
                                            .ToListAsync();

            db.RoleMembers.RemoveRange(roleMembers);

            foreach (DiscordMember member in args.Members)
            {
                IEnumerable <DiscordRole> roles = member.Roles.Where(r => ShouldPersist(args.Guild, r));

                if (!roles.Any() || member.IsBot)
                {
                    continue;
                }

                foreach (DiscordRole role in roles)
                {
                    RoleMember roleMember = roleMembers.Where(r => r.MemberId == member.Id && r.RoleId == role.Id)
                                            .FirstOrDefault();

                    if (roleMember != null)
                    {
                        db.Entry(roleMember).State = EntityState.Unchanged;
                    }
                    else
                    {
                        db.RoleMembers.Add(new RoleMember
                        {
                            MemberId = member.Id,
                            RoleId   = role.Id,
                        });
                    }
                }
            }

            await db.SaveChangesAsync();
        }
Ejemplo n.º 3
0
 private Task Client_GuildMembersChunked(GuildMembersChunkEventArgs e)
 {
     e.Client.DebugLogger.LogMessage(LogLevel.Info, "BotApp", e.ToString(), DateTime.Now);
     return(Task.CompletedTask);
 }
Ejemplo n.º 4
0
 private async Task GuildMemberChunked(DiscordClient c, GuildMembersChunkEventArgs e)
 {
     // Todo: logger
 }
Ejemplo n.º 5
0
 private Task Event_GuildMembersChunked(DiscordClient d, GuildMembersChunkEventArgs e)
 {
     d.Logger.LogDebug(BotEventId, "Event_GuildMembersChunked.");
     return(Task.CompletedTask);
 }