diff --git a/ChaosBot/Discord/Modules/Admin/Config.cs b/ChaosBot/Discord/Modules/Admin/Config.cs index 339ddc8..d95fd4a 100644 --- a/ChaosBot/Discord/Modules/Admin/Config.cs +++ b/ChaosBot/Discord/Modules/Admin/Config.cs @@ -6,6 +6,7 @@ using System.Text; using ChaosBot.Discord.PreConditions; using ChaosBot.Models; using ChaosBot.Repositories; +using ChaosBot.Services; using Discord; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; @@ -78,20 +79,23 @@ namespace ChaosBot.Discord.Modules.Admin { try { - if ((key != null) && (value != null)) + if ((key != null) && (value != null) ) { - using (ChaosbotContext dbContext = new ChaosbotContext()) + if(await RestrictedConfig.IsAllowed(key)) { - Configuration cnfSet = new Configuration(); - - cnfSet.Key = key; - cnfSet.DiscordGuildId = Context.Guild.Id; - cnfSet.SerializedValue = JsonConvert.SerializeObject(value); + using (ChaosbotContext dbContext = new ChaosbotContext()) + { + Configuration cnfSet = new Configuration(); - await dbContext.Configuration.Upsert(cnfSet) - .On(x => new {x.Key, x.DiscordGuildId}).RunAsync(); - - await ConfigGet(key, true); + cnfSet.Key = key; + cnfSet.DiscordGuildId = Context.Guild.Id; + cnfSet.SerializedValue = JsonConvert.SerializeObject(value); + + await dbContext.Configuration.Upsert(cnfSet) + .On(x => new {x.Key, x.DiscordGuildId}).RunAsync(); + + await ConfigGet(key, true); + } } } else @@ -111,7 +115,7 @@ namespace ChaosBot.Discord.Modules.Admin { try { - if (key != null) + if ((key != null) && (await RestrictedConfig.IsAllowed(key))) { StringBuilder sb = new StringBuilder(); EmbedBuilder embed = new EmbedBuilder();