Merge pull request #22 from Kwoth/dev
Guildconfigs now only query what it needs. Possibly broke a lot of stuff
This commit is contained in:
commit
112ee49ca7
@ -52,7 +52,7 @@ namespace NadekoBot.Modules.Administration
|
||||
bool shouldDelete;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
shouldDelete = uow.GuildConfigs.For(channel.Guild.Id).DeleteMessageOnCommand;
|
||||
shouldDelete = uow.GuildConfigs.For(channel.Guild.Id, set => set).DeleteMessageOnCommand;
|
||||
}
|
||||
|
||||
if (shouldDelete)
|
||||
@ -128,15 +128,15 @@ namespace NadekoBot.Modules.Administration
|
||||
public async Task Delmsgoncmd(IUserMessage umsg)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
GuildConfig conf;
|
||||
bool enabled;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
conf = uow.GuildConfigs.For(channel.Guild.Id);
|
||||
conf.DeleteMessageOnCommand = !conf.DeleteMessageOnCommand;
|
||||
uow.GuildConfigs.Update(conf);
|
||||
var conf = uow.GuildConfigs.For(channel.Guild.Id, set => set);
|
||||
enabled = conf.DeleteMessageOnCommand = !conf.DeleteMessageOnCommand;
|
||||
|
||||
await uow.CompleteAsync();
|
||||
}
|
||||
if (conf.DeleteMessageOnCommand)
|
||||
if (enabled)
|
||||
await channel.SendMessageAsync("✅ **Now automatically deleting successful command invokations.**").ConfigureAwait(false);
|
||||
else
|
||||
await channel.SendMessageAsync("❗**Stopped automatic deletion of successful command invokations.**").ConfigureAwait(false);
|
||||
@ -399,7 +399,7 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var config = uow.GuildConfigs.For(channel.Guild.Id);
|
||||
var config = uow.GuildConfigs.For(channel.Guild.Id, set => set);
|
||||
config.MuteRoleName = name;
|
||||
GuildMuteRoles.AddOrUpdate(channel.Guild.Id, name, (id, old) => name);
|
||||
await uow.CompleteAsync().ConfigureAwait(false);
|
||||
|
@ -30,7 +30,7 @@ namespace NadekoBot.Modules.Administration
|
||||
GuildConfig conf;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
conf = uow.GuildConfigs.For(user.Guild.Id);
|
||||
conf = uow.GuildConfigs.For(user.Guild.Id, set => set);
|
||||
}
|
||||
|
||||
if (conf.AutoAssignRoleId == 0)
|
||||
@ -57,13 +57,12 @@ namespace NadekoBot.Modules.Administration
|
||||
GuildConfig conf;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
conf = uow.GuildConfigs.For(channel.Guild.Id);
|
||||
conf = uow.GuildConfigs.For(channel.Guild.Id, set => set);
|
||||
if (role == null)
|
||||
conf.AutoAssignRoleId = 0;
|
||||
else
|
||||
conf.AutoAssignRoleId = role.Id;
|
||||
|
||||
uow.GuildConfigs.Update(conf);
|
||||
await uow.CompleteAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NadekoBot.Attributes;
|
||||
using NadekoBot.Extensions;
|
||||
using NadekoBot.Services;
|
||||
@ -698,7 +699,9 @@ namespace NadekoBot.Modules.Administration
|
||||
bool enabled;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var logSetting = uow.GuildConfigs.For(channel.Guild.Id).LogSetting;
|
||||
var logSetting = uow.GuildConfigs.For(channel.Guild.Id, set => set.Include(gc => gc.LogSetting)
|
||||
.ThenInclude(ls => ls.IgnoredVoicePresenceChannelIds))
|
||||
.LogSetting;
|
||||
GuildLogSettings.AddOrUpdate(channel.Guild.Id, (id) => logSetting, (id, old) => logSetting);
|
||||
enabled = logSetting.LogVoicePresence = !logSetting.LogVoicePresence;
|
||||
if (enabled)
|
||||
|
@ -109,7 +109,7 @@ namespace NadekoBot.Modules.Administration
|
||||
var byeMsg = (string)reader["ByeText"];
|
||||
var grdel = false;
|
||||
var byedel = grdel;
|
||||
var gc = uow.GuildConfigs.For(gid);
|
||||
var gc = uow.GuildConfigs.For(gid, set => set);
|
||||
|
||||
if (greetDM)
|
||||
gc.SendDmGreetMessage = greet;
|
||||
|
@ -27,7 +27,7 @@ namespace NadekoBot.Modules.Administration
|
||||
bool newval;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var config = uow.GuildConfigs.For(channel.Guild.Id);
|
||||
var config = uow.GuildConfigs.For(channel.Guild.Id, set => set);
|
||||
newval = config.AutoDeleteSelfAssignedRoleMessages = !config.AutoDeleteSelfAssignedRoleMessages;
|
||||
await uow.CompleteAsync().ConfigureAwait(false);
|
||||
}
|
||||
@ -132,7 +132,7 @@ namespace NadekoBot.Modules.Administration
|
||||
bool areExclusive;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var config = uow.GuildConfigs.For(channel.Guild.Id);
|
||||
var config = uow.GuildConfigs.For(channel.Guild.Id, set => set);
|
||||
|
||||
areExclusive = config.ExclusiveSelfAssignedRoles = !config.ExclusiveSelfAssignedRoles;
|
||||
await uow.CompleteAsync();
|
||||
@ -153,7 +153,7 @@ namespace NadekoBot.Modules.Administration
|
||||
IEnumerable<SelfAssignedRole> roles;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
conf = uow.GuildConfigs.For(channel.Guild.Id);
|
||||
conf = uow.GuildConfigs.For(channel.Guild.Id, set => set);
|
||||
roles = uow.SelfAssignedRoles.GetFromGuild(channel.Guild.Id);
|
||||
}
|
||||
SelfAssignedRole roleModel;
|
||||
@ -207,11 +207,11 @@ namespace NadekoBot.Modules.Administration
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
var guildUser = (IGuildUser)umsg.Author;
|
||||
|
||||
GuildConfig conf;
|
||||
bool autoDeleteSelfAssignedRoleMessages;
|
||||
IEnumerable<SelfAssignedRole> roles;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
conf = uow.GuildConfigs.For(channel.Guild.Id);
|
||||
autoDeleteSelfAssignedRoleMessages = uow.GuildConfigs.For(channel.Guild.Id, set => set).AutoDeleteSelfAssignedRoleMessages;
|
||||
roles = uow.SelfAssignedRoles.GetFromGuild(channel.Guild.Id);
|
||||
}
|
||||
SelfAssignedRole roleModel;
|
||||
@ -236,7 +236,7 @@ namespace NadekoBot.Modules.Administration
|
||||
}
|
||||
var msg = await channel.SendMessageAsync($"🆗 You no longer have **{role.Name}** role.").ConfigureAwait(false);
|
||||
|
||||
if (conf.AutoDeleteSelfAssignedRoleMessages)
|
||||
if (autoDeleteSelfAssignedRoleMessages)
|
||||
{
|
||||
var t = Task.Run(async () =>
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ namespace NadekoBot.Modules.Administration
|
||||
GuildConfig conf;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
conf = uow.GuildConfigs.For(user.Guild.Id);
|
||||
conf = uow.GuildConfigs.For(user.Guild.Id, set => set);
|
||||
}
|
||||
|
||||
if (!conf.SendChannelByeMessage) return;
|
||||
@ -76,7 +76,7 @@ namespace NadekoBot.Modules.Administration
|
||||
GuildConfig conf;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
conf = uow.GuildConfigs.For(user.Guild.Id);
|
||||
conf = uow.GuildConfigs.For(user.Guild.Id, set => set);
|
||||
}
|
||||
|
||||
if (conf.SendChannelGreetMessage)
|
||||
@ -147,9 +147,9 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var conf = uow.GuildConfigs.For(id);
|
||||
var conf = uow.GuildConfigs.For(id, set => set);
|
||||
conf.AutoDeleteGreetMessagesTimer = timer;
|
||||
uow.GuildConfigs.Update(conf);
|
||||
|
||||
await uow.CompleteAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@ -174,10 +174,10 @@ namespace NadekoBot.Modules.Administration
|
||||
bool enabled;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var conf = uow.GuildConfigs.For(guildId);
|
||||
var conf = uow.GuildConfigs.For(guildId, set => set);
|
||||
enabled = conf.SendChannelGreetMessage = value ?? !conf.SendChannelGreetMessage;
|
||||
conf.GreetMessageChannelId = channelId;
|
||||
uow.GuildConfigs.Update(conf);
|
||||
|
||||
await uow.CompleteAsync().ConfigureAwait(false);
|
||||
}
|
||||
return enabled;
|
||||
@ -192,12 +192,12 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
GuildConfig config;
|
||||
string channelGreetMessageText;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
config = uow.GuildConfigs.For(channel.Guild.Id);
|
||||
channelGreetMessageText = uow.GuildConfigs.For(channel.Guild.Id, set => set).ChannelGreetMessageText;
|
||||
}
|
||||
await channel.SendMessageAsync("ℹ️ Current **greet** message: `" + config.ChannelGreetMessageText?.SanitizeMentions() + "`");
|
||||
await channel.SendMessageAsync("ℹ️ Current **greet** message: `" + channelGreetMessageText?.SanitizeMentions() + "`");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -218,11 +218,10 @@ namespace NadekoBot.Modules.Administration
|
||||
bool greetMsgEnabled;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var conf = uow.GuildConfigs.For(guildId);
|
||||
var conf = uow.GuildConfigs.For(guildId, set => set);
|
||||
conf.ChannelGreetMessageText = message;
|
||||
greetMsgEnabled = conf.SendChannelGreetMessage;
|
||||
|
||||
uow.GuildConfigs.Update(conf);
|
||||
uow.Complete();
|
||||
}
|
||||
return greetMsgEnabled;
|
||||
@ -248,9 +247,9 @@ namespace NadekoBot.Modules.Administration
|
||||
bool enabled;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var conf = uow.GuildConfigs.For(guildId);
|
||||
var conf = uow.GuildConfigs.For(guildId, set => set);
|
||||
enabled = conf.SendDmGreetMessage = value ?? !conf.SendDmGreetMessage;
|
||||
uow.GuildConfigs.Update(conf);
|
||||
|
||||
await uow.CompleteAsync().ConfigureAwait(false);
|
||||
}
|
||||
return enabled;
|
||||
@ -295,7 +294,6 @@ namespace NadekoBot.Modules.Administration
|
||||
conf.DmGreetMessageText = message;
|
||||
greetMsgEnabled = conf.SendDmGreetMessage;
|
||||
|
||||
uow.GuildConfigs.Update(conf);
|
||||
uow.Complete();
|
||||
}
|
||||
return greetMsgEnabled;
|
||||
@ -321,10 +319,10 @@ namespace NadekoBot.Modules.Administration
|
||||
bool enabled;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var conf = uow.GuildConfigs.For(guildId);
|
||||
var conf = uow.GuildConfigs.For(guildId, set => set);
|
||||
enabled = conf.SendChannelByeMessage = value ?? !conf.SendChannelByeMessage;
|
||||
conf.ByeMessageChannelId = channelId;
|
||||
uow.GuildConfigs.Update(conf);
|
||||
|
||||
await uow.CompleteAsync();
|
||||
}
|
||||
return enabled;
|
||||
@ -339,12 +337,12 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
GuildConfig config;
|
||||
string byeMessageText;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
config = uow.GuildConfigs.For(channel.Guild.Id);
|
||||
byeMessageText = uow.GuildConfigs.For(channel.Guild.Id, set => set).ChannelByeMessageText;
|
||||
}
|
||||
await channel.SendMessageAsync("ℹ️ Current **bye** message: `" + config.ChannelByeMessageText?.SanitizeMentions() + "`");
|
||||
await channel.SendMessageAsync("ℹ️ Current **bye** message: `" + byeMessageText?.SanitizeMentions() + "`");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -365,11 +363,10 @@ namespace NadekoBot.Modules.Administration
|
||||
bool byeMsgEnabled;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var conf = uow.GuildConfigs.For(guildId);
|
||||
var conf = uow.GuildConfigs.For(guildId, set => set);
|
||||
conf.ChannelByeMessageText = message;
|
||||
byeMsgEnabled = conf.SendChannelByeMessage;
|
||||
|
||||
uow.GuildConfigs.Update(conf);
|
||||
uow.Complete();
|
||||
}
|
||||
return byeMsgEnabled;
|
||||
@ -397,9 +394,9 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var conf = uow.GuildConfigs.For(id);
|
||||
var conf = uow.GuildConfigs.For(id, set => set);
|
||||
conf.AutoDeleteByeMessagesTimer = timer;
|
||||
uow.GuildConfigs.Update(conf);
|
||||
|
||||
await uow.CompleteAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ namespace NadekoBot.Modules.Administration
|
||||
catch { }
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
uow.GuildConfigs.For(guild.Id).VoicePlusTextEnabled = false;
|
||||
uow.GuildConfigs.For(guild.Id, set => set).VoicePlusTextEnabled = false;
|
||||
voicePlusTextCache.TryRemove(guild.Id);
|
||||
await uow.CompleteAsync().ConfigureAwait(false);
|
||||
}
|
||||
@ -134,7 +134,7 @@ namespace NadekoBot.Modules.Administration
|
||||
bool isEnabled;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var conf = uow.GuildConfigs.For(guild.Id);
|
||||
var conf = uow.GuildConfigs.For(guild.Id, set => set);
|
||||
isEnabled = conf.VoicePlusTextEnabled = !conf.VoicePlusTextEnabled;
|
||||
await uow.CompleteAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NadekoBot.Attributes;
|
||||
using NadekoBot.Extensions;
|
||||
using NadekoBot.Services;
|
||||
@ -166,7 +167,7 @@ namespace NadekoBot.Modules.Games
|
||||
bool enabled;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var guildConfig = uow.GuildConfigs.For(channel.Id);
|
||||
var guildConfig = uow.GuildConfigs.For(channel.Id, set => set.Include(gc => gc.GenerateCurrencyChannelIds));
|
||||
|
||||
var toAdd = new GCChannelId() { ChannelId = channel.Id };
|
||||
if (!guildConfig.GenerateCurrencyChannelIds.Contains(toAdd))
|
||||
|
@ -220,7 +220,7 @@ namespace NadekoBot.Modules.Music
|
||||
}
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
uow.GuildConfigs.For(channel.Guild.Id).DefaultMusicVolume = val / 100.0f;
|
||||
uow.GuildConfigs.For(channel.Guild.Id, set => set).DefaultMusicVolume = val / 100.0f;
|
||||
uow.Complete();
|
||||
}
|
||||
await channel.SendMessageAsync($"🎵 `Default volume set to {val}%`").ConfigureAwait(false);
|
||||
@ -747,7 +747,7 @@ namespace NadekoBot.Modules.Music
|
||||
float vol = 1;// SpecificConfigurations.Default.Of(server.Id).DefaultMusicVolume;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
vol = uow.GuildConfigs.For(textCh.Guild.Id).DefaultMusicVolume;
|
||||
vol = uow.GuildConfigs.For(textCh.Guild.Id, set => set).DefaultMusicVolume;
|
||||
}
|
||||
var mp = new MusicPlayer(voiceCh, vol);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NadekoBot.Attributes;
|
||||
using NadekoBot.Extensions;
|
||||
using NadekoBot.Services;
|
||||
@ -46,7 +47,7 @@ namespace NadekoBot.Modules.Permissions
|
||||
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var config = uow.GuildConfigs.For(channel.Guild.Id);
|
||||
var config = uow.GuildConfigs.For(channel.Guild.Id, set => set.Include(gc => gc.CommandCooldowns));
|
||||
var localSet = commandCooldowns.GetOrAdd(channel.Guild.Id, new ConcurrentHashSet<CommandCooldown>());
|
||||
|
||||
config.CommandCooldowns.RemoveWhere(cc => cc.CommandName == command.Text.ToLowerInvariant());
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NadekoBot.Attributes;
|
||||
using NadekoBot.Services;
|
||||
using System.Collections.Concurrent;
|
||||
@ -68,7 +69,7 @@ namespace NadekoBot.Modules.Permissions
|
||||
bool enabled;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var config = uow.GuildConfigs.For(channel.Guild.Id);
|
||||
var config = uow.GuildConfigs.For(channel.Guild.Id, set => set);
|
||||
enabled = config.FilterInvites = !config.FilterInvites;
|
||||
await uow.CompleteAsync().ConfigureAwait(false);
|
||||
}
|
||||
@ -94,7 +95,7 @@ namespace NadekoBot.Modules.Permissions
|
||||
int removed;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var config = uow.GuildConfigs.For(channel.Guild.Id);
|
||||
var config = uow.GuildConfigs.For(channel.Guild.Id, set => set.Include(gc => gc.FilterInvitesChannelIds));
|
||||
removed = config.FilterInvitesChannelIds.RemoveWhere(fc => fc.ChannelId == channel.Id);
|
||||
if (removed == 0)
|
||||
{
|
||||
@ -127,7 +128,7 @@ namespace NadekoBot.Modules.Permissions
|
||||
bool enabled;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var config = uow.GuildConfigs.For(channel.Guild.Id);
|
||||
var config = uow.GuildConfigs.For(channel.Guild.Id, set => set);
|
||||
enabled = config.FilterWords = !config.FilterWords;
|
||||
await uow.CompleteAsync().ConfigureAwait(false);
|
||||
}
|
||||
@ -153,7 +154,7 @@ namespace NadekoBot.Modules.Permissions
|
||||
int removed;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var config = uow.GuildConfigs.For(channel.Guild.Id);
|
||||
var config = uow.GuildConfigs.For(channel.Guild.Id, set => set.Include(gc => gc.FilterWordsChannelIds));
|
||||
removed = config.FilterWordsChannelIds.RemoveWhere(fc => fc.ChannelId == channel.Id);
|
||||
if (removed == 0)
|
||||
{
|
||||
@ -191,7 +192,7 @@ namespace NadekoBot.Modules.Permissions
|
||||
int removed;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var config = uow.GuildConfigs.For(channel.Guild.Id);
|
||||
var config = uow.GuildConfigs.For(channel.Guild.Id, set => set.Include(gc => gc.FilteredWords));
|
||||
|
||||
removed = config.FilteredWords.RemoveWhere(fw => fw.Word == word);
|
||||
|
||||
|
@ -51,7 +51,7 @@ namespace NadekoBot.Modules.Permissions
|
||||
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var config = uow.GuildConfigs.For(channel.Guild.Id);
|
||||
var config = uow.GuildConfigs.For(channel.Guild.Id, set => set);
|
||||
config.VerbosePermissions = action.Value;
|
||||
Cache.AddOrUpdate(channel.Guild.Id, new PermissionCache()
|
||||
{
|
||||
@ -72,7 +72,7 @@ namespace NadekoBot.Modules.Permissions
|
||||
var channel = (ITextChannel)msg.Channel;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var config = uow.GuildConfigs.For(channel.Guild.Id);
|
||||
var config = uow.GuildConfigs.For(channel.Guild.Id, set => set);
|
||||
if (role == null)
|
||||
{
|
||||
await channel.SendMessageAsync($"ℹ️ Current permission role is **{config.PermissionRole}**.").ConfigureAwait(false);
|
||||
|
@ -112,7 +112,8 @@ namespace NadekoBot.Modules.Searches
|
||||
var channel = server?.GetTextChannel(fs.ChannelId);
|
||||
if (channel == null)
|
||||
return;
|
||||
|
||||
if (newStatus.IsLive)
|
||||
msg += "\n" + fs.GetLink();
|
||||
try { await channel.SendMessageAsync(msg).ConfigureAwait(false); } catch { }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user