Clash of clans crashfix
This commit is contained in:
		| @@ -25,13 +25,16 @@ namespace NadekoBot.Modules.ClashOfClans | ||||
|             { | ||||
|                 ClashWars = new ConcurrentDictionary<ulong, List<ClashWar>>( | ||||
|                     uow.ClashOfClans | ||||
|                         .GetAll() | ||||
|                         .GetAllWars() | ||||
|                         .Select(cw => { | ||||
|                             if (cw == null || cw.Bases == null) | ||||
|                                 return null; | ||||
|                             cw.Channel = NadekoBot.Client.GetGuild(cw.GuildId) | ||||
|                                                          ?.GetTextChannel(cw.ChannelId); | ||||
|                             cw.Bases.Capacity = cw.Size; | ||||
|                             return cw; | ||||
|                         }) | ||||
|                         .Where(cw => cw?.Channel != null) | ||||
|                         .GroupBy(cw => cw.GuildId) | ||||
|                         .ToDictionary(g => g.Key, g => g.ToList())); | ||||
|             } | ||||
|   | ||||
| @@ -36,6 +36,7 @@ namespace NadekoBot | ||||
|         public static StatsService Stats { get; private set; } | ||||
|  | ||||
|         public static ConcurrentDictionary<string, string> ModulePrefixes { get; private set; } | ||||
|         public static bool Ready { get; private set; } | ||||
|  | ||||
|         public async Task RunAsync(string[] args) | ||||
|         { | ||||
| @@ -97,6 +98,7 @@ namespace NadekoBot | ||||
| #if !GLOBAL_NADEKO | ||||
|             await CommandService.Load(new Music(Localizer, CommandService, Client, Google)).ConfigureAwait(false); | ||||
| #endif | ||||
|             Ready = true; | ||||
|             Console.WriteLine(await Stats.Print().ConfigureAwait(false)); | ||||
|  | ||||
|             await Task.Delay(-1); | ||||
|   | ||||
| @@ -72,7 +72,7 @@ namespace NadekoBot.Services | ||||
|             if (usrMsg == null) | ||||
|                 return; | ||||
|  | ||||
|             if (usrMsg.Author.IsBot) //no bots | ||||
|             if (usrMsg.Author.IsBot || !NadekoBot.Ready) //no bots | ||||
|                 return; | ||||
|  | ||||
|             var guild = (msg.Channel as ITextChannel)?.Guild; | ||||
|   | ||||
| @@ -9,6 +9,6 @@ namespace NadekoBot.Services.Database.Repositories | ||||
| { | ||||
|     public interface IClashOfClansRepository : IRepository<ClashWar> | ||||
|     { | ||||
|          | ||||
|         IEnumerable<ClashWar> GetAllWars(); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -13,5 +13,11 @@ namespace NadekoBot.Services.Database.Repositories.Impl | ||||
|         public ClashOfClansRepository(DbContext context) : base(context) | ||||
|         { | ||||
|         } | ||||
|  | ||||
|         public IEnumerable<ClashWar> GetAllWars() | ||||
|         { | ||||
|             return _set.Include(cw => cw.Bases) | ||||
|                         .ToList(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user