public static void Log(LogSeverity severity, string source, string message) { PrettyConsole.NewLine($"{DateTimeOffset.Now.ToString("hh:mm:ss")} ", ConsoleColor.DarkGray); PrettyConsole.Append($"[{severity}] ", ConsoleColor.Red); PrettyConsole.Append($"{source}: ", ConsoleColor.DarkGreen); PrettyConsole.Append(message, ConsoleColor.White); }
public async Task RunAsync(params string[] args) { PrettyConsole.NewLine("=== DEA ==="); PrettyConsole.NewLine(); Client = new DiscordSocketClient(new DiscordSocketConfig() { LogLevel = LogSeverity.Error, MessageCacheSize = 10, TotalShards = Credentials.ShardCount, //AlwaysDownloadUsers = true, }); Client.Log += (l) => Task.Run(() => PrettyConsole.Log(l.Severity, l.Source, l.Exception?.ToString() ?? l.Message)); CommandService = new CommandService(new CommandServiceConfig() { CaseSensitiveCommands = false, DefaultRunMode = RunMode.Sync }); var sw = Stopwatch.StartNew(); //Connection await Client.LoginAsync(TokenType.Bot, Credentials.Token).ConfigureAwait(false); await Client.StartAsync().ConfigureAwait(false); //await Client.DownloadAllUsersAsync().ConfigureAwait(false); sw.Stop(); PrettyConsole.Log(LogSeverity.Info, "Successfully connected", $"Elapsed time: {sw.Elapsed.TotalSeconds.ToString()} seconds."); var Map = new DependencyMap(); ConfigureServices(Map); await new MessageRecieved().InitializeAsync(Client, Map); new Ready(Client); PrettyConsole.Log(LogSeverity.Info, "Events and mapping successfully initialized", $"Client ready."); using (var db = new DEAContext()) { await db.Database.EnsureCreatedAsync(); } PrettyConsole.Log(LogSeverity.Info, "Database creation ensured", $"Ready for use."); }
public static void Log(CommandContext c) { var channel = (c.Channel as SocketGuildChannel); PrettyConsole.NewLine($"{DateTimeOffset.Now.ToString("hh:mm:ss")} ", ConsoleColor.Gray); if (channel == null) { PrettyConsole.Append($"[PM] ", ConsoleColor.Magenta); } else { PrettyConsole.Append($"[{c.Guild.Name} #{channel.Name}] ", ConsoleColor.DarkGreen); } PrettyConsole.Append($"{c.User}: ", ConsoleColor.Green); PrettyConsole.Append(c.Message.Content, ConsoleColor.White); }
public static void Log(IUserMessage msg) { var channel = (msg.Channel as IGuildChannel); PrettyConsole.NewLine($"{DateTimeOffset.Now.ToString("hh:mm:ss")} ", ConsoleColor.Gray); if (channel?.Guild == null) { PrettyConsole.Append($"[PM] ", ConsoleColor.Magenta); } else { PrettyConsole.Append($"[{channel.Guild.Name} #{channel.Name}] ", ConsoleColor.DarkGreen); } PrettyConsole.Append($"{msg.Author}: ", ConsoleColor.Green); PrettyConsole.Append(msg.Content, ConsoleColor.White); }
public async Task Start() { PrettyConsole.NewLine("=== DEA ==="); PrettyConsole.NewLine(); using (var db = new DbContext()) { db.Database.EnsureCreated(); } _client = new DiscordSocketClient(new DiscordSocketConfig() { LogLevel = LogSeverity.Error, AlwaysDownloadUsers = true, MessageCacheSize = 10000 }); _client.Log += (l) => Task.Run(() => PrettyConsole.Log(l.Severity, l.Source, l.Exception?.ToString() ?? l.Message)); await _client.LoginAsync(TokenType.Bot, Token.TOKEN); await _client.StartAsync(); var map = new DependencyMap(); ConfigureServices(map); await new MessageRecieved().InitializeAsync(_client, map); new Ready(_client); new UserEvents(_client); new RoleEvents(_client); new ChannelEvents(_client); new RecurringFunctions(_client); await Task.Delay(-1); }