/// <summary> /// Sets a channel to send all moderator activites the bot is used for into. /// </summary> /// <param name="serverId">The guild ID to look for.</param> /// <param name="channelId">The channel ID to set.</param> /// <param name="serverName">The name of the guild.</param> public async static Task SetModLogChannel(ulong serverId, ulong channelId, string serverName) { using (SqliteDbContext DbContext = new SqliteDbContext()) { try { //Check if the guild has a spot if (DbContext.GuildLocationSettings.Where(x => x.Serverid == serverId).Count() < 1) { DbContext.GuildLocationSettings.Add(new GuildLocationSettings { Serverid = serverId, WelcomeChannel = 0, ServerName = serverName, WelcomeMessage = "", BotSpamChannel = channelId, GoldInterest = 5, ChatLogChannel = 0, ModLogChannel = 0 }); } else { GuildLocationSettings Current = DbContext.GuildLocationSettings.Where(x => x.Serverid == serverId).FirstOrDefault(); Current.ModLogChannel = channelId; Current.ServerName = serverName; DbContext.GuildLocationSettings.Update(Current); } await DbContext.SaveChangesAsync(); } catch (Exception) { } } }
//Everything in here uses Sqlite to access the database /// <summary> /// Set the interest rate on giving gold in the server in whole number form. /// Converts to a percentage. Defaults at 5. /// </summary> /// <param name="serverId">The guild id</param> /// <param name="serverName">The guild name</param> /// <param name="percentage">The number to change the percentage to. 5 would be 0.05%</param> public static async Task SetInterest(ulong serverId, string serverName, int percentage) { using (SqliteDbContext DbContext = new SqliteDbContext()) { try { //Check if the guild already has a spot if (DbContext.GuildLocationSettings.Where(x => x.Serverid == serverId).Count() < 1) { DbContext.GuildLocationSettings.Add(new GuildLocationSettings { //Default the other settings. Serverid = serverId, WelcomeChannel = 0, ServerName = serverName, WelcomeMessage = "", BotSpamChannel = 0, GoldInterest = percentage }); } else { //Override the percentage value GuildLocationSettings Current = DbContext.GuildLocationSettings.Where(x => x.Serverid == serverId).FirstOrDefault(); Current.GoldInterest = percentage; DbContext.GuildLocationSettings.Update(Current); } //Update the database await DbContext.SaveChangesAsync(); } catch (Exception) { } } }