This commit is contained in:
@@ -7,6 +7,7 @@ using Discord;
|
||||
using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
using DiscordBot.Discord.Core;
|
||||
using PluginManager;
|
||||
using PluginManager.Interfaces;
|
||||
using PluginManager.Others;
|
||||
using PluginManager.Others.Permissions;
|
||||
@@ -58,10 +59,9 @@ namespace DiscordBot.Discord.Commands
|
||||
var channel = message.Channel;
|
||||
try
|
||||
{
|
||||
|
||||
string content = message.Content;
|
||||
string[] data = content.Split(' ');
|
||||
string keyword = data[1];
|
||||
string content = message.Content;
|
||||
string[] data = content.Split(' ');
|
||||
string keyword = data[1];
|
||||
if (keyword.ToLower() == "help")
|
||||
{
|
||||
await channel.SendMessageAsync("set token [new value] -- set the value of the new token (require restart)");
|
||||
@@ -78,7 +78,8 @@ namespace DiscordBot.Discord.Commands
|
||||
await channel.SendMessageAsync("Invalid token !");
|
||||
return;
|
||||
}
|
||||
Functions.WriteToSettings("./Data/Resources/DiscordBotCore.data", "BOT_TOKEN", data[2], '\t');
|
||||
|
||||
Config.SetValue("token", data[2]);
|
||||
break;
|
||||
case "prefix":
|
||||
if (data.Length != 3)
|
||||
@@ -86,7 +87,8 @@ namespace DiscordBot.Discord.Commands
|
||||
await channel.SendMessageAsync("Invalid token !");
|
||||
return;
|
||||
}
|
||||
Functions.WriteToSettings("./Data/Resources/DiscordBotCore.data", "BOT_PREFIX", data[2], '\t');
|
||||
|
||||
Config.SetValue("token", data[2]);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
@@ -94,8 +96,9 @@ namespace DiscordBot.Discord.Commands
|
||||
|
||||
await channel.SendMessageAsync("Restart required ...");
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
await channel.SendMessageAsync("Unknown usage to this command !\nUsage: " + Usage);
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace DiscordBot.Discord.Core
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
Config.SaveDictionary();
|
||||
Config.SaveConfig();
|
||||
Thread.Sleep(10000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,18 +28,16 @@ namespace DiscordBot
|
||||
Directory.CreateDirectory("./Data/Languages");
|
||||
Directory.CreateDirectory("./Data/Plugins/Commands");
|
||||
Directory.CreateDirectory("./Data/Plugins/Events");
|
||||
if (File.Exists(Functions.dataFolder + "var.dat"))
|
||||
Config.LoadDictionary();
|
||||
else if (Config.GetValue("token") == null || Config.GetValue("token")?.Length != 70)
|
||||
Config.LoadConfig().Wait();
|
||||
if (!Config.ContainsKey("token") || Config.GetValue("token") == null || Config.GetValue("token")?.Length != 70)
|
||||
{
|
||||
Dictionary<string, string> d = new Dictionary<string, string>();
|
||||
while (true)
|
||||
{
|
||||
Console.WriteLine("Please insert your token");
|
||||
Console.Write("Token = ");
|
||||
string token = Console.ReadLine();
|
||||
if (token?.Length == 59 || token?.Length == 70)
|
||||
d.Add("token", token);
|
||||
Config.AddValueToVariables("token", token, true);
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Invalid token");
|
||||
@@ -53,13 +51,12 @@ namespace DiscordBot
|
||||
|
||||
if (prefix == ' ' || char.IsDigit(prefix)) continue;
|
||||
|
||||
d.Add("prefix", prefix.ToString());
|
||||
Config.AddValueToVariables("prefix", prefix.ToString(), false);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Config.AppendToDictionary(d);
|
||||
d.Clear();
|
||||
Config.SaveConfig();
|
||||
}
|
||||
|
||||
HandleInput(args).Wait();
|
||||
@@ -84,7 +81,7 @@ namespace DiscordBot
|
||||
if (loadPluginsOnStartup) consoleCommandsHandler.HandleCommand("lp");
|
||||
if (listPluginsAtStartup) consoleCommandsHandler.HandleCommand("listplugs");
|
||||
if (listLanguagAtStartup) consoleCommandsHandler.HandleCommand("listlang");
|
||||
Config.SaveDictionary();
|
||||
Config.SaveConfig();
|
||||
while (true)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
|
||||
Reference in New Issue
Block a user