public async Task AddRole(IRole role, int level) { var config = LevelService.TryGetLevelConfig(Context.Guild.Id); if (config == null || !config.Enabled) { await ReplyAsync("You must enable leveling before editing it's settings."); return; } //Remove the role if it already exists in the rewards config.RewardRoles = config.RewardRoles.Where(x => x.RoleId != role.Id).ToList(); if (config.RewardRoles.Any(x => x.LevelRequirement == level)) { await ReplyAsync("There can only be one role per level."); return; } config.RewardRoles.Add(new LevelConfig.LevelReward { RoleId = role.Id, LevelRequirement = level }); LevelService.Database.Store(config, LevelConfig.DocumentName(Context.Guild.Id)); await ReplyAsync($"Role Added"); }
public async Task ToggleWhitelist() { var config = LevelService.GetOrCreateLevelConfig(Context.Guild.Id); config.RestrictionMode = LevelConfig.LevelRestrictionType.Whitelist; LevelService.Database.Store(config, LevelConfig.DocumentName(Context.Guild.Id)); await ReplyAsync($"Leveling will now be restricted to channels added with the `addchannel` command"); }
public async Task ToggleLevelingAsync() { var config = LevelService.GetOrCreateLevelConfig(Context.Guild.Id); config.Enabled = !config.Enabled; LevelService.Database.Store(config, LevelConfig.DocumentName(Context.Guild.Id)); await ReplyAsync($"Leveling Enabled: {config.Enabled}"); }
public LevelConfig GetOrCreateLevelConfig(ulong guildId) { var config = TryGetLevelConfig(guildId); if (config == null) { config = new LevelConfig(guildId); Database.Store(config, LevelConfig.DocumentName(guildId)); } return(config); }
public async Task ToggleMultiRole() { var config = LevelService.TryGetLevelConfig(Context.Guild.Id); if (config == null || !config.Enabled) { await ReplyAsync("You must enable leveling before editing it's settings."); return; } config.MultiRole = !config.MultiRole; LevelService.Database.Store(config, LevelConfig.DocumentName(Context.Guild.Id)); await ReplyAsync($"Multiple role rewards: {config.MultiRole}"); }
public async Task ToggleLevelUpNotifications() { var config = LevelService.TryGetLevelConfig(Context.Guild.Id); if (config == null || !config.Enabled) { await ReplyAsync("You must enable leveling before editing it's settings."); return; } config.ReplyLevelUps = !config.ReplyLevelUps; LevelService.Database.Store(config, LevelConfig.DocumentName(Context.Guild.Id)); await ReplyAsync($"Reply Level Ups: {config.ReplyLevelUps}"); }
public async Task DisableLogChannel() { var config = LevelService.TryGetLevelConfig(Context.Guild.Id); if (config == null || !config.Enabled) { await ReplyAsync("You must enable leveling before editing it's settings."); return; } config.LogChannelId = 0; LevelService.Database.Store(config, LevelConfig.DocumentName(Context.Guild.Id)); await ReplyAsync("Log channel disabled."); }
public async Task Enable() { var config = LevelService.TryGetLevelConfig(Context.Guild.Id); if (config == null || !config.Enabled) { await ReplyAsync("You must enable leveling before editing it's settings."); return; } config.LogChannelId = Context.Channel.Id; LevelService.Database.Store(config, LevelConfig.DocumentName(Context.Guild.Id)); await ReplyAsync($"Level up events will be logged to: {Context.Channel.Name}"); }
public async Task RemoveChannel() { var config = LevelService.GetOrCreateLevelConfig(Context.Guild.Id); if (config.RestrictionMode == LevelConfig.LevelRestrictionType.None) { await ReplyAsync("You must enable either the blacklist or whitelist to use this command."); return; } config.RestrictedChannels.Remove(Context.Channel.Id); LevelService.Database.Store(config, LevelConfig.DocumentName(Context.Guild.Id)); await ReplyAsync($"This channel is now removed from the level {config.RestrictionMode}."); }
public async Task RemoveChannels() { var config = LevelService.GetOrCreateLevelConfig(Context.Guild.Id); if (config.RestrictionMode == LevelConfig.LevelRestrictionType.None) { await ReplyAsync("You must enable either the blacklist or whitelist to use this command."); return; } config.RestrictedChannels = new List <ulong>(); LevelService.Database.Store(config, LevelConfig.DocumentName(Context.Guild.Id)); await ReplyAsync($"Restricted channels have been cleared."); }
public async Task RemoveRole(ulong roleId) { var config = LevelService.TryGetLevelConfig(Context.Guild.Id); if (config == null || !config.Enabled) { await ReplyAsync("You must enable leveling before editing it's settings."); return; } //Remove the role if it already exists in the rewards config.RewardRoles = config.RewardRoles.Where(x => x.RoleId != roleId).ToList(); LevelService.Database.Store(config, LevelConfig.DocumentName(Context.Guild.Id)); await ReplyAsync($"Role Removed\nNOTE: Users who have this role will still keep it."); }
public LevelConfig TryGetLevelConfig(ulong guildId) { var config = Database.Load <LevelConfig>(LevelConfig.DocumentName(guildId)); return(config); }