This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -121,7 +121,6 @@ internal class CommandHandler
|
||||
|
||||
plugin.Execute(context, message, client, false);
|
||||
Functions.WriteLogFile($"[{message.Author.Id}] Executed command : " + plugin.Command);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
using DiscordBot.Discord.Core;
|
||||
using PluginManager;
|
||||
using PluginManager.Items;
|
||||
using PluginManager.Others;
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using DiscordBot.Discord.Core;
|
||||
using PluginManager;
|
||||
using PluginManager.Items;
|
||||
using PluginManager.Online;
|
||||
using PluginManager.Others;
|
||||
|
||||
namespace DiscordBot;
|
||||
|
||||
namespace DiscordBot
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
private static bool loadPluginsOnStartup = false;
|
||||
private static bool listPluginsAtStartup = false;
|
||||
private static bool loadPluginsOnStartup;
|
||||
private static bool listPluginsAtStartup;
|
||||
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
@@ -28,42 +28,35 @@ namespace DiscordBot
|
||||
PreLoadComponents().Wait();
|
||||
|
||||
if (!Config.ContainsKey("token") || Config.GetValue<string>("token") == null || Config.GetValue<string>("token")?.Length != 70)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
Console.WriteLine("Please insert your token");
|
||||
Console.Write("Token = ");
|
||||
string token = Console.ReadLine();
|
||||
var token = Console.ReadLine();
|
||||
if (token?.Length == 59 || token?.Length == 70)
|
||||
Config.AddValueToVariables("token", token, true);
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Invalid token");
|
||||
continue;
|
||||
}
|
||||
|
||||
Console.WriteLine("Please insert your prefix (max. 1 character long):");
|
||||
Console.WriteLine("For a prefix longer then one character, the first character will be saved and the others will be ignored.\n No spaces or numbers allowed");
|
||||
Console.Write("Prefix = ");
|
||||
char prefix = Console.ReadLine()![0];
|
||||
|
||||
if (prefix == ' ' || char.IsDigit(prefix)) continue;
|
||||
Config.AddValueToVariables("prefix", prefix.ToString(), false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Config.ContainsKey("prefix"))
|
||||
{
|
||||
Console.WriteLine("Please insert your prefix (max. 1 character long):");
|
||||
Console.WriteLine("For a prefix longer then one character, the first character will be saved and the others will be ignored.\n No spaces or numbers allowed");
|
||||
Console.Write("Prefix = ");
|
||||
char prefix = Console.ReadLine()![0];
|
||||
var prefix = Console.ReadLine()![0];
|
||||
|
||||
if (prefix == ' ' || char.IsDigit(prefix)) return;
|
||||
Config.AddValueToVariables("prefix", prefix.ToString(), false);
|
||||
}
|
||||
|
||||
if (!Config.ContainsKey("prefix") || Config.GetValue<string>("prefix") == default)
|
||||
{
|
||||
Console.WriteLine("Please insert your prefix (max. 1 character long):");
|
||||
Console.WriteLine("For a prefix longer then one character, the first character will be saved and the others will be ignored.\n No spaces or numbers allowed");
|
||||
Console.Write("Prefix = ");
|
||||
var prefix = Console.ReadLine()![0];
|
||||
if (prefix == ' ') return;
|
||||
Config.AddValueToVariables("prefix", prefix.ToString(), false);
|
||||
}
|
||||
|
||||
|
||||
HandleInput(args).Wait();
|
||||
}
|
||||
|
||||
@@ -73,14 +66,14 @@ namespace DiscordBot
|
||||
/// <param name="discordbooter">The discord booter used to start the application</param>
|
||||
private static Task NoGUI(Boot discordbooter)
|
||||
{
|
||||
ConsoleCommandsHandler consoleCommandsHandler = new ConsoleCommandsHandler(discordbooter.client);
|
||||
var consoleCommandsHandler = new ConsoleCommandsHandler(discordbooter.client);
|
||||
if (loadPluginsOnStartup) consoleCommandsHandler.HandleCommand("lp");
|
||||
if (listPluginsAtStartup) consoleCommandsHandler.HandleCommand("listplugs");
|
||||
Config.SaveConfig();
|
||||
while (true)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
string cmd = Console.ReadLine();
|
||||
var cmd = Console.ReadLine();
|
||||
consoleCommandsHandler.HandleCommand(cmd);
|
||||
}
|
||||
}
|
||||
@@ -101,8 +94,8 @@ namespace DiscordBot
|
||||
|
||||
try
|
||||
{
|
||||
string token = Config.GetValue<string>("token");
|
||||
string prefix = Config.GetValue<string>("prefix");
|
||||
var token = Config.GetValue<string>("token");
|
||||
var prefix = Config.GetValue<string>("prefix");
|
||||
|
||||
var discordbooter = new Boot(token, prefix);
|
||||
await discordbooter.Awake();
|
||||
@@ -121,8 +114,8 @@ namespace DiscordBot
|
||||
/// <param name="d">Directory path</param>
|
||||
private static Task ClearFolder(string d)
|
||||
{
|
||||
string[] files = Directory.GetFiles(d);
|
||||
int fileNumb = files.Length;
|
||||
var files = Directory.GetFiles(d);
|
||||
var fileNumb = files.Length;
|
||||
for (var i = 0; i < fileNumb; i++)
|
||||
{
|
||||
File.Delete(files[i]);
|
||||
@@ -138,37 +131,12 @@ namespace DiscordBot
|
||||
/// <param name="args">The arguments</param>
|
||||
private static async Task HandleInput(string[] args)
|
||||
{
|
||||
int len = args.Length;
|
||||
if (len == 1 && args[0] == "--help")
|
||||
{
|
||||
Console.WriteLine("Available commands:\n--exec -> start the bot with tools enabled");
|
||||
return;
|
||||
}
|
||||
|
||||
if (len == 1 && args[0] == "--logout")
|
||||
{
|
||||
File.Delete(Functions.dataFolder + "config.json");
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
Environment.Exit(0x08);
|
||||
}
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (len >= 2 && args[0] == "--encrypt")
|
||||
{
|
||||
string s2e = args.MergeStrings(1);
|
||||
Console.WriteLine("MD5: " + await Cryptography.CreateMD5(s2e));
|
||||
Console.WriteLine("SHA356: " + await Cryptography.CreateSHA256(s2e));
|
||||
return;
|
||||
}
|
||||
var len = args.Length;
|
||||
|
||||
if (len == 3 && args[0] == "/download")
|
||||
{
|
||||
string url = args[1];
|
||||
string location = args[2];
|
||||
var url = args[1];
|
||||
var location = args[2];
|
||||
|
||||
await ServerCom.DownloadFileAsync(url, location);
|
||||
|
||||
@@ -183,9 +151,9 @@ namespace DiscordBot
|
||||
}
|
||||
|
||||
|
||||
if (len == 0 || args[0] != "--exec" && args[0] != "--execute")
|
||||
if (len == 0 || (args[0] != "--exec" && args[0] != "--execute"))
|
||||
{
|
||||
Boot b = await StartNoGUI();
|
||||
var b = await StartNoGUI();
|
||||
await NoGUI(b);
|
||||
return;
|
||||
}
|
||||
@@ -205,7 +173,7 @@ namespace DiscordBot
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
Console.Write("> ");
|
||||
string[] message = Console.ReadLine().Split(' ');
|
||||
var message = Console.ReadLine().Split(' ');
|
||||
|
||||
switch (message[0])
|
||||
{
|
||||
@@ -241,7 +209,7 @@ namespace DiscordBot
|
||||
Environment.Exit(0);
|
||||
break;
|
||||
case "--start":
|
||||
Boot booter = await StartNoGUI();
|
||||
var booter = await StartNoGUI();
|
||||
await NoGUI(booter);
|
||||
return;
|
||||
|
||||
@@ -257,8 +225,7 @@ namespace DiscordBot
|
||||
await Config.LoadConfig();
|
||||
if (Config.ContainsKey("DeleteLogsAtStartup"))
|
||||
if (Config.GetValue<bool>("DeleteLogsAtStartup"))
|
||||
foreach (string file in Directory.GetFiles("./Output/Logs/"))
|
||||
foreach (var file in Directory.GetFiles("./Output/Logs/"))
|
||||
File.Delete(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
using Discord;
|
||||
using Discord.Audio;
|
||||
using MusicCommands;
|
||||
|
||||
namespace CMD_Utils.Music;
|
||||
namespace MusicCommands;
|
||||
|
||||
internal static class Data
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using Discord.WebSocket;
|
||||
using PluginManager.Interfaces;
|
||||
|
||||
namespace CMD_Utils.Music;
|
||||
namespace MusicCommands;
|
||||
|
||||
internal class Leave : DBCommand
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>warnings</Nullable>
|
||||
<BaseOutputPath>..\DiscordBot\bin\Debug\net6.0\Data\Plugins\Commands\MusicCommands</BaseOutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using CMD_Utils.Music;
|
||||
using PluginManager.Others;
|
||||
|
||||
namespace MusicCommands;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using Discord.WebSocket;
|
||||
using PluginManager.Interfaces;
|
||||
|
||||
namespace CMD_Utils.Music;
|
||||
namespace MusicCommands;
|
||||
|
||||
internal class Pause : DBCommand
|
||||
{
|
||||
|
||||
@@ -5,11 +5,10 @@ using Discord;
|
||||
using Discord.Audio;
|
||||
using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
using MusicCommands;
|
||||
using PluginManager.Interfaces;
|
||||
using PluginManager.Others;
|
||||
|
||||
namespace CMD_Utils.Music;
|
||||
namespace MusicCommands;
|
||||
|
||||
internal class Play : DBCommand
|
||||
{
|
||||
@@ -29,7 +28,7 @@ internal class Play : DBCommand
|
||||
{
|
||||
var path = "./Music";
|
||||
var FileName = Functions.GetArguments(message).ToArray().MergeStrings(0);
|
||||
path += "/" + FileName + ".mp3";
|
||||
path += "/" + FileName + ".ogg";
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Console.WriteLine("Unknown path " + path);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using CMD_Utils.Music;
|
||||
using Discord.Commands;
|
||||
using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
using PluginManager.Interfaces;
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using CMD_Utils.Music;
|
||||
using Discord;
|
||||
using Discord;
|
||||
using Discord.Audio;
|
||||
using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
|
||||
Reference in New Issue
Block a user