diff --git a/.gitignore b/.gitignore
index 1deecb5..8afdcb6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,10 +29,8 @@ x86/
bld/
[Bb]in/
[Oo]bj/
-[Oo]ut/
[Ll]og/
[Ll]ogs/
-[Dd]ata/
# Visual Studio 2015/2017 cache/options directory
.vs/
@@ -64,6 +62,9 @@ project.lock.json
project.fragment.lock.json
artifacts/
+# Tye
+.tye/
+
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
@@ -98,7 +99,6 @@ StyleCopReport.xml
*.pidb
*.svclog
*.scc
-*.code-workspace
# Chutzpah Test files
_Chutzpah*
@@ -364,15 +364,91 @@ MigrationBackup/
# Fody - auto-generated XML schema
FodyWeavers.xsd
-*.txt
+##
+## Visual studio for Mac
+##
-#folders
-/Plugins/
-/DiscordBot.rar
-/DiscordBot/Data/
-/DiscordBot/Updater/
+
+# globs
+Makefile.in
+*.userprefs
+*.usertasks
+config.make
+config.status
+aclocal.m4
+install-sh
+autom4te.cache/
+*.tar.gz
+tarballs/
+test-results/
+
+# Mac bundle stuff
+*.dmg
+*.app
+
+# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
+# General
+.DS_Store
+.AppleDouble
+.LSOverride
+
+# Icon must end with two \r
+Icon
+
+
+# Thumbnails
+._*
+
+# Files that might appear in the root of a volume
+.DocumentRevisions-V100
+.fseventsd
+.Spotlight-V100
+.TemporaryItems
+.Trashes
+.VolumeIcon.icns
+.com.apple.timemachine.donotpresent
+
+# Directories potentially created on remote AFP share
+.AppleDB
+.AppleDesktop
+Network Trash Folder
+Temporary Items
+.apdisk
+
+# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
+# Windows thumbnail cache files
+Thumbs.db
+ehthumbs.db
+ehthumbs_vista.db
+
+# Dump file
+*.stackdump
+
+# Folder config file
+[Dd]esktop.ini
+
+# Recycle Bin used on file shares
+$RECYCLE.BIN/
+
+# Windows Installer files
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# Windows shortcuts
+*.lnk
+
+# JetBrains Rider
.idea/
-DiscordBot/Launcher.exe
-DiscordBotUI/bin
-DiscordBotUI/obj
-/.vscode
+*.sln.iml
+
+##
+## Visual Studio Code
+##
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 0000000..5d8722e
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,6 @@
+
+
+ enable
+ 11.0.2
+
+
diff --git a/DiscordBot/Program.cs b/DiscordBot/Program.cs
index 33c51ad..c05efab 100644
--- a/DiscordBot/Program.cs
+++ b/DiscordBot/Program.cs
@@ -30,7 +30,7 @@ public class Program
///
private static async Task ConsoleInputHandler()
{
- Application.CurrentApplication.InternalActionManager.Execute("plugin", "load").Wait();
+ await Application.CurrentApplication.InternalActionManager.Execute("plugin", "load");
while (true)
{
@@ -92,9 +92,8 @@ public class Program
await Task.Delay(5000);
}
- Application.CurrentApplication.Logger.OnFormattedLog += async (sender, logMessage) =>
+ Application.CurrentApplication.Logger.OnFormattedLog += (sender, logMessage) =>
{
- await File.AppendAllTextAsync(Application.CurrentApplication.LogFile, logMessage.Message + "\n");
var messageColor = logMessage.Type switch
{
LogType.INFO => "[green]",
@@ -117,8 +116,8 @@ public class Program
if (!Application.CurrentApplication.ApplicationEnvironmentVariables.ContainsKey("ServerID") ||
!Application.CurrentApplication.ApplicationEnvironmentVariables.ContainsKey("token") ||
- !Application.CurrentApplication.ApplicationEnvironmentVariables.ContainsKey("prefix")
- )
- Installer.GenerateStartupConfig().Wait();
+ !Application.CurrentApplication.ApplicationEnvironmentVariables.ContainsKey("prefix"))
+ await Installer.GenerateStartupConfig();
}
+
}
diff --git a/DiscordBotCore/Application.cs b/DiscordBotCore/Application.cs
index e5bc442..78a00a3 100644
--- a/DiscordBotCore/Application.cs
+++ b/DiscordBotCore/Application.cs
@@ -78,8 +78,9 @@ namespace DiscordBotCore
await CurrentApplication.PluginManager.UninstallMarkedPlugins();
await CurrentApplication.PluginManager.CheckForUpdates();
- CurrentApplication.InternalActionManager = new InternalActionManager(CurrentApplication.ApplicationEnvironmentVariables["PluginFolder"], "*.dll");
+ CurrentApplication.InternalActionManager = new InternalActionManager(CurrentApplication.ApplicationEnvironmentVariables["PluginFolder"], "dll");
await CurrentApplication.InternalActionManager.Initialize();
+
}
diff --git a/DiscordBotCore/Interfaces/DBEvent.cs b/DiscordBotCore/Interfaces/DBEvent.cs
index 80bb93e..63a6f5d 100644
--- a/DiscordBotCore/Interfaces/DBEvent.cs
+++ b/DiscordBotCore/Interfaces/DBEvent.cs
@@ -14,6 +14,11 @@ public interface DBEvent
///
string Description { get; }
+ ///
+ /// If the event requires another thread to run
+ ///
+ bool RequireOtherThread { get; }
+
///
/// The method that is invoked when the event is loaded into memory
///
diff --git a/DiscordBotCore/Loaders/ActionsLoader.cs b/DiscordBotCore/Loaders/ActionsLoader.cs
index ffbf53c..d5dc088 100644
--- a/DiscordBotCore/Loaders/ActionsLoader.cs
+++ b/DiscordBotCore/Loaders/ActionsLoader.cs
@@ -13,9 +13,9 @@ public class ActionsLoader
{
public delegate void ActionLoaded(string name, string typeName, bool success, Exception? e = null);
- private readonly string _actionExtension = "dll";
+ private readonly string _actionExtension;
- private readonly string _actionFolder = @"./Data/Plugins/";
+ private readonly string _actionFolder;
public ActionsLoader(string path, string extension)
{
diff --git a/DiscordBotCore/Loaders/PluginLoaderExtensions.cs b/DiscordBotCore/Loaders/PluginLoaderExtensions.cs
index 55b5f93..643670a 100644
--- a/DiscordBotCore/Loaders/PluginLoaderExtensions.cs
+++ b/DiscordBotCore/Loaders/PluginLoaderExtensions.cs
@@ -21,13 +21,13 @@ internal static class PluginLoaderExtensions
throw new ArgumentNullException(nameof(dbEvent));
}
-
dbEvent.Start(pluginLoader._Client);
return true;
}
catch (Exception e)
{
Application.CurrentApplication.Logger.Log($"Error starting event {dbEvent.Name}: {e.Message}", typeof(PluginLoader), LogType.ERROR);
+ Application.CurrentApplication.Logger.LogException(e, typeof(PluginLoader));
return false;
}
}
diff --git a/DiscordBotCore/Others/Logger/LogMessage.cs b/DiscordBotCore/Others/Logger/LogMessage.cs
index b369344..b98e453 100644
--- a/DiscordBotCore/Others/Logger/LogMessage.cs
+++ b/DiscordBotCore/Others/Logger/LogMessage.cs
@@ -72,7 +72,7 @@ namespace DiscordBotCore.Others.Logger
public static LogMessage CreateFromException(Exception exception, object Sender)
{
- LogMessage message = new LogMessage(exception.Message, Sender, LogType.ERROR);
+ LogMessage message = new LogMessage(exception.ToString(), Sender, LogType.ERROR);
return message;
}
}
diff --git a/DiscordBotCore/Others/Logger/Logger.cs b/DiscordBotCore/Others/Logger/Logger.cs
index 6a079a1..caa355a 100644
--- a/DiscordBotCore/Others/Logger/Logger.cs
+++ b/DiscordBotCore/Others/Logger/Logger.cs
@@ -37,6 +37,11 @@ public sealed class Logger : ILogger
return messageAsString;
}
+ private void LogToFile(string message)
+ {
+ System.IO.File.AppendAllText(Application.CurrentApplication.LogFile, message);
+ }
+
private string GenerateLogMessage(ILogMessage message, string customFormat)
{
string messageAsString = customFormat;
@@ -54,6 +59,7 @@ public sealed class Logger : ILogger
OnRawLog?.Invoke(this, message);
string messageAsString = GenerateLogMessage(message, format);
OnFormattedLog?.Invoke(this, new ILogger.FormattedMessage() { Message = messageAsString, Type = message.LogMessageType });
+ LogToFile(messageAsString);
}
public void Log(ILogMessage message)
@@ -61,6 +67,7 @@ public sealed class Logger : ILogger
OnRawLog?.Invoke(this, message);
string messageAsString = GenerateLogMessage(message);
OnFormattedLog?.Invoke(this, new ILogger.FormattedMessage() { Message = messageAsString, Type = message.LogMessageType }) ;
+ LogToFile(messageAsString);
}
public void Log(string message, LogType logType, string format) => Log(new LogMessage(message, logType), format);
diff --git a/DiscordBotUI/.gitignore b/DiscordBotUI/.gitignore
deleted file mode 100644
index 8afdcb6..0000000
--- a/DiscordBotUI/.gitignore
+++ /dev/null
@@ -1,454 +0,0 @@
-## Ignore Visual Studio temporary files, build results, and
-## files generated by popular Visual Studio add-ons.
-##
-## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
-
-# User-specific files
-*.rsuser
-*.suo
-*.user
-*.userosscache
-*.sln.docstates
-
-# User-specific files (MonoDevelop/Xamarin Studio)
-*.userprefs
-
-# Mono auto generated files
-mono_crash.*
-
-# Build results
-[Dd]ebug/
-[Dd]ebugPublic/
-[Rr]elease/
-[Rr]eleases/
-x64/
-x86/
-[Ww][Ii][Nn]32/
-[Aa][Rr][Mm]/
-[Aa][Rr][Mm]64/
-bld/
-[Bb]in/
-[Oo]bj/
-[Ll]og/
-[Ll]ogs/
-
-# Visual Studio 2015/2017 cache/options directory
-.vs/
-# Uncomment if you have tasks that create the project's static files in wwwroot
-#wwwroot/
-
-# Visual Studio 2017 auto generated files
-Generated\ Files/
-
-# MSTest test Results
-[Tt]est[Rr]esult*/
-[Bb]uild[Ll]og.*
-
-# NUnit
-*.VisualState.xml
-TestResult.xml
-nunit-*.xml
-
-# Build Results of an ATL Project
-[Dd]ebugPS/
-[Rr]eleasePS/
-dlldata.c
-
-# Benchmark Results
-BenchmarkDotNet.Artifacts/
-
-# .NET Core
-project.lock.json
-project.fragment.lock.json
-artifacts/
-
-# Tye
-.tye/
-
-# ASP.NET Scaffolding
-ScaffoldingReadMe.txt
-
-# StyleCop
-StyleCopReport.xml
-
-# Files built by Visual Studio
-*_i.c
-*_p.c
-*_h.h
-*.ilk
-*.meta
-*.obj
-*.iobj
-*.pch
-*.pdb
-*.ipdb
-*.pgc
-*.pgd
-*.rsp
-*.sbr
-*.tlb
-*.tli
-*.tlh
-*.tmp
-*.tmp_proj
-*_wpftmp.csproj
-*.log
-*.vspscc
-*.vssscc
-.builds
-*.pidb
-*.svclog
-*.scc
-
-# Chutzpah Test files
-_Chutzpah*
-
-# Visual C++ cache files
-ipch/
-*.aps
-*.ncb
-*.opendb
-*.opensdf
-*.sdf
-*.cachefile
-*.VC.db
-*.VC.VC.opendb
-
-# Visual Studio profiler
-*.psess
-*.vsp
-*.vspx
-*.sap
-
-# Visual Studio Trace Files
-*.e2e
-
-# TFS 2012 Local Workspace
-$tf/
-
-# Guidance Automation Toolkit
-*.gpState
-
-# ReSharper is a .NET coding add-in
-_ReSharper*/
-*.[Rr]e[Ss]harper
-*.DotSettings.user
-
-# TeamCity is a build add-in
-_TeamCity*
-
-# DotCover is a Code Coverage Tool
-*.dotCover
-
-# AxoCover is a Code Coverage Tool
-.axoCover/*
-!.axoCover/settings.json
-
-# Coverlet is a free, cross platform Code Coverage Tool
-coverage*.json
-coverage*.xml
-coverage*.info
-
-# Visual Studio code coverage results
-*.coverage
-*.coveragexml
-
-# NCrunch
-_NCrunch_*
-.*crunch*.local.xml
-nCrunchTemp_*
-
-# MightyMoose
-*.mm.*
-AutoTest.Net/
-
-# Web workbench (sass)
-.sass-cache/
-
-# Installshield output folder
-[Ee]xpress/
-
-# DocProject is a documentation generator add-in
-DocProject/buildhelp/
-DocProject/Help/*.HxT
-DocProject/Help/*.HxC
-DocProject/Help/*.hhc
-DocProject/Help/*.hhk
-DocProject/Help/*.hhp
-DocProject/Help/Html2
-DocProject/Help/html
-
-# Click-Once directory
-publish/
-
-# Publish Web Output
-*.[Pp]ublish.xml
-*.azurePubxml
-# Note: Comment the next line if you want to checkin your web deploy settings,
-# but database connection strings (with potential passwords) will be unencrypted
-*.pubxml
-*.publishproj
-
-# Microsoft Azure Web App publish settings. Comment the next line if you want to
-# checkin your Azure Web App publish settings, but sensitive information contained
-# in these scripts will be unencrypted
-PublishScripts/
-
-# NuGet Packages
-*.nupkg
-# NuGet Symbol Packages
-*.snupkg
-# The packages folder can be ignored because of Package Restore
-**/[Pp]ackages/*
-# except build/, which is used as an MSBuild target.
-!**/[Pp]ackages/build/
-# Uncomment if necessary however generally it will be regenerated when needed
-#!**/[Pp]ackages/repositories.config
-# NuGet v3's project.json files produces more ignorable files
-*.nuget.props
-*.nuget.targets
-
-# Microsoft Azure Build Output
-csx/
-*.build.csdef
-
-# Microsoft Azure Emulator
-ecf/
-rcf/
-
-# Windows Store app package directories and files
-AppPackages/
-BundleArtifacts/
-Package.StoreAssociation.xml
-_pkginfo.txt
-*.appx
-*.appxbundle
-*.appxupload
-
-# Visual Studio cache files
-# files ending in .cache can be ignored
-*.[Cc]ache
-# but keep track of directories ending in .cache
-!?*.[Cc]ache/
-
-# Others
-ClientBin/
-~$*
-*~
-*.dbmdl
-*.dbproj.schemaview
-*.jfm
-*.pfx
-*.publishsettings
-orleans.codegen.cs
-
-# Including strong name files can present a security risk
-# (https://github.com/github/gitignore/pull/2483#issue-259490424)
-#*.snk
-
-# Since there are multiple workflows, uncomment next line to ignore bower_components
-# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
-#bower_components/
-
-# RIA/Silverlight projects
-Generated_Code/
-
-# Backup & report files from converting an old project file
-# to a newer Visual Studio version. Backup files are not needed,
-# because we have git ;-)
-_UpgradeReport_Files/
-Backup*/
-UpgradeLog*.XML
-UpgradeLog*.htm
-ServiceFabricBackup/
-*.rptproj.bak
-
-# SQL Server files
-*.mdf
-*.ldf
-*.ndf
-
-# Business Intelligence projects
-*.rdl.data
-*.bim.layout
-*.bim_*.settings
-*.rptproj.rsuser
-*- [Bb]ackup.rdl
-*- [Bb]ackup ([0-9]).rdl
-*- [Bb]ackup ([0-9][0-9]).rdl
-
-# Microsoft Fakes
-FakesAssemblies/
-
-# GhostDoc plugin setting file
-*.GhostDoc.xml
-
-# Node.js Tools for Visual Studio
-.ntvs_analysis.dat
-node_modules/
-
-# Visual Studio 6 build log
-*.plg
-
-# Visual Studio 6 workspace options file
-*.opt
-
-# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
-*.vbw
-
-# Visual Studio LightSwitch build output
-**/*.HTMLClient/GeneratedArtifacts
-**/*.DesktopClient/GeneratedArtifacts
-**/*.DesktopClient/ModelManifest.xml
-**/*.Server/GeneratedArtifacts
-**/*.Server/ModelManifest.xml
-_Pvt_Extensions
-
-# Paket dependency manager
-.paket/paket.exe
-paket-files/
-
-# FAKE - F# Make
-.fake/
-
-# CodeRush personal settings
-.cr/personal
-
-# Python Tools for Visual Studio (PTVS)
-__pycache__/
-*.pyc
-
-# Cake - Uncomment if you are using it
-# tools/**
-# !tools/packages.config
-
-# Tabs Studio
-*.tss
-
-# Telerik's JustMock configuration file
-*.jmconfig
-
-# BizTalk build output
-*.btp.cs
-*.btm.cs
-*.odx.cs
-*.xsd.cs
-
-# OpenCover UI analysis results
-OpenCover/
-
-# Azure Stream Analytics local run output
-ASALocalRun/
-
-# MSBuild Binary and Structured Log
-*.binlog
-
-# NVidia Nsight GPU debugger configuration file
-*.nvuser
-
-# MFractors (Xamarin productivity tool) working folder
-.mfractor/
-
-# Local History for Visual Studio
-.localhistory/
-
-# BeatPulse healthcheck temp database
-healthchecksdb
-
-# Backup folder for Package Reference Convert tool in Visual Studio 2017
-MigrationBackup/
-
-# Ionide (cross platform F# VS Code tools) working folder
-.ionide/
-
-# Fody - auto-generated XML schema
-FodyWeavers.xsd
-
-##
-## Visual studio for Mac
-##
-
-
-# globs
-Makefile.in
-*.userprefs
-*.usertasks
-config.make
-config.status
-aclocal.m4
-install-sh
-autom4te.cache/
-*.tar.gz
-tarballs/
-test-results/
-
-# Mac bundle stuff
-*.dmg
-*.app
-
-# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
-# General
-.DS_Store
-.AppleDouble
-.LSOverride
-
-# Icon must end with two \r
-Icon
-
-
-# Thumbnails
-._*
-
-# Files that might appear in the root of a volume
-.DocumentRevisions-V100
-.fseventsd
-.Spotlight-V100
-.TemporaryItems
-.Trashes
-.VolumeIcon.icns
-.com.apple.timemachine.donotpresent
-
-# Directories potentially created on remote AFP share
-.AppleDB
-.AppleDesktop
-Network Trash Folder
-Temporary Items
-.apdisk
-
-# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
-# Windows thumbnail cache files
-Thumbs.db
-ehthumbs.db
-ehthumbs_vista.db
-
-# Dump file
-*.stackdump
-
-# Folder config file
-[Dd]esktop.ini
-
-# Recycle Bin used on file shares
-$RECYCLE.BIN/
-
-# Windows Installer files
-*.cab
-*.msi
-*.msix
-*.msm
-*.msp
-
-# Windows shortcuts
-*.lnk
-
-# JetBrains Rider
-.idea/
-*.sln.iml
-
-##
-## Visual Studio Code
-##
-.vscode/*
-!.vscode/settings.json
-!.vscode/tasks.json
-!.vscode/launch.json
-!.vscode/extensions.json
diff --git a/DiscordBotUI/DiscordBotUI.Desktop/DiscordBotUI.Desktop.csproj b/DiscordBotUI/DiscordBotUI.Desktop/DiscordBotUI.Desktop.csproj
deleted file mode 100644
index 6befdf1..0000000
--- a/DiscordBotUI/DiscordBotUI.Desktop/DiscordBotUI.Desktop.csproj
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
- WinExe
-
- net8.0
- enable
- true
-
-
-
- app.manifest
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/DiscordBotUI/DiscordBotUI.Desktop/Program.cs b/DiscordBotUI/DiscordBotUI.Desktop/Program.cs
deleted file mode 100644
index 0d660fb..0000000
--- a/DiscordBotUI/DiscordBotUI.Desktop/Program.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-
-using Avalonia;
-using Avalonia.ReactiveUI;
-
-namespace DiscordBotUI.Desktop
-{
- internal sealed class Program
- {
- // Initialization code. Don't use any Avalonia, third-party APIs or any
- // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
- // yet and stuff might break.
- [STAThread]
- public static void Main(string[] args) => BuildAvaloniaApp()
- .StartWithClassicDesktopLifetime(args);
-
- // Avalonia configuration, don't remove; also used by visual designer.
- public static AppBuilder BuildAvaloniaApp()
- => AppBuilder.Configure()
- .UsePlatformDetect()
- .WithInterFont()
- .LogToTrace()
- .UseReactiveUI();
- }
-}
diff --git a/DiscordBotUI/DiscordBotUI.Desktop/Properties/launchSettings.json b/DiscordBotUI/DiscordBotUI.Desktop/Properties/launchSettings.json
deleted file mode 100644
index 69f26c5..0000000
--- a/DiscordBotUI/DiscordBotUI.Desktop/Properties/launchSettings.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "profiles": {
- "DiscordBotUI.Desktop": {
- "commandName": "Project"
- },
- "WSL": {
- "commandName": "WSL2",
- "distributionName": ""
- }
- }
-}
\ No newline at end of file
diff --git a/DiscordBotUI/DiscordBotUI.Desktop/app.manifest b/DiscordBotUI/DiscordBotUI.Desktop/app.manifest
deleted file mode 100644
index 1a06515..0000000
--- a/DiscordBotUI/DiscordBotUI.Desktop/app.manifest
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/DiscordBotUI/DiscordBotUI.Desktop/builder.bat b/DiscordBotUI/DiscordBotUI.Desktop/builder.bat
deleted file mode 100644
index f73d6b4..0000000
--- a/DiscordBotUI/DiscordBotUI.Desktop/builder.bat
+++ /dev/null
@@ -1,35 +0,0 @@
-@echo off
-echo "Building..."
-
-echo "Building linux-x64 not self-contained"
-dotnet publish -r linux-x64 -p:PublishSingleFile=false --self-contained true -c Release -o ../publish/linux-x64
-
-echo "Building win-x64 not self-contained"
-dotnet publish -r win-x64 -p:PublishSingleFile=false --self-contained true -c Release -o ../publish/win-x64
-
-echo "Building osx-x64 not self-contained"
-dotnet publish -r osx-x64 -p:PublishSingleFile=false --self-contained true -c Release -o ../publish/osx-x64
-
-
-echo "Building linux-x64 self-contained"
-dotnet publish -r linux-x64 -p:PublishSingleFile=true --self-contained true -c Release -o ../publish/linux-x64-selfcontained
-
-echo "Building win-x64 self-contained"
-dotnet publish -r win-x64 -p:PublishSingleFile=true --self-contained true -c Release -o ../publish/win-x64-selfcontained
-
-echo "Building osx-x64 self-contained"
-dotnet publish -r osx-x64 -p:PublishSingleFile=true --self-contained true -c Release -o ../publish/osx-x64-selfcontained
-
-echo "Zipping..."
-mkdir ../publish/zip
-
-
-zip -r ../publish/zip/linux-x64.zip ../publish/linux-x64
-zip -r ../publish/zip/win-x64.zip ../publish/win-x64
-zip -r ../publish/zip/osx-x64.zip ../publish/osx-x64
-
-zip -r ../publish/zip/linux-x64-selfcontained.zip ../publish/linux-x64-selfcontained
-zip -r ../publish/zip/win-x64-selfcontained.zip ../publish/win-x64-selfcontained
-zip -r ../publish/zip/osx-x64-selfcontained.zip ../publish/osx-x64-selfcontained
-
-echo "Done!"
\ No newline at end of file
diff --git a/DiscordBotUI/DiscordBotUI/App.axaml b/DiscordBotUI/DiscordBotUI/App.axaml
deleted file mode 100644
index c9d9a69..0000000
--- a/DiscordBotUI/DiscordBotUI/App.axaml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/DiscordBotUI/DiscordBotUI/App.axaml.cs b/DiscordBotUI/DiscordBotUI/App.axaml.cs
deleted file mode 100644
index 5194606..0000000
--- a/DiscordBotUI/DiscordBotUI/App.axaml.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using Avalonia;
-using Avalonia.Controls.ApplicationLifetimes;
-using Avalonia.Markup.Xaml;
-
-using DiscordBotUI.ViewModels;
-using DiscordBotUI.Views;
-
-namespace DiscordBotUI
-{
- public partial class App : Application
- {
- public override void Initialize()
- {
- AvaloniaXamlLoader.Load(this);
- }
-
- public override void OnFrameworkInitializationCompleted()
- {
- if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
- {
- desktop.MainWindow = new HomePage();
- }
- else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform)
- {
- singleViewPlatform.MainView = new HomePage();
- }
-
- base.OnFrameworkInitializationCompleted();
- }
- }
-}
\ No newline at end of file
diff --git a/DiscordBotUI/DiscordBotUI/Assets/avalonia-logo.ico b/DiscordBotUI/DiscordBotUI/Assets/avalonia-logo.ico
deleted file mode 100644
index da8d49f..0000000
Binary files a/DiscordBotUI/DiscordBotUI/Assets/avalonia-logo.ico and /dev/null differ
diff --git a/DiscordBotUI/DiscordBotUI/Bot/Commands/Help.cs b/DiscordBotUI/DiscordBotUI/Bot/Commands/Help.cs
deleted file mode 100644
index 24bcb40..0000000
--- a/DiscordBotUI/DiscordBotUI/Bot/Commands/Help.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-using System.Collections.Generic;
-using Discord;
-using DiscordBotCore;
-using DiscordBotCore.Interfaces;
-using DiscordBotCore.Loaders;
-using DiscordBotCore.Others;
-
-namespace DiscordBotUI.Bot.Commands;
-
-///
-/// The help command
-///
-internal class Help: DBCommand
-{
- ///
- /// Command name
- ///
- public string Command => "help";
-
- public List Aliases => null;
-
- ///
- /// Command Description
- ///
- public string Description => "This command allows you to check all loaded commands";
-
- ///
- /// Command usage
- ///
- public string Usage => "help ";
-
- ///
- /// Check if the command require administrator to be executed
- ///
- public bool requireAdmin => false;
-
- ///
- /// The main body of the command
- ///
- /// The command context
- public void ExecuteServer(DbCommandExecutingArguments args)
- {
- if (args.arguments is not null)
- {
- var e = GenerateHelpCommand(args.arguments[0]);
- if (e is null)
- args.context.Channel.SendMessageAsync("Unknown Command " + args.arguments[0]);
- else
- args.context.Channel.SendMessageAsync(embed: e.Build());
-
-
- return;
- }
-
- var embedBuilder = new EmbedBuilder();
-
- var adminCommands = "";
- var normalCommands = "";
-
- foreach (var cmd in PluginLoader.Commands)
- if (cmd.requireAdmin)
- adminCommands += cmd.Command + " ";
- else
- normalCommands += cmd.Command + " ";
-
-
- if (adminCommands.Length > 0)
- embedBuilder.AddField("Admin Commands", adminCommands);
- if (normalCommands.Length > 0)
- embedBuilder.AddField("Normal Commands", normalCommands);
- args.context.Channel.SendMessageAsync(embed: embedBuilder.Build());
- }
-
- private EmbedBuilder GenerateHelpCommand(string command)
- {
- var embedBuilder = new EmbedBuilder();
- var cmd = PluginLoader.Commands.Find(p => p.Command == command ||
- p.Aliases is not null && p.Aliases.Contains(command)
- );
- if (cmd == null) return null;
-
- embedBuilder.AddField("Usage", DiscordBotCore.Application.CurrentApplication.ApplicationEnvironmentVariables["prefix"] + cmd.Usage);
- embedBuilder.AddField("Description", cmd.Description);
- if (cmd.Aliases is null)
- return embedBuilder;
- embedBuilder.AddField("Alias", cmd.Aliases.Count == 0 ? "-" : string.Join(", ", cmd.Aliases));
-
- return embedBuilder;
- }
-}
diff --git a/DiscordBotUI/DiscordBotUI/Bot/DiscordBot.cs b/DiscordBotUI/DiscordBotUI/Bot/DiscordBot.cs
deleted file mode 100644
index b906ab4..0000000
--- a/DiscordBotUI/DiscordBotUI/Bot/DiscordBot.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-using System.Threading.Tasks;
-
-using DiscordBotCore;
-using DiscordBotCore.Interfaces;
-using DiscordBotCore.Loaders;
-using DiscordBotCore.Others;
-
-namespace DiscordBotUI.Bot
-{
- internal class DiscordBot
- {
- private readonly string[] _StartArguments;
-
- public DiscordBot(string[] args)
- {
- this._StartArguments = args;
- }
-
- public async Task InitializeBot()
- {
- string token = DiscordBotCore.Application.CurrentApplication.ApplicationEnvironmentVariables["token"];
- string prefix = DiscordBotCore.Application.CurrentApplication.ApplicationEnvironmentVariables["prefix"];
- DiscordBotCore.Bot.Boot discordBooter = new DiscordBotCore.Bot.Boot(token, prefix);
- await discordBooter.Awake();
- }
-
- public async Task LoadPlugins()
- {
- var loader = new PluginLoader(DiscordBotCore.Application.CurrentApplication.DiscordBotClient.Client);
-
- loader.OnCommandLoaded += (data) =>
- {
- if (data.IsSuccess)
- {
- Application.CurrentApplication.Logger.Log("Successfully loaded command : " + data.PluginName, typeof(ICommandAction),
- LogType.INFO
- );
- }
-
- else
- {
- Application.CurrentApplication.Logger.Log("Failed to load command : " + data.PluginName + " because " + data.ErrorMessage,
- typeof(ICommandAction), LogType.ERROR
- );
- }
- };
- loader.OnEventLoaded += (data) =>
- {
- if (data.IsSuccess)
- {
- Application.CurrentApplication.Logger.Log("Successfully loaded event : " + data.PluginName, typeof(ICommandAction),
- LogType.INFO
- );
- }
- else
- {
- Application.CurrentApplication.Logger.Log("Failed to load event : " + data.PluginName + " because " + data.ErrorMessage,
- typeof(ICommandAction), LogType.ERROR
- );
- }
- };
-
- loader.OnSlashCommandLoaded += (data) =>
- {
- if (data.IsSuccess)
- {
- Application.CurrentApplication.Logger.Log("Successfully loaded slash command : " + data.PluginName, typeof(ICommandAction),
- LogType.INFO
- );
- }
- else
- {
- Application.CurrentApplication.Logger.Log("Failed to load slash command : " + data.PluginName + " because " + data.ErrorMessage,
- typeof(ICommandAction), LogType.ERROR
- );
- }
- };
-
- await loader.LoadPlugins();
- }
-
- }
-}
diff --git a/DiscordBotUI/DiscordBotUI/DiscordBotUI.csproj b/DiscordBotUI/DiscordBotUI/DiscordBotUI.csproj
deleted file mode 100644
index 882ca18..0000000
--- a/DiscordBotUI/DiscordBotUI/DiscordBotUI.csproj
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
- net8.0
- enable
- latest
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/DiscordBotUI/DiscordBotUI/ViewLocator.cs b/DiscordBotUI/DiscordBotUI/ViewLocator.cs
deleted file mode 100644
index c72ec8c..0000000
--- a/DiscordBotUI/DiscordBotUI/ViewLocator.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System;
-
-using Avalonia.Controls;
-using Avalonia.Controls.Templates;
-
-using DiscordBotUI.ViewModels;
-
-namespace DiscordBotUI
-{
- public class ViewLocator : IDataTemplate
- {
- public Control? Build(object? data)
- {
- if (data is null)
- return null;
-
- var name = data.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal);
- var type = Type.GetType(name);
-
- if (type != null)
- {
- return (Control)Activator.CreateInstance(type)!;
- }
-
- return new TextBlock { Text = "Not Found: " + name };
- }
-
- public bool Match(object? data)
- {
- return data is ViewModelBase;
- }
- }
-}
\ No newline at end of file
diff --git a/DiscordBotUI/DiscordBotUI/ViewModels/OnlinePlugin.cs b/DiscordBotUI/DiscordBotUI/ViewModels/OnlinePlugin.cs
deleted file mode 100644
index 0545e38..0000000
--- a/DiscordBotUI/DiscordBotUI/ViewModels/OnlinePlugin.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace DiscordBotUI.ViewModels
-{
- public class OnlinePlugin
- {
- public string Name { get; set; }
- public string Description { get; set; }
- public string Version { get; set; }
-
- public OnlinePlugin(string name, string description, string version) {
- Name = name;
- Description = description;
- Version = version;
-
- }
- }
-}
diff --git a/DiscordBotUI/DiscordBotUI/ViewModels/Plugin.cs b/DiscordBotUI/DiscordBotUI/ViewModels/Plugin.cs
deleted file mode 100644
index 55bb941..0000000
--- a/DiscordBotUI/DiscordBotUI/ViewModels/Plugin.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace DiscordBotUI.ViewModels
-{
- public class Plugin
- {
- public string Name { get; set; }
- public string Version { get; set; }
- public bool IsMarkedToUninstall { get; set; }
-
- public Plugin(string Name, string Version, bool isMarkedToUninstall)
- {
- this.Name = Name;
- this.Version = Version;
- IsMarkedToUninstall = isMarkedToUninstall;
- }
- }
-}
diff --git a/DiscordBotUI/DiscordBotUI/ViewModels/ViewModelBase.cs b/DiscordBotUI/DiscordBotUI/ViewModels/ViewModelBase.cs
deleted file mode 100644
index 6d48d97..0000000
--- a/DiscordBotUI/DiscordBotUI/ViewModels/ViewModelBase.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System.ComponentModel;
-using System.Runtime.CompilerServices;
-
-using ReactiveUI;
-
-namespace DiscordBotUI.ViewModels
-{
- public class ViewModelBase : ReactiveObject
- {
- }
-}
diff --git a/DiscordBotUI/DiscordBotUI/Views/HomePage.axaml b/DiscordBotUI/DiscordBotUI/Views/HomePage.axaml
deleted file mode 100644
index f783e49..0000000
--- a/DiscordBotUI/DiscordBotUI/Views/HomePage.axaml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/DiscordBotUI/DiscordBotUI/Views/HomePage.axaml.cs b/DiscordBotUI/DiscordBotUI/Views/HomePage.axaml.cs
deleted file mode 100644
index fe0aa2e..0000000
--- a/DiscordBotUI/DiscordBotUI/Views/HomePage.axaml.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-using System;
-
-using Avalonia;
-using Avalonia.Controls;
-using Avalonia.Markup.Xaml;
-using Avalonia.Threading;
-
-using DiscordBotUI.Bot;
-
-using DiscordBotCore;
-using DiscordBotCore.Others.Logger;
-using DiscordBotCore.Interfaces.Logger;
-
-namespace DiscordBotUI.Views;
-
-public partial class HomePage : Window
-{
- private readonly DiscordBot _DiscordBot;
-
- public HomePage()
- {
- InitializeComponent();
- _DiscordBot = new DiscordBot(null!);
-
- Loaded += HomePage_Loaded;
- }
-
- private async void HomePage_Loaded(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
- {
- await DiscordBotCore.Application.CreateApplication();
-
- if(!DiscordBotCore.Application.CurrentApplication.ApplicationEnvironmentVariables.ContainsAllKeys("token", "prefix"))
- {
- await new SettingsPage().ShowDialog(this);
-
- if (string.IsNullOrWhiteSpace(DiscordBotCore.Application.CurrentApplication.ApplicationEnvironmentVariables["token"]) || string.IsNullOrWhiteSpace(DiscordBotCore.Application.CurrentApplication.ApplicationEnvironmentVariables["prefix"]))
- Environment.Exit(-1);
- }
-
-
- textBoxToken.Text = DiscordBotCore.Application.CurrentApplication.ApplicationEnvironmentVariables["token"];
- textBoxPrefix.Text = DiscordBotCore.Application.CurrentApplication.ApplicationEnvironmentVariables["prefix"];
- textBoxServerId.Text = DiscordBotCore.Application.CurrentApplication.ApplicationEnvironmentVariables["ServerID"];
- }
-
- private void SetTextToTB(ILogMessage logMessage)
- {
- logTextBlock.Text += $"[{logMessage.LogMessageType}] [{logMessage.ThrowTime.ToShortTimeString()}] {logMessage.Message}\n";
- }
-
- private async void ButtonStartBotClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
- {
-
- DiscordBotCore.Application.CurrentApplication.Logger.OnRawLog += async (sender, logMessage) =>
- {
- await Dispatcher.UIThread.InvokeAsync(() => SetTextToTB(logMessage), DispatcherPriority.Background);
- };
-
- await _DiscordBot.InitializeBot();
-
- await _DiscordBot.LoadPlugins();
-
- }
-
- private async void SettingsMenuClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
- {
- //await new SettingsPage().ShowDialog(this);
- new SettingsPage().Show();
- }
-
- private async void PluginsMenuClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
- {
- //await new PluginsPage().ShowDialog(this);
- new PluginsPage().Show();
- }
-
- private void NewPluginsMenuClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
- {
- new PluginInstaller().Show();
- }
-}
\ No newline at end of file
diff --git a/DiscordBotUI/DiscordBotUI/Views/PluginInstaller.axaml b/DiscordBotUI/DiscordBotUI/Views/PluginInstaller.axaml
deleted file mode 100644
index ac444b9..0000000
--- a/DiscordBotUI/DiscordBotUI/Views/PluginInstaller.axaml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/DiscordBotUI/DiscordBotUI/Views/PluginInstaller.axaml.cs b/DiscordBotUI/DiscordBotUI/Views/PluginInstaller.axaml.cs
deleted file mode 100644
index 4dae1eb..0000000
--- a/DiscordBotUI/DiscordBotUI/Views/PluginInstaller.axaml.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Windows.Input;
-
-using Avalonia.Controls;
-using Avalonia.Interactivity;
-using Avalonia.Markup.Xaml.Templates;
-using Avalonia.Media;
-
-using DiscordBotUI.ViewModels;
-
-using DiscordBotCore;
-using DiscordBotCore.Plugin;
-
-namespace DiscordBotUI.Views;
-
-public partial class PluginInstaller : Window
-{
-
- public ObservableCollection Plugins { get; private set; }
-
- public PluginInstaller()
- {
- InitializeComponent();
- Loaded += OnPageLoaded;
-
- }
-
- private async void OnPageLoaded(object? sender, RoutedEventArgs e)
- {
- if (DiscordBotCore.Application.CurrentApplication.PluginManager is null) return;
-
- List? onlineInfos = await DiscordBotCore.Application.CurrentApplication.PluginManager.GetPluginsList();
-
- if(onlineInfos is null) return;
-
- List plugins = new List();
-
- foreach(PluginOnlineInfo onlinePlugin in onlineInfos)
- {
- plugins.Add(new OnlinePlugin(onlinePlugin.Name, onlinePlugin.Description, onlinePlugin.Version.ToShortString()));
- }
-
- Plugins = new ObservableCollection(plugins);
-
- dataGridInstallablePlugins.ItemsSource = Plugins;
-
- }
-
- public async void InstallPlugin(string name)
- {
-
- PluginOnlineInfo? info = await DiscordBotCore.Application.CurrentApplication.PluginManager.GetPluginDataByName(name);
- if(info is null) return;
-
-
-
- await DiscordBotCore.Application.CurrentApplication.PluginManager.InstallPlugin(info, null);
- }
-}
\ No newline at end of file
diff --git a/DiscordBotUI/DiscordBotUI/Views/PluginsPage.axaml b/DiscordBotUI/DiscordBotUI/Views/PluginsPage.axaml
deleted file mode 100644
index 091c701..0000000
--- a/DiscordBotUI/DiscordBotUI/Views/PluginsPage.axaml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/DiscordBotUI/DiscordBotUI/Views/PluginsPage.axaml.cs b/DiscordBotUI/DiscordBotUI/Views/PluginsPage.axaml.cs
deleted file mode 100644
index f5c0526..0000000
--- a/DiscordBotUI/DiscordBotUI/Views/PluginsPage.axaml.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-
-using Avalonia.Controls;
-using Avalonia.Interactivity;
-
-using DiscordBotUI.ViewModels;
-
-using DiscordBotCore;
-
-namespace DiscordBotUI.Views;
-
-
-public partial class PluginsPage: Window
-{
-
- public ObservableCollection Plugins { get; private set; }
-
- public PluginsPage()
- {
- InitializeComponent();
- Loaded += OnPageLoaded;
- }
-
- private async void OnPageLoaded(object? sender, RoutedEventArgs e)
- {
- if (DiscordBotCore.Application.CurrentApplication.PluginManager is null) return;
-
- var plugins = await DiscordBotCore.Application.CurrentApplication.PluginManager.GetInstalledPlugins();
- var localList = new List();
- foreach (var plugin in plugins)
- {
- localList.Add(new Plugin(plugin.PluginName, plugin.PluginVersion.ToShortString(), plugin.IsMarkedToUninstall));
- }
-
- Plugins = new ObservableCollection(localList);
-
-
- dataGridPlugins.ItemsSource = Plugins;
- }
-
-
-}
\ No newline at end of file
diff --git a/DiscordBotUI/DiscordBotUI/Views/SettingsPage.axaml b/DiscordBotUI/DiscordBotUI/Views/SettingsPage.axaml
deleted file mode 100644
index 96c285f..0000000
--- a/DiscordBotUI/DiscordBotUI/Views/SettingsPage.axaml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/DiscordBotUI/DiscordBotUI/Views/SettingsPage.axaml.cs b/DiscordBotUI/DiscordBotUI/Views/SettingsPage.axaml.cs
deleted file mode 100644
index 6fea35e..0000000
--- a/DiscordBotUI/DiscordBotUI/Views/SettingsPage.axaml.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using Avalonia.Controls;
-
-namespace DiscordBotUI.Views;
-
-public partial class SettingsPage : Window
-{
- public SettingsPage()
- {
- InitializeComponent();
- }
-
- private async void ButtonSaveSettingsClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
- {
- string token = textBoxToken.Text;
- string botPrefix = textBoxPrefix.Text;
- string serverId = textBoxServerId.Text;
-
- if (string.IsNullOrWhiteSpace(serverId)) serverId = string.Empty;
- if (string.IsNullOrWhiteSpace(token))
- {
- labelErrorMessage.Content = "The token is invalid";
- return;
- }
-
- if(string.IsNullOrWhiteSpace(botPrefix) || botPrefix.Length > 1 || botPrefix.Length < 1)
- {
- labelErrorMessage.Content = "The prefix is invalid";
- return;
- }
-
- DiscordBotCore.Application.CurrentApplication.ApplicationEnvironmentVariables.Add("token", token);
- DiscordBotCore.Application.CurrentApplication.ApplicationEnvironmentVariables.Add("prefix", botPrefix);
- DiscordBotCore.Application.CurrentApplication.ApplicationEnvironmentVariables.Add("ServerID", serverId);
-
- await DiscordBotCore.Application.CurrentApplication.ApplicationEnvironmentVariables.SaveToFile();
-
- DiscordBotCore.Application.CurrentApplication.Logger.Log("Config Saved", this);
-
- Close();
-
- }
-}
\ No newline at end of file
diff --git a/DiscordBotUI/DiscordBotUI_Windows.csproj b/DiscordBotUI/DiscordBotUI_Windows.csproj
new file mode 100644
index 0000000..2d86afd
--- /dev/null
+++ b/DiscordBotUI/DiscordBotUI_Windows.csproj
@@ -0,0 +1,15 @@
+
+
+
+ Library
+ net8.0-windows
+ enable
+ true
+ enable
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DiscordBotUI/Program.cs b/DiscordBotUI/Program.cs
new file mode 100644
index 0000000..a486818
--- /dev/null
+++ b/DiscordBotUI/Program.cs
@@ -0,0 +1,65 @@
+using Discord.WebSocket;
+
+using DiscordBotCore.Interfaces;
+using DiscordBotCore.Others;
+using DiscordBotCore.Others.Actions;
+
+using DiscordBotUI_Windows.WindowsForms;
+
+namespace DiscordBotUI
+{
+
+ public class DiscordEventUI : DBEvent
+ {
+ public string Name => "DiscordUI";
+
+ public bool RequireOtherThread => true;
+ public string Description => "Discord UI desc";
+
+ public void Start(DiscordSocketClient client)
+ {
+ Thread thread = new Thread(() =>
+ {
+ Application.Run(new MainWindow());
+ });
+ thread.SetApartmentState(ApartmentState.STA);
+ thread.Start();
+ }
+ }
+
+ public class ConsoleStartAction : ICommandAction
+ {
+ public string ActionName => "ui";
+
+ public string? Description => "UI Set of actions";
+
+ public string? Usage => "ui