示例#1
0
        /// <summary>
        /// Handler for when a shard has connected.
        /// </summary>
        /// <param name="shard">The shard which is ready.</param>
        /// <returns>When the task has completed.</returns>
        private static Task ProcessShardConnected(DiscordSocketClient shard)
        {
            Logger.LogInformation("Shard connected;{{shardId:{shardId}}}", shard.ShardId);

            // Process any guild tasks that were waiting for the shard connection
            foreach (var guild in shard.Guilds)
            {
                // Begin the member download for any guilds that don't have all of the members downloaded
                if (!guild.HasAllMembers)
                {
                    var ignoreAwait = ChillBotService.BeginMembersDownload(guild);
                }
            }

            return(Task.CompletedTask);
        }
示例#2
0
        /// <summary>
        /// Forwards all client logs to the console.
        /// </summary>
        /// <param name="log">The client log.</param>
        /// <returns>When the task has completed.</returns>
        private static Task ForwardLogToLogging(Discord.LogMessage log)
        {
            var logCategory   = ChillBotService.DiscordLogSourceCategoryCache.GetOrAdd(log.Source, (source) => $"{nameof(Discord)}.{source}");
            var discordLogger = LogManager.GetLogger(logCategory);

            if (ChillBotService.IsDiscordReconnect(log))
            {
                discordLogger.Log(
                    LogLevel.Information,
                    "Client log - Client reconnect;{{exceptionType:{exceptionType}}}",
                    log.Exception?.GetType());
            }
            else
            {
                discordLogger.Log(
                    log.Severity.ToLogLevel(),
                    log.Exception,
                    "Client log - {logMessage}",
                    log.Message ?? string.Empty);
            }

            return(Task.CompletedTask);
        }