Skip to content

Commit

Permalink
[Bot -> Services] Rework startup banner, remove dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogFeelings committed Nov 25, 2024
1 parent a73ac6f commit b64699d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
2 changes: 0 additions & 2 deletions Source/SammBot/SammBot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
<ItemGroup>
<PackageReference Include="AnalogFeelings.Matcha" Version="2.1.0"/>
<PackageReference Include="Discord.Net" Version="3.16.0" />
<PackageReference Include="Figgle" Version="0.5.1"/>
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand All @@ -60,7 +59,6 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.0"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.0"/>
<PackageReference Include="Pastel" Version="6.0.0"/>
<PackageReference Include="SharpCat" Version="1.0.0"/>
<PackageReference Include="SkiaSharp" Version="2.88.9"/>
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.9"/>
Expand Down
24 changes: 5 additions & 19 deletions Source/SammBot/Services/StartupService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@
using Discord;
using Discord.Interactions;
using Discord.WebSocket;
using Figgle;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.Extensions.DependencyInjection;
using Pastel;
using SammBot.Library;
using SammBot.Library.Extensions;
using System;
Expand All @@ -35,7 +33,6 @@
using System.Threading.Tasks;
using SammBot.Library.Models.Data;
using SammBot.Library.Services;
using Color = System.Drawing.Color;

namespace SammBot.Services;

Expand Down Expand Up @@ -103,37 +100,26 @@ public async Task StartAsync()
_interactionService.Log += DiscordLogAsync;

string botVersion = _informationService.Version;

Console.Title = $"{Constants.BOT_NAME} v{botVersion}";

string discordNetVersion = Assembly.GetAssembly(typeof(SessionStartLimit))!.GetName().Version!.ToString(3);
string discordNetVersion = DiscordConfig.Version;
string matchaVersion = Assembly.GetAssembly(typeof(MatchaLogger))!.GetName().Version!.ToString(3);

Console.Title = $"{Constants.BOT_NAME} v{botVersion}";
Console.Clear();

Console.Write(FiggleFonts.Slant.Render(Constants.BOT_NAME).Pastel(Color.SkyBlue));
Console.Write("===========".Pastel(Color.CadetBlue));
Console.Write($"Source code v{botVersion}, Discord.NET {discordNetVersion}".Pastel(Color.LightCyan));
Console.WriteLine("===========".Pastel(Color.CadetBlue));
Console.WriteLine();

await _logger.LogAsync(LogSeverity.Information, "Using Matcha {0}.", matchaVersion);
await _logger.LogAsync(LogSeverity.Information, "{0} v{1} - Copyright (C) 2021-2024 Analog Feelings", Constants.BOT_NAME, botVersion);
await _logger.LogAsync(LogSeverity.Information, "Using Matcha v{0}, Discord.NET v{1}.", matchaVersion, discordNetVersion);

_informationService.Uptime.Stop();

await _logger.LogAsync(LogSeverity.Information, "{0} took {1}ms to boot.", Constants.BOT_NAME, _informationService.Uptime.ElapsedMilliseconds);

_informationService.Uptime.Restart();

#if DEBUG
await _logger.LogAsync(LogSeverity.Warning, "{0} has been built on Debug configuration. Extra logging will be available.", Constants.BOT_NAME);
#endif

if (_settingsService.Settings.OnlyOwnerMode)
await _logger.LogAsync(LogSeverity.Warning, "Only Owner Mode is active. {0} will only handle commands sent by the bot account owner.", Constants.BOT_NAME);

await _logger.LogAsync(LogSeverity.Information, "Thawing the bot database...");
_ = Task.Run(() => ThawBotDatabase());
_ = Task.Run(ThawBotDatabase);

await _logger.LogAsync(LogSeverity.Information, "Initializing command handler...");
await _commandService.InitializeHandlerAsync();
Expand Down

0 comments on commit b64699d

Please sign in to comment.