Augmenting code to use isAllowed
This commit is contained in:
parent
93f55adf7b
commit
f1577ba5b7
@ -6,6 +6,7 @@ using System.Text;
|
|||||||
using ChaosBot.Discord.PreConditions;
|
using ChaosBot.Discord.PreConditions;
|
||||||
using ChaosBot.Models;
|
using ChaosBot.Models;
|
||||||
using ChaosBot.Repositories;
|
using ChaosBot.Repositories;
|
||||||
|
using ChaosBot.Services;
|
||||||
using Discord;
|
using Discord;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@ -78,20 +79,23 @@ namespace ChaosBot.Discord.Modules.Admin
|
|||||||
{
|
{
|
||||||
try
|
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();
|
using (ChaosbotContext dbContext = new ChaosbotContext())
|
||||||
|
{
|
||||||
cnfSet.Key = key;
|
Configuration cnfSet = new Configuration();
|
||||||
cnfSet.DiscordGuildId = Context.Guild.Id;
|
|
||||||
cnfSet.SerializedValue = JsonConvert.SerializeObject(value);
|
|
||||||
|
|
||||||
await dbContext.Configuration.Upsert(cnfSet)
|
cnfSet.Key = key;
|
||||||
.On(x => new {x.Key, x.DiscordGuildId}).RunAsync();
|
cnfSet.DiscordGuildId = Context.Guild.Id;
|
||||||
|
cnfSet.SerializedValue = JsonConvert.SerializeObject(value);
|
||||||
await ConfigGet(key, true);
|
|
||||||
|
await dbContext.Configuration.Upsert(cnfSet)
|
||||||
|
.On(x => new {x.Key, x.DiscordGuildId}).RunAsync();
|
||||||
|
|
||||||
|
await ConfigGet(key, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -111,7 +115,7 @@ namespace ChaosBot.Discord.Modules.Admin
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (key != null)
|
if ((key != null) && (await RestrictedConfig.IsAllowed(key)))
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
EmbedBuilder embed = new EmbedBuilder();
|
EmbedBuilder embed = new EmbedBuilder();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user