public static async Task Setgame(SocketMessage message, string[] arg, string msg) { if (RoleUtils.IsUserBotAdmin(message.Author.Id)) { try { if (arg.Count() > 1) { string game = msg.Substring(8); await Program.client.SetGameAsync(game); ConfigUtils.Configuration.Playing = game; ConfigUtils.Save(@"resources\config\config.json"); await message.Channel.SendMessageAsync($":white_check_mark: `The game is now '{game}'`"); } else { await Program.client.SetGameAsync(""); ConfigUtils.Configuration.Playing = ""; ConfigUtils.Save(@"resources\config\config.json"); await message.Channel.SendMessageAsync($":white_check_mark: `The game has been reset !`"); } } catch (Exception ex) { Logger.WriteLine($"Error: {ex.Message}", ConsoleColor.Red); } } else { await message.Channel.SendMessageAsync($":no_entry: `Your KD is too low to execute this command...`"); } }
public static async Task Setprefix(SocketMessage message, string[] arg, string msg) { if (RoleUtils.IsUserBotAdmin(message.Author.Id)) { try { if (arg.Count() > 1) { string prefix = msg.Substring(10); ConfigUtils.Configuration.Prefix = prefix; ConfigUtils.Save(@"resources\config\config.json"); await message.Channel.SendMessageAsync($":white_check_mark: `The prefix is now '{prefix}'`"); } else { ConfigUtils.Configuration.Prefix = ConfigUtils.DEFAULT_PREFIX; ConfigUtils.Save(@"resources\config\config.json"); await message.Channel.SendMessageAsync($":white_check_mark: `The prefix has been reset.`"); } } catch { await message.Channel.SendMessageAsync($":no_entry: `Could not change the dank prefix :/`"); } } else { await message.Channel.SendMessageAsync($":no_entry: `Your KD is too low to execute this command...`"); } }
public static async Task Reset(SocketMessage message, string[] arg, string msg) { if (RoleUtils.IsUserBotAdmin(message.Author.Id)) { try { ConfigUtils.SetDefaults(); ConfigUtils.Save(@"resources\config\config.json"); await message.Channel.SendMessageAsync($":white_check_mark: `The configuration has been reset`"); } catch { await message.Channel.SendMessageAsync($":no_entry: `Could not reload the configuration :/`"); } } else { await message.Channel.SendMessageAsync($":no_entry: `Your KD is too low to execute this command...`"); } }
static async Task BotMain() { Logger.WriteLine("Welcome to DankBot !"); if (!Directory.Exists(@"resources\config\")) { Directory.CreateDirectory(@"resources\config\"); } if (!Directory.Exists(@"cache")) { Directory.CreateDirectory(@"cache"); } if (!File.Exists(@"resources\config\config.json")) { Logger.Write("Generating configuration... "); try { ConfigUtils.SetDefaults(); ConfigUtils.Save(@"resources\config\config.json"); Logger.OK(); } catch { Logger.FAILED(); Panic("Could not generate configuration file !"); } } Logger.Write("Loading configuration... "); try { ConfigUtils.Load(@"resources\config\config.json"); Logger.OK(); } catch (Exception ex) { Logger.FAILED(); Panic(ex.Message); } Logger.Write("Starting discord client... "); try { await client.LoginAsync(ConfigUtils.Configuration.TokenType, ConfigUtils.Configuration.BotToken); await client.StartAsync(); await client.SetStatusAsync(UserStatus.Online); await client.SetGameAsync(ConfigUtils.Configuration.Playing); Logger.OK(); } catch (Exception ex) { Logger.FAILED(); Panic(ex.Message); } Logger.Write("Loading resources... "); try { ResourceCache.Load(); Logger.OK(); } catch (Exception ex) { Logger.FAILED(); Panic(ex.Message); } Logger.Write("Starting message handler... "); try { CommandManager.LoadCommands(); client.MessageReceived += CommandManager.MessageReceived; Logger.OK(); } catch (Exception ex) { Logger.FAILED(); Panic(ex.Message); } Logger.Write("Enabling audio player... "); try { Playlist.Enable(); Logger.OK(); } catch (Exception ex) { Logger.FAILED(); Panic(ex.Message); } Logger.WriteLine("Ready.", ConsoleColor.Green); while (true) { Thread.Sleep(1000); } }