private static void ResetHelpModulesCmd() { HelpModulesManager.ResetHelpModulesToDefault(); HelpModulesManager.SaveHelpModules(); Logger.Log("The help modules were reset to their defaults."); }
public async Task HelpCmd() { try { StringBuilder builder = new StringBuilder(); List <string> existingCommands = new List <string>(); builder.Append( $"```# Pootis-Bot Normal Commands```\nFor more help on a specific command do `{Global.BotPrefix}help [command]`.\n"); //Basic Commands foreach (HelpModule helpModule in HelpModulesManager.GetHelpModules()) { builder.Append($"\n**{helpModule.Group}** - "); foreach (CommandInfo command in helpModule.Modules.SelectMany(module => DiscordModuleManager.GetModule(module).Commands)) { if (existingCommands.Contains(command.Name)) { continue; } builder.Append($"`{command.Name}` "); existingCommands.Add(command.Name); } } await Context.Channel.SendMessageAsync(builder.ToString()); } catch (NullReferenceException) { await Context.Channel.SendMessageAsync( $"Sorry, but it looks like the bot owner doesn't have the help options configured correctly.\nVisit {Global.websiteCommands} for command list."); Logger.Log("The help options are configured incorrectly!", LogVerbosity.Error); } }
/// <summary> /// Starts the bot /// </summary> /// <returns></returns> public async Task StartBot() { IsStreaming = false; IsRunning = true; Global.BotStatusText = Config.bot.DefaultGameMessage; //Make sure the token isn't null or empty, if so open the bot config menu. if (string.IsNullOrEmpty(Global.BotToken)) { new ConfigMainMenu().OpenConfigMenu(); } Logger.Debug("Creating new Discord client..."); Client = new DiscordSocketClient(new DiscordSocketConfig { LogLevel = LogSeverity.Verbose }); Logger.Debug("Setting up events"); //Setup client events Client.Log += Log; Client.Ready += BotReady; //Setup the remaining events EventsSetup unused = new EventsSetup(Client); Logger.Debug("Signing in using token..."); try { await Client.LoginAsync(TokenType.Bot, Global.BotToken); //Logging into the bot using the token in the config. } catch (Discord.Net.HttpException) { Logger.Error("The supplied token was invalid!"); await EndBot(); Environment.Exit(0); return; } catch (HttpRequestException) { Logger.Error("There was an error connecting to Discord! This may be because Discord API is down, or there is no internet connection."); await EndBot(); Environment.Exit(0); return; } await Client.StartAsync(); //Start the client Logger.Debug("Sign in successful!"); CommandHandler handler = new CommandHandler(Client); Logger.Debug("Installing commands..."); //Install all the Modules await handler.SetupCommandHandlingAsync(); //Check all help modules HelpModulesManager.CheckHelpModules(); //Bot owner Global.BotOwner = (await Client.GetApplicationInfoAsync()).Owner; Logger.Debug($"The owner of this bot is {Global.BotOwner}"); //Enable the Steam services if an api key is provided if (!string.IsNullOrWhiteSpace(Config.bot.Apis.ApiSteamKey)) { SteamService.SetupSteam(); } //Set the bot status to the default game status await Client.SetGameAsync(Config.bot.DefaultGameMessage); //Starts the check connection status task, which will run indefinitely until the bot is stopped. await CheckConnectionStatusTask(); }
/// <summary> /// Starts the bot /// </summary> /// <returns></returns> public async Task StartBot() { IsStreaming = false; IsRunning = true; Global.BotStatusText = Config.bot.DefaultGameMessage; //Make sure the token isn't null or empty, if so open the bot config menu. if (string.IsNullOrEmpty(Global.BotToken)) { new ConfigMenu().OpenConfig(true); } Logger.Log("Creating new client...", LogVerbosity.Debug); _client = new DiscordSocketClient(new DiscordSocketConfig { LogLevel = LogSeverity.Verbose }); Logger.Log("Setting up events", LogVerbosity.Debug); //Setup client events _client.Log += Log; _client.Ready += BotReady; //Setup the remaining events EventsSetup unused = new EventsSetup(_client); Logger.Log("Signing in using token...", LogVerbosity.Debug); await _client.LoginAsync(TokenType.Bot, Global.BotToken); //Logging into the bot using the token in the config. await _client.StartAsync(); //Start the client Logger.Log("Sign in successful!", LogVerbosity.Debug); CommandHandler handler = new CommandHandler(_client); Logger.Log("Installing commands...", LogVerbosity.Debug); //Install all the Modules await handler.SetupCommandHandlingAsync(); //Check all help modules HelpModulesManager.CheckHelpModules(); //Bot owner Global.BotOwner = (await _client.GetApplicationInfoAsync()).Owner; Logger.Log($"The owner of this bot is {Global.BotOwner}", LogVerbosity.Debug); //Enable the Steam services if an api key is provided if (!string.IsNullOrWhiteSpace(Config.bot.Apis.ApiSteamKey)) { SteamService.SetupSteam(); } //Set the bot status to the default game status await _client.SetGameAsync(Config.bot.DefaultGameMessage); await CheckConnectionStatus(); }