patch
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
using PluginManager;
|
||||
using PluginManager.Interfaces;
|
||||
using PluginManager.Others;
|
||||
|
||||
using DiscordLibCommands = Discord.Commands;
|
||||
using DiscordLib = Discord;
|
||||
using OperatingSystem = PluginManager.Others.OperatingSystem;
|
||||
|
||||
namespace DiscordBot.Discord.Commands;
|
||||
@@ -40,7 +42,7 @@ internal class Restart : DBCommand
|
||||
public async void ExecuteServer(DiscordLibCommands.SocketCommandContext context)
|
||||
{
|
||||
var args = Functions.GetArguments(context.Message);
|
||||
var OS = Functions.GetOperatingSystem();
|
||||
var OS = Functions.GetOperatingSystem();
|
||||
if (args.Count == 0)
|
||||
{
|
||||
switch (OS)
|
||||
@@ -79,7 +81,7 @@ internal class Restart : DBCommand
|
||||
switch (OS)
|
||||
{
|
||||
case OperatingSystem.WINDOWS:
|
||||
Functions.WriteLogFile("Restarting the bot with the following arguments: \"" + cmd + "\"");
|
||||
Logger.WriteLogFile("Restarting the bot with the following arguments: \"" + cmd + "\"");
|
||||
Process.Start("./DiscordBot.exe", cmd);
|
||||
break;
|
||||
case OperatingSystem.LINUX:
|
||||
|
||||
@@ -5,7 +5,7 @@ using Discord;
|
||||
using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
|
||||
using static PluginManager.Others.Functions;
|
||||
using PluginManager;
|
||||
|
||||
namespace DiscordBot.Discord.Core;
|
||||
|
||||
@@ -98,7 +98,7 @@ internal class Boot
|
||||
|
||||
private async Task Client_LoggedOut()
|
||||
{
|
||||
WriteLogFile("Successfully Logged Out");
|
||||
Logger.WriteLine("Successfully Logged Out");
|
||||
await Log(new LogMessage(LogSeverity.Info, "Boot", "Successfully logged out from discord !"));
|
||||
|
||||
/* var cmds = await client.GetGlobalApplicationCommandsAsync();
|
||||
@@ -117,7 +117,7 @@ internal class Boot
|
||||
private Task LoggedIn()
|
||||
{
|
||||
Console.Title = "CONNECTED";
|
||||
WriteLogFile("The bot has been logged in at " + DateTime.Now.ToShortDateString() + " (" +
|
||||
Logger.WriteLine("The bot has been logged in at " + DateTime.Now.ToShortDateString() + " (" +
|
||||
DateTime.Now.ToShortTimeString() + ")"
|
||||
);
|
||||
return Task.CompletedTask;
|
||||
@@ -129,7 +129,7 @@ internal class Boot
|
||||
{
|
||||
case LogSeverity.Error:
|
||||
case LogSeverity.Critical:
|
||||
WriteErrFile(message.Message);
|
||||
Logger.WriteErrFile(message.Message);
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine("[ERROR] " + message.Message);
|
||||
@@ -139,7 +139,7 @@ internal class Boot
|
||||
|
||||
case LogSeverity.Info:
|
||||
case LogSeverity.Debug:
|
||||
WriteLogFile(message.Message);
|
||||
Logger.WriteLogFile(message.Message);
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||
Console.WriteLine("[INFO] " + message.Message);
|
||||
|
||||
@@ -7,9 +7,10 @@ using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
|
||||
using PluginManager.Loaders;
|
||||
using PluginManager.Others;
|
||||
using PluginManager.Others.Permissions;
|
||||
|
||||
using static PluginManager.Logger;
|
||||
|
||||
namespace DiscordBot.Discord.Core;
|
||||
|
||||
internal class CommandHandler
|
||||
|
||||
@@ -309,7 +309,7 @@ public class Program
|
||||
Config.Variables.Add("LaunchMessage",
|
||||
"An error occured while closing the bot last time. Please consider closing the bot using the &rsd&c method !\nThere is a risk of losing all data or corruption of the save file, which in some cases requires to reinstall the bot !",
|
||||
false);
|
||||
Functions.WriteErrFile(ex.ToString());
|
||||
Logger.WriteErrFile(ex.ToString());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -318,6 +318,14 @@ public class Program
|
||||
|
||||
private static async Task PreLoadComponents()
|
||||
{
|
||||
Settings.sqlDatabase = new SqlDatabase(Functions.dataFolder + "SetDB.dat");
|
||||
|
||||
await Settings.sqlDatabase.Open();
|
||||
await Config.Initialize();
|
||||
Logger.Initialize(true);
|
||||
ArchiveManager.Initialize();
|
||||
|
||||
|
||||
Logger.LogEvent += (message) =>
|
||||
{
|
||||
Console.Write(message);
|
||||
@@ -330,13 +338,6 @@ public class Program
|
||||
Directory.CreateDirectory("./Data/Plugins");
|
||||
Directory.CreateDirectory("./Data/PAKS");
|
||||
|
||||
Settings.sqlDatabase = new SqlDatabase(Functions.dataFolder + "SetDB.dat");
|
||||
|
||||
await Settings.sqlDatabase.Open();
|
||||
await Config.Initialize();
|
||||
|
||||
|
||||
|
||||
if (await Config.Variables.ExistsAsync("DeleteLogsAtStartup"))
|
||||
if (await Config.Variables.GetValueAsync("DeleteLogsAtStartup") == "true")
|
||||
foreach (var file in Directory.GetFiles("./Output/Logs/"))
|
||||
@@ -364,7 +365,7 @@ public class Program
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Functions.WriteErrFile(ex.Message);
|
||||
Logger.WriteErrFile(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -451,7 +452,7 @@ public class Program
|
||||
await ServerCom.DownloadFileNoProgressAsync(
|
||||
"https://github.com/Wizzy69/installer/releases/download/release-1-discordbot/Updater.zip",
|
||||
"./Updater.zip");
|
||||
await Functions.ExtractArchive("./Updater.zip", "./", null,
|
||||
await ArchiveManager.ExtractArchive("./Updater.zip", "./", null,
|
||||
UnzipProgressType.PercentageFromTotalSize);
|
||||
await Config.Variables.SetValueAsync("UpdaterVersion", updaternewversion);
|
||||
File.Delete("Updater.zip");
|
||||
|
||||
Reference in New Issue
Block a user