This commit is contained in:
@@ -5,7 +5,6 @@ using System;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using PluginManager;
|
using PluginManager;
|
||||||
using PluginManager.Others;
|
|
||||||
using static PluginManager.Others.Functions;
|
using static PluginManager.Others.Functions;
|
||||||
|
|
||||||
namespace DiscordBot.Discord.Core
|
namespace DiscordBot.Discord.Core
|
||||||
@@ -77,17 +76,6 @@ namespace DiscordBot.Discord.Core
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The method that stops the bot from running
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task ShutDown()
|
|
||||||
{
|
|
||||||
if (client == null) return;
|
|
||||||
await client.LogoutAsync();
|
|
||||||
await client.StopAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CommonTasks()
|
private void CommonTasks()
|
||||||
{
|
{
|
||||||
if (client == null) return;
|
if (client == null) return;
|
||||||
|
|||||||
@@ -6,6 +6,16 @@
|
|||||||
<Nullable>disable</Nullable>
|
<Nullable>disable</Nullable>
|
||||||
<ApplicationIcon />
|
<ApplicationIcon />
|
||||||
<StartupObject />
|
<StartupObject />
|
||||||
|
<SignAssembly>False</SignAssembly>
|
||||||
|
<IsPublishable>True</IsPublishable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
<DebugType>none</DebugType>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||||
|
<DebugType>none</DebugType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -50,9 +50,7 @@ namespace DiscordBot
|
|||||||
char prefix = Console.ReadLine()[0];
|
char prefix = Console.ReadLine()[0];
|
||||||
|
|
||||||
if (prefix == ' ' || char.IsDigit(prefix)) continue;
|
if (prefix == ' ' || char.IsDigit(prefix)) continue;
|
||||||
|
|
||||||
Config.AddValueToVariables("prefix", prefix.ToString(), false);
|
Config.AddValueToVariables("prefix", prefix.ToString(), false);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ namespace DiscordBotGUI
|
|||||||
string current_version = Config.GetValue("Version");
|
string current_version = Config.GetValue("Version");
|
||||||
if (current_version == null)
|
if (current_version == null)
|
||||||
if (!Config.SetValue("Version", "0"))
|
if (!Config.SetValue("Version", "0"))
|
||||||
Config.AddValueToVariables("Version", "0");
|
Config.AddValueToVariables("Version", "0", false);
|
||||||
string latest_version = (await ServerCom.ReadTextFromFile("https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Updates/Version"))[0];
|
string latest_version = (await ServerCom.ReadTextFromFile("https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Updates/Version"))[0];
|
||||||
_version = latest_version;
|
_version = latest_version;
|
||||||
if (current_version != latest_version) { return true; }
|
if (current_version != latest_version) { return true; }
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ namespace DiscordBotGUI
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Functions.WriteToSettings(Functions.dataFolder + "DiscordBotCore.data", "BOT_TOKEN", token, '=');
|
Config.SetValue("token", token);
|
||||||
Functions.WriteToSettings(Functions.dataFolder + "DiscordBotCore.data", "BOT_PREFIX", prefix, '=');
|
Config.SetValue("prefix", prefix);
|
||||||
RunDiscordBot(args);
|
RunDiscordBot(args);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ namespace PluginManager
|
|||||||
{
|
{
|
||||||
private static AppConfig appConfig = null;
|
private static AppConfig appConfig = null;
|
||||||
|
|
||||||
public static bool AddValueToVariables(string key, string value, bool isReadOnly)
|
public static bool AddValueToVariables(string key, string value, bool isProtected)
|
||||||
{
|
{
|
||||||
if (appConfig.ApplicationVariables.ContainsKey(key)) return false;
|
if (appConfig.ApplicationVariables.ContainsKey(key)) return false;
|
||||||
appConfig.ApplicationVariables.Add(key, value);
|
appConfig.ApplicationVariables.Add(key, value);
|
||||||
if (isReadOnly) appConfig.ProtectedKeyWords.Add(key);
|
if (isProtected) appConfig.ProtectedKeyWords.Add(key);
|
||||||
SaveConfig();
|
SaveConfig();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,6 @@ namespace PluginManager
|
|||||||
{
|
{
|
||||||
appConfig = await Functions.ConvertFromJson<AppConfig>(path);
|
appConfig = await Functions.ConvertFromJson<AppConfig>(path);
|
||||||
Functions.WriteLogFile($"Loaded {appConfig.ApplicationVariables.Keys.Count} application variables.\nLoaded {appConfig.ProtectedKeyWords.Count} readonly variables.");
|
Functions.WriteLogFile($"Loaded {appConfig.ApplicationVariables.Keys.Count} application variables.\nLoaded {appConfig.ProtectedKeyWords.Count} readonly variables.");
|
||||||
//Console.WriteLine($"Loaded {appConfig.ApplicationVariables.Count} application variables !");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
appConfig = new() { ApplicationVariables = new Dictionary<string, string>(), ProtectedKeyWords = new List<string>() };
|
appConfig = new() { ApplicationVariables = new Dictionary<string, string>(), ProtectedKeyWords = new List<string>() };
|
||||||
|
|||||||
Reference in New Issue
Block a user