Example #1
0
        public static async Task SetHex(Color color, ulong UserId)
        {
            using var DbContext = new NamikoDbContext();
            var profile = DbContext.Profiles.Where(x => x.UserId == UserId).FirstOrDefault();

            //checking hex validity (makes sure hex colour.len ALWAYS = 6)
            string colour   = color.Name;
            int    boundary = colour.Length;

            if (boundary < 6)
            {
                colour = new string('0', 6 - boundary) + colour;
            }

            //if this user has not set a custom colour
            if (profile == null)
            {
                DbContext.Add(new Profile {
                    UserId = UserId, ColorHex = colour
                });
                await DbContext.SaveChangesAsync();

                return;
            }

            //setting profile values + updating stack
            profile.PriorColorHexStack = PushStackManagement(profile.ColorHex, profile.PriorColorHexStack);
            profile.ColorHex           = colour;
            DbContext.Update(profile);
            await DbContext.SaveChangesAsync();
        }
Example #2
0
 public static async Task NewInvite(ulong teamId, ulong userId)
 {
     using var DbContext = new NamikoDbContext();
     DbContext.Add(new Invite {
         TeamId = teamId, UserId = userId, Date = DateTime.Now
     });
     await DbContext.SaveChangesAsync();
 }
Example #3
0
 public static async Task AddTeam(ulong leaderId, ulong memberId, ulong guildId)
 {
     using var DbContext = new NamikoDbContext();
     DbContext.Add(new Team {
         LeaderRoleId = leaderId, MemberRoleId = memberId, GuildId = guildId
     });
     await DbContext.SaveChangesAsync();
 }
Example #4
0
 public static async Task Add(ulong roleId, ulong guildId)
 {
     using var DbContext = new NamikoDbContext();
     DbContext.Add(new PublicRole {
         RoleId = roleId, GuildId = guildId
     });
     await DbContext.SaveChangesAsync();
 }
Example #5
0
 public static async Task AddMessage(String message)
 {
     using var DbContext = new NamikoDbContext();
     DbContext.Add(new WelcomeMessage {
         Message = message
     });
     await DbContext.SaveChangesAsync();
 }
Example #6
0
 public static async Task CreateAlbum(string name, string albumId)
 {
     using var db = new NamikoDbContext();
     db.Add(new ImgurAlbumLink {
         AlbumId = albumId, Name = name.ToLowerInvariant()
     });
     await db.SaveChangesAsync();
 }
Example #7
0
        public static async Task UpdateServer(Server server)
        {
            using var db = new NamikoDbContext();
            if (!db.Servers.Any(x => x.GuildId == server.GuildId))
            {
                db.Add(server);
            }

            else
            {
                db.Update(server);
            }

            await db.SaveChangesAsync();
        }
Example #8
0
        public static async Task UpdateBlacklistedChannel(BlacklistedChannel ch)
        {
            using NamikoDbContext db = new NamikoDbContext();
            var res = db.BlacklistedChannels.Where(x => x.ChannelId == ch.ChannelId).FirstOrDefault();

            if (res == null)
            {
                db.Add(ch);
            }

            else
            {
                db.Update(ch);
            }

            BlacklistedChannelIds.Add(ch.ChannelId);
            await db.SaveChangesAsync();
        }
Example #9
0
        public static async Task SetToasties(ulong UserId, int Amount, ulong GuildId)
        {
            using var DbContext = new NamikoDbContext();
            var toasties = DbContext.Toasties.FirstOrDefault(x => x.UserId == UserId && x.GuildId == GuildId);

            if (toasties == null)
            {
                DbContext.Add(new Balance {
                    UserId = UserId, Amount = Amount, GuildId = GuildId
                });
            }
            else
            {
                toasties.Amount = Amount;
                DbContext.Update(toasties);
            }
            await DbContext.SaveChangesAsync();
        }
Example #10
0
        public static async Task HexDefault(ulong UserId)
        {
            using var DbContext = new NamikoDbContext();
            var profile = DbContext.Profiles.Where(x => x.UserId == UserId).FirstOrDefault();

            //if this user is not in the database
            if (profile == null)
            {
                DbContext.Add(new Profile {
                    UserId = UserId
                });
                await DbContext.SaveChangesAsync();

                return;
            }

            //updating profile + stack change
            profile.PriorColorHexStack = PushStackManagement(profile.ColorHex, profile.PriorColorHexStack);
            profile.ColorHex           = "";
            DbContext.Update(profile);
            await DbContext.SaveChangesAsync();
        }
Example #11
0
 public static async Task <int> AddWaifu(Waifu waifu)
 {
     using var DbContext = new NamikoDbContext();
     DbContext.Add(waifu);
     return(await DbContext.SaveChangesAsync());
 }
Example #12
0
 public static async Task NewBanroulette(Banroulette banroulette)
 {
     using var db = new NamikoDbContext();
     db.Add(banroulette);
     await db.SaveChangesAsync();
 }
Example #13
0
 public static async Task AddBan(BannedUser bannedUser)
 {
     using var db = new NamikoDbContext();
     db.Add(bannedUser);
     await db.SaveChangesAsync();
 }