mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
Added exception throw when token or prefix not valid.
This commit is contained in:
parent
4ad6e4a5e9
commit
b6781e1291
3 changed files with 11 additions and 4 deletions
|
|
@ -5615,7 +5615,8 @@
|
|||
|
||||
<!--#region Discord Bot -->
|
||||
<sys:String x:Key="DiscordBot_ErrorTitle">Discord Bot Error</sys:String>
|
||||
<sys:String x:Key="DiscordBot_MissingTokenError">The discord bot requires a valid token so it can log into the discord server\r\nThis can be set in the global settings.</sys:String>
|
||||
<sys:String x:Key="DiscordBot_MissingTokenError">The discord bot requires a valid token so it can log into the discord server.\r\nThis can be set in the global settings.</sys:String>
|
||||
<sys:String x:Key="DiscordBot_MissingPrefixError">The discord bot requires a valid prefix.\r\nThis can be set in the global settings.</sys:String>
|
||||
<sys:String x:Key="DiscordBot_InvalidPrefixError">The discord bot prefix contains invalid characters. Only letters and numbers are allowed.</sys:String>
|
||||
|
||||
<sys:String x:Key="DiscordBot_CommandNotEnabled">Command '{0}' has not been enabled.</sys:String>
|
||||
|
|
|
|||
|
|
@ -1263,6 +1263,7 @@
|
|||
<!--#region Discord Bot -->
|
||||
<sys:String x:Key="DiscordBot_ErrorTitle">Discord Bot Error</sys:String>
|
||||
<sys:String x:Key="DiscordBot_MissingTokenError">The discord bot requires a valid token so it can log into the discord server\r\nThis can be set in the global settings.</sys:String>
|
||||
<sys:String x:Key="DiscordBot_MissingPrefixError">The discord bot requires a valid prefix.\r\nThis can be set in the global settings.</sys:String>
|
||||
<sys:String x:Key="DiscordBot_InvalidPrefixError">The discord bot prefix contains invalid characters. Only letters and numbers are allowed.</sys:String>
|
||||
|
||||
<sys:String x:Key="DiscordBot_CommandNotEnabled">Command '{0}' has not been enabled.</sys:String>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue