コード例 #1
0
        public async Task ExemptAsync(ulong gid, ExemptedEntityType type, IEnumerable <ulong> ids)
        {
            using TheGodfatherDbContext db = this.dbb.CreateContext();
            db.ExemptsMention.AddExemptions(gid, type, ids);
            await db.SaveChangesAsync();

            this.UpdateExemptsForGuildAsync(gid);
        }
コード例 #2
0
        public async Task UnexemptAsync(ulong gid, ExemptedEntityType type, IEnumerable <ulong> ids)
        {
            using TheGodfatherDbContext db = this.dbb.CreateContext();
            db.ExemptsMention.RemoveRange(
                db.ExemptsMention.Where(ex => ex.GuildId == gid && ex.Type == type && ids.Any(id => id == ex.Id))
                );
            await db.SaveChangesAsync();

            this.UpdateExemptsForGuildAsync(gid);
        }
コード例 #3
0
ファイル: ExemptedEntity.cs プロジェクト: Nexowned/Freud2.0
        public static string ToUserFriendlyString(this ExemptedEntityType entity)
        {
            switch (entity)
            {
            case ExemptedEntityType.Channel: return("Channel");

            case ExemptedEntityType.Member: return("User");

            case ExemptedEntityType.Role: return("Role");

            default: return("Unknown");
            }
        }
コード例 #4
0
ファイル: ExemptedEntity.cs プロジェクト: Nexowned/Freud2.0
        public static char ToFlag(this ExemptedEntityType entity)
        {
            switch (entity)
            {
            case ExemptedEntityType.Channel: return('c');

            case ExemptedEntityType.Member: return('m');

            case ExemptedEntityType.Role: return('r');

            default: return('?');
            }
        }
コード例 #5
0
 public static void AddExemptions <TEntity>(this DbSet <TEntity> set, ulong gid, ExemptedEntityType type, IEnumerable <ulong> ids)
     where TEntity : ExemptedEntity, new()
 {
     set.AddRange(ids
                  .Where(id => !set.Where(dbe => dbe.GuildIdDb == (long)gid).Any(dbe => dbe.Type == type && dbe.IdDb == (long)id))
                  .Select(id => new TEntity {
         GuildId = gid,
         Id      = id,
         Type    = type
     })
                  );
 }
コード例 #6
0
 public static void AddExemptions <TEntity, TExempt>(this DbSet <TEntity> set, ulong gid, IEnumerable <TExempt> exempts, ExemptedEntityType type)
     where TEntity : DatabaseExemptedEntity, new()
     where TExempt : SnowflakeObject
 {
     set.AddRange(exempts
                  .Where(e => !set.Where(dbe => dbe.GuildId == gid).Any(dbe => dbe.Type == type && dbe.Id == e.Id))
                  .Select(e => new TEntity {
         GuildId = gid,
         Id      = e.Id,
         Type    = type
     })
                  );
 }
コード例 #7
0
 public static string ToTypeString(this ExemptedEntityType type)
 => Enum.GetName(typeof(ExemptedEntityType), type) ?? "Unknown";