Some packages updated, and small cleanup

This commit is contained in:
Toastie 2024-09-09 13:24:23 +12:00
parent 22d03005a1
commit 31ed61075e
Signed by: toastie_t0ast
SSH key fingerprint: SHA256:ifNM08wfTUSLj8yk2fVhHh1EhwRQyaa81wEEif06ISw
4 changed files with 203 additions and 8 deletions

191
ellie-menu.ps1 Normal file
View file

@ -0,0 +1,191 @@
param (
[switch]$testing,
[switch]$release,
[switch]$output_test,
[switch]$build,
[switch]$help
)
$script_version = "1.0.0-public"
Write-Output ""
Write-Host "███████╗██╗ ██╗ ██╗███████╗██████╗ ██████╗ ████████╗" -ForegroundColor DarkCyan
Write-Host "██╔════╝██║ ██║ ██║██╔════╝██╔══██╗██╔═══██╗╚══██╔══╝" -ForegroundColor DarkCyan
Write-Host "█████╗ ██║ ██║ ██║█████╗ ██████╔╝██║ ██║ ██║ " -ForegroundColor DarkCyan
Write-Host "██╔══╝ ██║ ██║ ██║██╔══╝ ██╔══██╗██║ ██║ ██║ " -ForegroundColor DarkCyan
Write-Host "███████╗███████╗███████╗██║███████╗██████╔╝╚██████╔╝ ██║ " -ForegroundColor DarkCyan
Write-Host "╚══════╝╚══════╝╚══════╝╚═╝╚══════╝╚═════╝ ╚═════╝ ╚═╝ " -ForegroundColor DarkCyan
Write-Output ""
# If you remove this copyright header I will bonk
Write-Output "Copyright © 2024 Toastie_t0ast & EllieBotDevs"
Write-Output ""
Write-Host "Current script version is v$script_version" -ForegroundColor DarkCyan
Write-Output ""
if ($release) {
if ($args.Length -eq 0) {
Write-Host "Please provide a version string." -ForegroundColor Red
Write-Output ""
Write-Host "Script failed." -ForegroundColor Red
Write-Host "Please read the Error above for more information" -ForegroundColor Gray
Write-Output ""
}
else {
$version = $args[0]
Write-Output ""
Write-Host "Publishing EllieBot v$version" -Foregroundcolor Green
Write-Output ""
Write-Output ""
dotnet publish -c Release -r linux-x64 --self-contained -o elliebot-linux-x64 src/EllieBot/EllieBot.csproj
Write-Output ""
dotnet publish -c Release -r linux-arm64 --self-contained -o elliebot-linux-arm64 src/EllieBot/EllieBot.csproj
Write-Output ""
dotnet publish -c Release -r win-x64 --self-contained -o elliebot-windows-x64 src/EllieBot/EllieBot.csproj
Write-Output ""
dotnet publish -c Release -r win-arm64 --self-contained -o elliebot-windows-arm64 src/EllieBot/EllieBot.csproj
Write-Output ""
dotnet publish -c Release -r osx-x64 --self-contained -o elliebot-osx-x64 src/EllieBot/EllieBot.csproj
Write-Output ""
dotnet publish -c Release -r osx-arm64 --self-contained -o elliebot-osx-arm64 src/EllieBot/EllieBot.csproj
Write-Output ""
Write-Output "Preparing the Windows installer build."
Write-Output ""
dotnet clean
dotnet restore -f --no-cache -v n
dotnet publish -c Release --self-contained --runtime win-x64 /p:Version="$version" src/EllieBot
Write-Output ""
Write-Output "Setting environemt variable"
Write-Output ""
$env:ELLIEBOT_INSTALL_VERSION = $version
Write-Output ""
Write-Output "Compiling installer file"
Write-Output ""
iscc.exe /O+ .\exe_builder.iss
Write-Output ""
Write-Output "Compressing windows build files"
Write-Output ""
Compress-Archive -Path elliebot-windows-x64/ "$version-windows-x64-build.zip"
Compress-Archive -Path elliebot-windows-arm64/ "$version-windows-arm64-build.zip"
Write-Output ""
Write-Output "Moving the installer file to the directory this script is in"
Write-Output ""
Move-Item ellie-installers/$version/ellie-setup-$version.exe ellie-setup-$version.exe
Write-Output ""
Write-Output "Script finished successfully"
Write-Output ""
Write-Output "If you wish to build the linux or MacOS builds please run"
Write-Output "package.sh in wsl if you are on Windows or in bash (or whatever terminal you use) on linux"
Write-Output ""
Write-Output "If you have any suggestions on how to make this script better please make a suggestion"
Write-Output "in our discord @ https://discord.gg/etQdZxSyEH and in the 📚・suggestions channel"
Write-Output ""
}
}
if ($testing) {
if ($args.Length -eq 0) {
Write-Host "Please provide a version string." -ForegroundColor Red
Write-Output ""
Write-Host "Script failed." -ForegroundColor Red
Write-Host "Please read the Error above for more information" -ForegroundColor Gray
Write-Output ""
}
else {
$version = $args[0]
Write-Output ""
Write-Output "Running tests for EllieBot v$version"
Write-Output ""
dotnet test
Write-Output ""
Write-Output "Script finished successfully"
Write-Output ""
Write-Output "If you have any suggestions on how to make this script better please make a suggestion"
Write-Output "in our discord @ https://discord.gg/etQdZxSyEH and in the 📚・suggestions channel"
Write-Output ""
}
}
if ($output_test) {
Write-Output ""
Write-Output "Compiling a test build of EllieBot"
Write-Output ""
dotnet publish -c Release -o output/ src/EllieBot/
Write-Output ""
Write-Output "copying creds_example.yml to creds.yml"
Write-Output ""
Set-Location output
Copy-Item creds_example.yml creds.yml
Set-Location ..
Write-Output ""
Write-Output "Script finished successfully"
Write-Output ""
Write-Output "If you have any suggestions on how to make this script better please make a suggestion"
Write-Output "in our discord @ https://discord.gg/etQdZxSyEH and in the 📚・suggestions channel"
Write-Output ""
}
if ($build) {
Write-Output ""
Write-Output "Restoring EllieBot"
Write-Output ""
dotnet restore
Write-Output ""
Write-Output "Building EllieBot"
Write-Output ""
dotnet build --no-restore -c Release
Write-Output ""
Write-Output "Script finished successfully"
Write-Output ""
Write-Output "If you have any suggestions on how to make this script better please make a suggestion"
Write-Output "in our discord @ https://discord.gg/etQdZxSyEH and in the 📚・suggestions channel"
Write-Output ""
}
if ($help) {
Write-Output ""
Write-Output "Here is a list of switches for this script."
Write-Output ""
Write-Host "Release parameter" -ForegroundColor Green
Write-Output "-release"
Write-Output ""
Write-Host "Testing parameter" -ForegroundColor Blue
Write-Output "-testing"
Write-Output ""
Write-Host "Output test parameter" -ForegroundColor Yellow
Write-Output "-output_test"
Write-Output ""
Write-Host "Build parameter" -ForegroundColor DarkCyan
Write-Output "-build"
Write-Output ""
Write-Host "Here is an example" -ForegroundColor Gray
Write-Host "build.ps1 -build" -ForegroundColor Gray
Write-Output ""
}

