Add guildId filtered config settings

This commit is contained in:
Daniel_I_Am 2020-06-06 13:15:34 +02:00
parent 9a98960717
commit cb335bd393
No known key found for this signature in database
GPG Key ID: 80C428FCC9743E84
2 changed files with 12 additions and 2 deletions

View File

@ -13,6 +13,16 @@ namespace ChaosBot.Database.Repository
return AppSettingsHandler.GetValue<T>(configurationFlag); return AppSettingsHandler.GetValue<T>(configurationFlag);
} }
public static T GetValue<T>(string configurationFlag, ulong guildId)
{
return AppSettingsHandler.GetValue<T>($"Servers:{guildId}:{configurationFlag}");
}
public static T SetValue<T>(string configurationFlag, T value)
{
return AppSettingsHandler.GetValue<T>(configurationFlag);
}
public static IConfigurationSection GetSection(string configurationFlag) public static IConfigurationSection GetSection(string configurationFlag)
{ {
return AppSettingsHandler.GetSection(configurationFlag); return AppSettingsHandler.GetSection(configurationFlag);

View File

@ -59,12 +59,12 @@ namespace ChaosBot.Discord.Modules
[RequireUserPermission(GuildPermission.ManageGuild)] [RequireUserPermission(GuildPermission.ManageGuild)]
public async Task RaffleCommandAdd(string user, int amount = 1) public async Task RaffleCommandAdd(string user, int amount = 1)
{ {
if (ConfigurationRepository.GetValue<int>($"Servers:{Context.Guild.Id}:Raffle:Max") >= amount) if (ConfigurationRepository.GetValue<int>($"Raffle:Max", Context.Guild.Id) >= amount)
await RaffleCommandHelper("add", user, amount); await RaffleCommandHelper("add", user, amount);
else else
{ {
await ReplyAsync( await ReplyAsync(
$"You cannot give more then {ConfigurationRepository.GetValue<int>($"Servers:{Context.Guild.Id}:Raffle:Max").ToString()} tickets at a time", false); $"You cannot give more then {ConfigurationRepository.GetValue<int>($"Raffle:Max", Context.Guild.Id).ToString()} tickets at a time", false);
_logger.Warn($"{Context.User.Username} attempted to give {amount} tickets to {user}!"); _logger.Warn($"{Context.User.Username} attempted to give {amount} tickets to {user}!");
} }
} }