Much better startup time on shared bot
This commit is contained in:
parent
02171b5765
commit
073b31d717
@ -36,7 +36,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
using (var uow = DbHandler.UnitOfWork())
|
using (var uow = DbHandler.UnitOfWork())
|
||||||
{
|
{
|
||||||
var configs = uow.GuildConfigs.GetAll();
|
var configs = NadekoBot.AllGuildConfigs;
|
||||||
GuildMuteRoles = new ConcurrentDictionary<ulong, string>(configs
|
GuildMuteRoles = new ConcurrentDictionary<ulong, string>(configs
|
||||||
.Where(c=>!string.IsNullOrWhiteSpace(c.MuteRoleName))
|
.Where(c=>!string.IsNullOrWhiteSpace(c.MuteRoleName))
|
||||||
.ToDictionary(c => c.GuildId, c => c.MuteRoleName));
|
.ToDictionary(c => c.GuildId, c => c.MuteRoleName));
|
||||||
|
@ -41,8 +41,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
|
|
||||||
using (var uow = DbHandler.UnitOfWork())
|
using (var uow = DbHandler.UnitOfWork())
|
||||||
{
|
{
|
||||||
GuildLogSettings = new ConcurrentDictionary<ulong, LogSetting>(uow.GuildConfigs
|
GuildLogSettings = new ConcurrentDictionary<ulong, LogSetting>(NadekoBot.AllGuildConfigs
|
||||||
.GetAll()
|
|
||||||
.ToDictionary(g => g.GuildId, g => g.LogSetting));
|
.ToDictionary(g => g.GuildId, g => g.LogSetting));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
using (var uow = DbHandler.UnitOfWork())
|
using (var uow = DbHandler.UnitOfWork())
|
||||||
{
|
{
|
||||||
voicePlusTextCache = new ConcurrentHashSet<ulong>(uow.GuildConfigs.GetAll().Where(g => g.VoicePlusTextEnabled).Select(g => g.GuildId));
|
voicePlusTextCache = new ConcurrentHashSet<ulong>(NadekoBot.AllGuildConfigs.Where(g => g.VoicePlusTextEnabled).Select(g => g.GuildId));
|
||||||
}
|
}
|
||||||
NadekoBot.Client.UserVoiceStateUpdated += UserUpdatedEventHandler;
|
NadekoBot.Client.UserVoiceStateUpdated += UserUpdatedEventHandler;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ namespace NadekoBot.Modules.Games
|
|||||||
{
|
{
|
||||||
var conf = uow.BotConfig.GetOrCreate();
|
var conf = uow.BotConfig.GetOrCreate();
|
||||||
var x =
|
var x =
|
||||||
generationChannels = new ConcurrentHashSet<ulong>(uow.GuildConfigs.GetAll()
|
generationChannels = new ConcurrentHashSet<ulong>(NadekoBot.AllGuildConfigs
|
||||||
.SelectMany(c => c.GenerateCurrencyChannelIds.Select(obj=>obj.ChannelId)));
|
.SelectMany(c => c.GenerateCurrencyChannelIds.Select(obj=>obj.ChannelId)));
|
||||||
chance = conf.CurrencyGenerationChance;
|
chance = conf.CurrencyGenerationChance;
|
||||||
cooldown = conf.CurrencyGenerationCooldown;
|
cooldown = conf.CurrencyGenerationCooldown;
|
||||||
|
@ -33,7 +33,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
using (var uow = DbHandler.UnitOfWork())
|
using (var uow = DbHandler.UnitOfWork())
|
||||||
{
|
{
|
||||||
var configs = uow.GuildConfigs.GetAll();
|
var configs = NadekoBot.AllGuildConfigs;
|
||||||
commandCooldowns = new ConcurrentDictionary<ulong, ConcurrentHashSet<CommandCooldown>>(configs.ToDictionary(k => k.GuildId, v => new ConcurrentHashSet<CommandCooldown>(v.CommandCooldowns)));
|
commandCooldowns = new ConcurrentDictionary<ulong, ConcurrentHashSet<CommandCooldown>>(configs.ToDictionary(k => k.GuildId, v => new ConcurrentHashSet<CommandCooldown>(v.CommandCooldowns)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
using (var uow = DbHandler.UnitOfWork())
|
using (var uow = DbHandler.UnitOfWork())
|
||||||
{
|
{
|
||||||
var guildConfigs = uow.GuildConfigs.GetAll();
|
var guildConfigs = NadekoBot.AllGuildConfigs;
|
||||||
|
|
||||||
InviteFilteringServers = new ConcurrentHashSet<ulong>(guildConfigs.Where(gc => gc.FilterInvites).Select(gc => gc.GuildId));
|
InviteFilteringServers = new ConcurrentHashSet<ulong>(guildConfigs.Where(gc => gc.FilterInvites).Select(gc => gc.GuildId));
|
||||||
InviteFilteringChannels = new ConcurrentHashSet<ulong>(guildConfigs.SelectMany(gc => gc.FilterInvitesChannelIds.Select(fci => fci.ChannelId)));
|
InviteFilteringChannels = new ConcurrentHashSet<ulong>(guildConfigs.SelectMany(gc => gc.FilterInvitesChannelIds.Select(fci => fci.ChannelId)));
|
||||||
|
@ -19,6 +19,7 @@ using Module = Discord.Commands.Module;
|
|||||||
using NadekoBot.TypeReaders;
|
using NadekoBot.TypeReaders;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using NadekoBot.Modules.Music;
|
using NadekoBot.Modules.Music;
|
||||||
|
using NadekoBot.Services.Database.Models;
|
||||||
|
|
||||||
namespace NadekoBot
|
namespace NadekoBot
|
||||||
{
|
{
|
||||||
@ -38,6 +39,16 @@ namespace NadekoBot
|
|||||||
public static ConcurrentDictionary<string, string> ModulePrefixes { get; private set; }
|
public static ConcurrentDictionary<string, string> ModulePrefixes { get; private set; }
|
||||||
public static bool Ready { get; private set; }
|
public static bool Ready { get; private set; }
|
||||||
|
|
||||||
|
public static IEnumerable<GuildConfig> AllGuildConfigs { get; }
|
||||||
|
|
||||||
|
static NadekoBot()
|
||||||
|
{
|
||||||
|
using (var uow = DbHandler.UnitOfWork())
|
||||||
|
{
|
||||||
|
AllGuildConfigs = uow.GuildConfigs.GetAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task RunAsync(string[] args)
|
public async Task RunAsync(string[] args)
|
||||||
{
|
{
|
||||||
SetupLogger();
|
SetupLogger();
|
||||||
|
@ -19,18 +19,19 @@ namespace NadekoBot.Services
|
|||||||
static DbHandler() { }
|
static DbHandler() { }
|
||||||
|
|
||||||
private DbHandler() {
|
private DbHandler() {
|
||||||
switch (NadekoBot.Credentials.Db.Type.ToUpperInvariant())
|
dbType = typeof(NadekoSqliteContext);
|
||||||
{
|
//switch (NadekoBot.Credentials.Db.Type.ToUpperInvariant())
|
||||||
case "SQLITE":
|
//{
|
||||||
dbType = typeof(NadekoSqliteContext);
|
// case "SQLITE":
|
||||||
break;
|
// dbType = typeof(NadekoSqliteContext);
|
||||||
//case "SQLSERVER":
|
// break;
|
||||||
// dbType = typeof(NadekoSqlServerContext);
|
// //case "SQLSERVER":
|
||||||
// break;
|
// // dbType = typeof(NadekoSqlServerContext);
|
||||||
default:
|
// // break;
|
||||||
break;
|
// default:
|
||||||
|
// break;
|
||||||
|
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
public NadekoContext GetDbContext() =>
|
public NadekoContext GetDbContext() =>
|
||||||
|
Loading…
Reference in New Issue
Block a user