public async Task OnShardReadyAsync(ShardReadyEventArgs args) { var guilds = args.Shard.Guilds.Count; var users = args.Shard.Guilds.SelectMany(x => x.Users).DistinctBy(x => x.Id).Count(); var channels = args.Shard.Guilds.SelectMany(x => x.Channels).DistinctBy(x => x.Id).Count(); _logger.PrintVersion(); _logger.Info(LogSource.Volte, "Use this URL to invite me to your guilds:"); _logger.Info(LogSource.Volte, $"{args.Shard.GetInviteUrl()}"); _logger.Info(LogSource.Volte, $"Logged in as {args.Shard.CurrentUser}, shard {args.Shard.ShardId}"); _logger.Info(LogSource.Volte, $"Default command prefix is: \"{Config.CommandPrefix}\""); _logger.Info(LogSource.Volte, "Connected to:"); _logger.Info(LogSource.Volte, $" {"guild".ToQuantity(guilds)}"); _logger.Info(LogSource.Volte, $" {"user".ToQuantity(users)}"); _logger.Info(LogSource.Volte, $" {"channel".ToQuantity(channels)}"); if (!_shouldStream) { if (_shouldSetGame) { await args.Shard.SetGameAsync(Config.Game); _logger.Info(LogSource.Volte, $"Set {args.Shard.CurrentUser.Username}'s game to \"{Config.Game}\"."); } } else { await args.Shard.SetGameAsync(Config.Game, Config.FormattedStreamUrl, ActivityType.Streaming); _logger.Info(LogSource.Volte, $"Set {args.Shard.CurrentUser.Username}'s activity to \"{ActivityType.Streaming}: {Config.Game}\", at Twitch user {Config.Streamer}."); } _ = Task.Run(async() => { foreach (var guild in args.Shard.Guilds) { if (Config.BlacklistedOwners.Contains(guild.OwnerId)) { _logger.Warn(LogSource.Volte, $"Left guild \"{guild.Name}\" owned by blacklisted owner {guild.Owner}."); await guild.LeaveAsync(); } _ = _db.GetData(guild); //ensuring all guilds have data available to prevent exceptions later on } }); if (Config.GuildLogging.EnsureValidConfiguration(args.Client, out var channel)) { await new EmbedBuilder() .WithSuccessColor() .WithAuthor(args.Client.GetOwner()) .WithDescription( $"Volte {Version.FullVersion} is starting at **{DateTimeOffset.UtcNow.FormatFullTime()}, on {DateTimeOffset.UtcNow.FormatDate()}**!") .SendToAsync(channel); } }
private Task ShardReadyAsync(ShardReadyEventArgs e) { _shardsReady.AddOrUpdate(e.SessionId, true, (shardKey, value) => true); if (_shardsReady.Count == RiasBot.Shards.Count && _shardsReady.All(x => x.Value)) { RiasBot.ShardReady -= ShardReadyAsync; Log.Information("All shards are connected"); RiasBot.GetRequiredService <MuteService>(); var reactionsService = RiasBot.GetRequiredService <ReactionsService>(); reactionsService.WeebUserAgent = $"{RiasBot.CurrentUser.Name}/{Rias.Version}"; reactionsService.AddWeebUserAgent(); } return(Task.CompletedTask); }