This commit is contained in:
2022-10-23 20:11:27 +03:00
parent cbaf552e7a
commit 47f88f167f
10 changed files with 337 additions and 241 deletions

View File

@@ -1,8 +1,10 @@
using System;
using System.Threading.Tasks;
using Discord;
using Discord.Commands;
using Discord.WebSocket;
using static PluginManager.Others.Functions;
namespace DiscordBot.Discord.Core;
@@ -42,7 +44,7 @@ internal class Boot
public Boot(string botToken, string botPrefix)
{
this.botPrefix = botPrefix;
this.botToken = botToken;
this.botToken = botToken;
}
@@ -60,17 +62,20 @@ internal class Boot
{
var config = new DiscordSocketConfig { AlwaysDownloadUsers = true };
client = new DiscordSocketClient(config);
client = new DiscordSocketClient(config);
service = new CommandService();
CommonTasks();
await client.LoginAsync(TokenType.Bot, botToken);
await client.StartAsync();
commandServiceHandler = new CommandHandler(client, service, botPrefix);
await commandServiceHandler.InstallCommandsAsync();
await Task.Delay(2000);
while (!isReady) ;
}
@@ -79,24 +84,27 @@ internal class Boot
{
if (client == null) return;
client.LoggedOut += Client_LoggedOut;
client.Log += Log;
client.LoggedIn += LoggedIn;
client.Ready += Ready;
client.Log += Log;
client.LoggedIn += LoggedIn;
client.Ready += Ready;
}
private Task Client_LoggedOut()
private async Task Client_LoggedOut()
{
WriteLogFile("Successfully Logged Out");
Log(new LogMessage(LogSeverity.Info, "Boot", "Successfully logged out from discord !"));
return Task.CompletedTask;
await Log(new LogMessage(LogSeverity.Info, "Boot", "Successfully logged out from discord !"));
/* var cmds = await client.GetGlobalApplicationCommandsAsync();
foreach (var cmd in cmds)
await cmd.DeleteAsync();*/
}
private Task Ready()
private async Task Ready()
{
Console.Title = "ONLINE";
isReady = true;
return Task.CompletedTask;
isReady = true;
}
private Task LoggedIn()

View File

@@ -306,8 +306,7 @@ public class Program
var main = new Console_Utilities.ProgressBar(ProgressBarType.NO_END);
main.Start();
Directory.CreateDirectory("./Data/Resources");
Directory.CreateDirectory("./Data/Plugins/Commands");
Directory.CreateDirectory("./Data/Plugins/Events");
Directory.CreateDirectory("./Data/Plugins");
Directory.CreateDirectory("./Data/PAKS");
await Config.LoadConfig();
if (Config.ContainsKey("DeleteLogsAtStartup"))
@@ -318,8 +317,6 @@ public class Program
await ServerCom.ReadTextFromURL(
"https://raw.githubusercontent.com/Wizzy69/installer/discord-bot-files/SetupKeys");
Config.PluginConfig.Load();
if (!Config.ContainsKey("Version"))
Config.AddValueToVariables("Version", Assembly.GetExecutingAssembly().GetName().Version.ToString(), false);
else