public async Task LogAsync(LogMessage logMessage) { Discord.LogSeverity dSeverity = Discord.LogSeverity.Info; switch (logMessage.Severity) { case LogSeverity.Info: dSeverity = Discord.LogSeverity.Info; break; case LogSeverity.Warning: dSeverity = Discord.LogSeverity.Warning; break; case LogSeverity.Error: dSeverity = Discord.LogSeverity.Error; break; } await LogAsync(dSeverity, logMessage.Source, logMessage.Message); }
private void OnStarted() { _logger.LogInformation("OnStarted has been called."); Discord.LogSeverity logLevel = LogSeverity.Info; if (_config["LOGLEVEL"] == "DEBUG") { logLevel = LogSeverity.Debug; } else if (_config["LOGLEVEL"] == "WARNING") { logLevel = LogSeverity.Warning; } else if (_config["LOGLEVEL"] == "ERROR") { logLevel = LogSeverity.Error; } ConfigureEventGrid(); // Setup the Discord Client Configuration discordClient = new DiscordShardedClient(new DiscordSocketConfig { LogLevel = logLevel }); ConfigureEventHandlers(); discordClient.LoginAsync(Discord.TokenType.Bot, botToken).Wait(); discordClient.StartAsync().Wait(); }
private static SeverityLevel?ConvertLogSeverity(Discord.LogSeverity discordSeverity) { var dict = new Dictionary <Discord.LogSeverity, SeverityLevel>() { { Discord.LogSeverity.Critical, SeverityLevel.Critical }, // do not log Debug // { Discord.LogSeverity.Debug, SeverityLevel.Verbose }, { Discord.LogSeverity.Error, SeverityLevel.Error }, { Discord.LogSeverity.Info, SeverityLevel.Information }, { Discord.LogSeverity.Verbose, SeverityLevel.Verbose }, { Discord.LogSeverity.Warning, SeverityLevel.Warning }, }; if (dict.ContainsKey(discordSeverity)) { return(dict[discordSeverity]); } return(null); }
public async Task LogAsync(Discord.LogSeverity severity, string source, string message) { await _logAsync(new Discord.LogMessage(severity, source, message)); }