public async Task LogIgnore() { var channel = (ITextChannel)Context.Channel; int removed; using (var uow = _db.UnitOfWork) { var config = uow.GuildConfigs.LogSettingsFor(channel.Guild.Id); LogSetting logSetting = Service.GuildLogSettings.GetOrAdd(channel.Guild.Id, (id) => config.LogSetting); removed = logSetting.IgnoredChannels.RemoveWhere(ilc => ilc.ChannelId == channel.Id); config.LogSetting.IgnoredChannels.RemoveWhere(ilc => ilc.ChannelId == channel.Id); if (removed == 0) { var toAdd = new IgnoredLogChannel { ChannelId = channel.Id }; logSetting.IgnoredChannels.Add(toAdd); config.LogSetting.IgnoredChannels.Add(toAdd); } await uow.CompleteAsync().ConfigureAwait(false); } if (removed == 0) { await ReplyConfirmLocalized("log_ignore", Format.Bold(channel.Mention + "(" + channel.Id + ")")).ConfigureAwait(false); } else { await ReplyConfirmLocalized("log_not_ignore", Format.Bold(channel.Mention + "(" + channel.Id + ")")).ConfigureAwait(false); } }
public async Task LogIgnore(IUserMessage imsg) { var channel = (ITextChannel)imsg.Channel; int removed; using (var uow = DbHandler.UnitOfWork()) { var config = uow.GuildConfigs.For(channel.Guild.Id); LogSetting logSetting = GuildLogSettings.GetOrAdd(channel.Guild.Id, (id) => config.LogSetting); removed = logSetting.IgnoredChannels.RemoveWhere(ilc => ilc.ChannelId == channel.Id); config.LogSetting.IgnoredChannels.RemoveWhere(ilc => ilc.ChannelId == channel.Id); if (removed == 0) { var toAdd = new IgnoredLogChannel { ChannelId = channel.Id }; logSetting.IgnoredChannels.Add(toAdd); config.LogSetting.IgnoredChannels.Add(toAdd); } await uow.CompleteAsync().ConfigureAwait(false); } if (removed == 0) { await channel.SendMessageAsync($"🆗 Logging will **now ignore** #⃣ `{channel.Name} ({channel.Id})`").ConfigureAwait(false); } else { await channel.SendMessageAsync($"ℹ️ Logging will **no longer ignore** #⃣ `{channel.Name} ({channel.Id})`").ConfigureAwait(false); } }