The bot now checks for update
This commit is contained in:
@@ -3,11 +3,11 @@
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>disable</Nullable>
|
||||
<ApplicationIcon/>
|
||||
<StartupObject/>
|
||||
<ApplicationIcon />
|
||||
<StartupObject />
|
||||
<SignAssembly>False</SignAssembly>
|
||||
<IsPublishable>True</IsPublishable>
|
||||
<AssemblyVersion>1.0.3.1</AssemblyVersion>
|
||||
<AssemblyVersion>1.0.3.0</AssemblyVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DebugType>none</DebugType>
|
||||
@@ -16,28 +16,28 @@
|
||||
<DebugType>none</DebugType>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Remove="Data\**"/>
|
||||
<Compile Remove="obj\**"/>
|
||||
<Compile Remove="Output\**"/>
|
||||
<Compile Remove="Data\**" />
|
||||
<Compile Remove="obj\**" />
|
||||
<Compile Remove="Output\**" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Remove="Data\**"/>
|
||||
<EmbeddedResource Remove="obj\**"/>
|
||||
<EmbeddedResource Remove="Output\**"/>
|
||||
<EmbeddedResource Remove="Data\**" />
|
||||
<EmbeddedResource Remove="obj\**" />
|
||||
<EmbeddedResource Remove="Output\**" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="Data\**"/>
|
||||
<None Remove="obj\**"/>
|
||||
<None Remove="Output\**"/>
|
||||
<None Remove="builder.bat"/>
|
||||
<None Remove="builder.sh"/>
|
||||
<None Remove="Data\**" />
|
||||
<None Remove="obj\**" />
|
||||
<None Remove="Output\**" />
|
||||
<None Remove="builder.bat" />
|
||||
<None Remove="builder.sh" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Discord.Net" Version="3.11.0"/>
|
||||
<PackageReference Include="pythonnet" Version="3.0.1"/>
|
||||
<PackageReference Include="Spectre.Console" Version="0.47.0"/>
|
||||
<PackageReference Include="Discord.Net" Version="3.11.0" />
|
||||
<PackageReference Include="pythonnet" Version="3.0.1" />
|
||||
<PackageReference Include="Spectre.Console" Version="0.47.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PluginManager\PluginManager.csproj"/>
|
||||
<ProjectReference Include="..\PluginManager\PluginManager.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -7,24 +7,30 @@ namespace DiscordBot;
|
||||
|
||||
public static class Installer
|
||||
{
|
||||
public static async Task GenerateStartupConfig()
|
||||
private static async Task AskForConfig(string key, string message)
|
||||
{
|
||||
var token = AnsiConsole.Ask<string>("[green]Token:[/]");
|
||||
var botPrefix = AnsiConsole.Ask<string>("[yellow]Prefix:[/]");
|
||||
var serverId = AnsiConsole.Ask<string>("[deeppink1]Server ID:[/]");
|
||||
var value = AnsiConsole.Ask<string>($"[green]{message}[/]");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(serverId)) serverId = string.Empty;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(token) || string.IsNullOrWhiteSpace(botPrefix))
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
AnsiConsole.MarkupLine("Invalid token or prefix !");
|
||||
AnsiConsole.MarkupLine($"Invalid {key} !");
|
||||
|
||||
Environment.Exit(-20);
|
||||
}
|
||||
|
||||
Config.AppSettings.Add("token", token);
|
||||
Config.AppSettings.Add("prefix", botPrefix);
|
||||
Config.AppSettings.Add("ServerID", serverId);
|
||||
Config.AppSettings.Add(key, value);
|
||||
}
|
||||
public static async Task GenerateStartupConfig()
|
||||
{
|
||||
|
||||
if(!Config.AppSettings.ContainsKey("token"))
|
||||
await AskForConfig("token", "Token:");
|
||||
|
||||
if(!Config.AppSettings.ContainsKey("prefix"))
|
||||
await AskForConfig("prefix", "Prefix:");
|
||||
|
||||
if(!Config.AppSettings.ContainsKey("ServerID"))
|
||||
await AskForConfig("ServerID", "Server ID:");
|
||||
|
||||
await Config.AppSettings.SaveToFile();
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ public class Program
|
||||
{
|
||||
PreLoadComponents(args).Wait();
|
||||
|
||||
|
||||
|
||||
if (!AppSettings.ContainsKey("ServerID") || !AppSettings.ContainsKey("token") || !AppSettings.ContainsKey("prefix"))
|
||||
Installer.GenerateStartupConfig().Wait();
|
||||
|
||||
@@ -38,7 +40,6 @@ public class Program
|
||||
internalActionManager.Execute("plugin", "load").Wait();
|
||||
internalActionManager.Refresh().Wait();
|
||||
|
||||
|
||||
while (true)
|
||||
{
|
||||
var cmd = Console.ReadLine();
|
||||
@@ -61,7 +62,7 @@ public class Program
|
||||
Console.Clear();
|
||||
Console.ForegroundColor = ConsoleColor.DarkYellow;
|
||||
|
||||
Console.WriteLine($"Running on version: {Assembly.GetExecutingAssembly().GetName().Version}");
|
||||
Console.WriteLine($"Running on version: {AppSettings["Version"]}");
|
||||
Console.WriteLine("Git SethBot: https://github.com/andreitdr/SethDiscordBot");
|
||||
Console.WriteLine("Git Plugins: https://github.com/andreitdr/SethPlugins");
|
||||
|
||||
@@ -111,6 +112,20 @@ public class Program
|
||||
{
|
||||
await Initialize();
|
||||
|
||||
AppSettings["Version"] = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
|
||||
PluginManager.Updater.Application.AppUpdater updater = new();
|
||||
var update = await updater.CheckForUpdates();
|
||||
|
||||
if (update != PluginManager.Updater.Application.Update.None)
|
||||
{
|
||||
Console.WriteLine($"New update available: {update.UpdateVersion}");
|
||||
Console.WriteLine($"Download link: {update.UpdateUrl}");
|
||||
Console.WriteLine($"Update notes: {update.UpdateNotes}\n\n");
|
||||
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
Logger.OnLog += (sender, logMessage) =>
|
||||
{
|
||||
var messageColor = logMessage.Type switch
|
||||
@@ -130,7 +145,5 @@ public class Program
|
||||
|
||||
AnsiConsole.MarkupLine($"{messageColor}{logMessage.ThrowTime} {logMessage.Message} [/]");
|
||||
};
|
||||
|
||||
AppSettings["Version"] = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user