View file

@ -88,7 +88,7 @@ public sealed class Bot : IBot
public IReadOnlyList<ulong> GetCurrentGuildIds() public IReadOnlyList<ulong> GetCurrentGuildIds()
=> Client.Guilds.Select(x => x.Id).ToList().ToList(); => Client.Guilds.Select(x => x.Id).ToList().AsReadOnly();
private void AddServices() private void AddServices()
{ {
@ -99,7 +99,7 @@ public sealed class Bot : IBot
using (var uow = _db.GetDbContext()) using (var uow = _db.GetDbContext())
{ {
uow.EnsureUserCreated(bot.Id, bot.Username, bot.Discriminator, bot.AvatarId); uow.EnsureUserCreated(bot.Id, bot.Username, bot.Discriminator, bot.AvatarId);
AllGuildConfigs = uow.Set<GuildConfig>().GetAllGuildConfigs(startingGuildIdList).ToImmutableArray(); AllGuildConfigs = uow.GuildConfigs.GetAllGuildConfigs(startingGuildIdList);
} }
// var svcs = new StandardKernel(new NinjectSettings() // var svcs = new StandardKernel(new NinjectSettings()

View file

@ -47,14 +47,18 @@ public static class GuildConfigExtensions
.Include(gc => gc.CommandCooldowns) .Include(gc => gc.CommandCooldowns)
.Include(gc => gc.FollowedStreams) .Include(gc => gc.FollowedStreams)
.Include(gc => gc.StreamRole) .Include(gc => gc.StreamRole)
.Include(gc => gc.DelMsgOnCmdChannels)
.Include(gc => gc.XpSettings) .Include(gc => gc.XpSettings)
.ThenInclude(x => x.ExclusionList) .ThenInclude(x => x.ExclusionList);
.Include(gc => gc.DelMsgOnCmdChannels);
public static IEnumerable<GuildConfig> GetAllGuildConfigs( public static IReadOnlyCollection<GuildConfig> GetAllGuildConfigs(
this DbSet<GuildConfig> configs, this DbSet<GuildConfig> configs,
IReadOnlyList<ulong> availableGuilds) IReadOnlyList<ulong> availableGuilds)
=> configs.IncludeEverything().AsNoTracking().Where(x => availableGuilds.Contains(x.GuildId)).ToList(); => configs.IncludeEverything()
.AsNoTracking()
.Where(x => availableGuilds.Contains(x.GuildId))
.ToList()
.AsReadOnly();
/// <summary> /// <summary>
/// Gets and creates if it doesn't exist a config for a guild. /// Gets and creates if it doesn't exist a config for a guild.

View file

@ -81,7 +81,7 @@
<!-- Db-related packages --> <!-- Db-related packages -->
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@ -89,7 +89,7 @@
<PackageReference Include="linq2db.EntityFrameworkCore" Version="8.1.0" /> <PackageReference Include="linq2db.EntityFrameworkCore" Version="8.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.4" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.8" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" /> <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" /> <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />