Restart functions updated
This commit is contained in:
@@ -37,29 +37,52 @@ namespace DiscordBot.Discord.Commands
|
||||
{
|
||||
if (!DiscordPermissions.hasPermission(message.Author as SocketGuildUser, ds.GuildPermission.Administrator)) return;
|
||||
var args = Functions.GetArguments(message);
|
||||
if (args.Count != 0)
|
||||
var OS = Functions.GetOperatinSystem();
|
||||
if (args.Count == 0)
|
||||
{
|
||||
switch (args[0])
|
||||
switch (OS)
|
||||
{
|
||||
case "-p":
|
||||
case "-poweroff":
|
||||
case "-c":
|
||||
case "-close":
|
||||
Environment.Exit(0);
|
||||
case PluginManager.Others.OperatingSystem.WINDOWS:
|
||||
Process.Start("./DiscordBot.exe");
|
||||
break;
|
||||
case "-cmd":
|
||||
case "-args":
|
||||
Process.Start("./DiscordBot.exe", Functions.MergeStrings(args.ToArray(), 1));
|
||||
Environment.Exit(0);
|
||||
case PluginManager.Others.OperatingSystem.LINUX:
|
||||
case PluginManager.Others.OperatingSystem.MAC_OS:
|
||||
Process.Start("./DiscordBot");
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
switch (args[0])
|
||||
{
|
||||
case "-p":
|
||||
case "-poweroff":
|
||||
case "-c":
|
||||
case "-close":
|
||||
Environment.Exit(0);
|
||||
break;
|
||||
case "-cmd":
|
||||
case "-args":
|
||||
|
||||
switch (OS)
|
||||
{
|
||||
case PluginManager.Others.OperatingSystem.WINDOWS:
|
||||
Process.Start("./DiscordBot.exe", Functions.MergeStrings(args.ToArray(), 1));
|
||||
break;
|
||||
case PluginManager.Others.OperatingSystem.LINUX:
|
||||
case PluginManager.Others.OperatingSystem.MAC_OS:
|
||||
Process.Start("./DiscordBot", Functions.MergeStrings(args.ToArray(), 1));
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
Environment.Exit(0);
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
Process.Start("./DiscordBot.exe", "--execute:lp");
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ using PluginManager.LanguageSystem;
|
||||
using PluginManager.Online;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DiscordBot
|
||||
{
|
||||
@@ -20,6 +21,8 @@ namespace DiscordBot
|
||||
private static LanguageManager languageManager = new LanguageManager("https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Languages");
|
||||
|
||||
private static bool loadPluginsOnStartup = false;
|
||||
private static bool listPluginsAtStartup = false;
|
||||
private static bool listLanguagAtStartup = false;
|
||||
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
@@ -76,6 +79,10 @@ namespace DiscordBot
|
||||
LoadLanguage();
|
||||
if (loadPluginsOnStartup)
|
||||
LoadPlugins(discordbooter);
|
||||
if (listPluginsAtStartup)
|
||||
await manager.ListAvailablePlugins();
|
||||
if (listLanguagAtStartup)
|
||||
await languageManager.ListAllLanguages();
|
||||
while (true)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
@@ -97,9 +104,10 @@ namespace DiscordBot
|
||||
Console.WriteLine("This command is for windows users ONLY");
|
||||
break;
|
||||
}
|
||||
Process.Start("./DiscordBot.exe", "--cmd lp");
|
||||
if (discordbooter.client.ConnectionState == ConnectionState.Connected)
|
||||
await discordbooter.ShutDown();
|
||||
Process.Start("./DiscordBot", "--execute:lp");
|
||||
else Environment.Exit(0);
|
||||
break;
|
||||
case "listplugs":
|
||||
await manager.ListAvailablePlugins();
|
||||
@@ -404,15 +412,20 @@ namespace DiscordBot
|
||||
return;
|
||||
}
|
||||
|
||||
if (len == 1 && args[0] == "--execute:lp")
|
||||
if (len > 0 && args.Contains("--cmd"))
|
||||
{
|
||||
loadPluginsOnStartup = true;
|
||||
if (args.Contains("lp") || args.Contains("loadplugins"))
|
||||
loadPluginsOnStartup = true;
|
||||
if (args.Contains("listplugs"))
|
||||
listPluginsAtStartup = true;
|
||||
if (args.Contains("listlang"))
|
||||
listLanguagAtStartup = true;
|
||||
|
||||
len = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (len == 0 || args[0] != "--exec" && args[0] != "--execute")
|
||||
{
|
||||
Boot b = await StartNoGUI();
|
||||
|
||||
@@ -39,5 +39,6 @@ namespace PluginManager.Items
|
||||
this.PrefixUsed = data[0][0];
|
||||
else this.PrefixUsed = '\0'; //null
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user