Added exception throw when token or prefix not valid.

This commit is contained in:
Brett Hewitson 2021-12-17 16:41:48 +10:00
parent 4ad6e4a5e9
commit b6781e1291
3 changed files with 11 additions and 4 deletions

View file

@ -30,12 +30,17 @@ namespace ServerManagerTool.DiscordBot
public async Task StartAsync(LogLevel logLevel, string discordToken, string commandPrefix, string dataDirectory, bool allowAllBots, IEnumerable<string> botWhitelist, HandleCommandDelegate handleCommandCallback, HandleTranslationDelegate handleTranslationCallback, CancellationToken token)
{
if (string.IsNullOrWhiteSpace(commandPrefix) || string.IsNullOrWhiteSpace(discordToken) || handleTranslationCallback is null || handleCommandCallback is null)
if (string.IsNullOrWhiteSpace(discordToken))
{
return;
throw new Exception("#DiscordBot_MissingTokenError");
}
if (Started)
if (string.IsNullOrWhiteSpace(commandPrefix))
{
throw new Exception("#DiscordBot_MissingPrefixError");
}
if (Started || handleTranslationCallback is null || handleCommandCallback is null)
{
return;
}