Add --disable-gateway parameter to the run parameters to stop the bot from connecting to discord. Useful when working on the web-api
This commit is contained in:
parent
447c6d8042
commit
85d06b76e0
3 changed files with 18 additions and 10 deletions
|
@ -80,17 +80,20 @@ namespace Geekbot.Bot
|
||||||
var database = ConnectToDatabase();
|
var database = ConnectToDatabase();
|
||||||
_globalSettings = new GlobalSettings(database);
|
_globalSettings = new GlobalSettings(database);
|
||||||
|
|
||||||
logger.Information(LogSource.Geekbot, "Connecting to Discord");
|
if (!runParameters.DisableGateway)
|
||||||
SetupDiscordClient();
|
{
|
||||||
await Login();
|
logger.Information(LogSource.Geekbot, "Connecting to Discord");
|
||||||
_logger.Information(LogSource.Geekbot, $"Now Connected as {_client.CurrentUser.Username} to {_client.Guilds.Count} Servers");
|
SetupDiscordClient();
|
||||||
await _client.SetGameAsync(_globalSettings.GetKey("Game"));
|
await Login();
|
||||||
|
_logger.Information(LogSource.Geekbot, $"Now Connected as {_client.CurrentUser.Username} to {_client.Guilds.Count} Servers");
|
||||||
|
await _client.SetGameAsync(_globalSettings.GetKey("Game"));
|
||||||
|
}
|
||||||
|
|
||||||
RegisterSentry();
|
RegisterSentry();
|
||||||
|
|
||||||
_logger.Information(LogSource.Geekbot, "Loading Dependencies and Handlers");
|
_logger.Information(LogSource.Geekbot, "Loading Dependencies and Handlers");
|
||||||
RegisterDependencies();
|
RegisterDependencies();
|
||||||
await RegisterHandlers();
|
if (!runParameters.DisableGateway) await RegisterHandlers();
|
||||||
|
|
||||||
_logger.Information(LogSource.Api, "Starting Web API");
|
_logger.Information(LogSource.Api, "Starting Web API");
|
||||||
StartWebApi();
|
StartWebApi();
|
||||||
|
@ -187,9 +190,9 @@ namespace Geekbot.Bot
|
||||||
services.AddSingleton<IDiceParser>(diceParser);
|
services.AddSingleton<IDiceParser>(diceParser);
|
||||||
services.AddSingleton<IReactionListener>(_reactionListener);
|
services.AddSingleton<IReactionListener>(_reactionListener);
|
||||||
services.AddSingleton<IGuildSettingsManager>(_guildSettingsManager);
|
services.AddSingleton<IGuildSettingsManager>(_guildSettingsManager);
|
||||||
services.AddSingleton(_client);
|
|
||||||
services.AddTransient<IHighscoreManager>(e => new HighscoreManager(_databaseInitializer.Initialize(), _userRepository));
|
services.AddTransient<IHighscoreManager>(e => new HighscoreManager(_databaseInitializer.Initialize(), _userRepository));
|
||||||
services.AddTransient(e => _databaseInitializer.Initialize());
|
services.AddTransient(e => _databaseInitializer.Initialize());
|
||||||
|
if (!_runParameters.DisableGateway) services.AddSingleton(_client);
|
||||||
|
|
||||||
_servicesProvider = services.BuildServiceProvider();
|
_servicesProvider = services.BuildServiceProvider();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,9 @@ namespace Geekbot.Core
|
||||||
[Option('e', "expose-errors", HelpText = "Shows internal errors in the chat (default: false) (env: EXPOSE_ERRORS)")]
|
[Option('e', "expose-errors", HelpText = "Shows internal errors in the chat (default: false) (env: EXPOSE_ERRORS)")]
|
||||||
public bool ExposeErrors { get; set; } = ParamFallback("EXPOSE_ERRORS", false);
|
public bool ExposeErrors { get; set; } = ParamFallback("EXPOSE_ERRORS", false);
|
||||||
|
|
||||||
|
[Option("disable-gateway", HelpText = "Disables the Discord Gateway (default: false) (env: GATEWAY_DISABLE)")]
|
||||||
|
public bool DisableGateway { get; set; } = ParamFallback("GATEWAY_DISABLE", false);
|
||||||
|
|
||||||
/************************************
|
/************************************
|
||||||
* Database *
|
* Database *
|
||||||
************************************/
|
************************************/
|
||||||
|
|
|
@ -38,11 +38,13 @@ namespace Geekbot.Web
|
||||||
builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
|
builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
|
||||||
});
|
});
|
||||||
|
|
||||||
services.AddSingleton(commandService);
|
|
||||||
services.AddSingleton(databaseContext);
|
services.AddSingleton(databaseContext);
|
||||||
services.AddSingleton(client);
|
|
||||||
services.AddSingleton(globalSettings);
|
services.AddSingleton(globalSettings);
|
||||||
services.AddSingleton(highscoreManager);
|
services.AddSingleton(highscoreManager);
|
||||||
|
|
||||||
|
if (runParameters.DisableGateway) return;
|
||||||
|
services.AddSingleton(commandService);
|
||||||
|
services.AddSingleton(client);
|
||||||
})
|
})
|
||||||
.Configure(app =>
|
.Configure(app =>
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue