Skip to content

Commit

Permalink
fix: version check
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulalaby committed Dec 21, 2023
1 parent bfa19df commit 9726717
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions DisCatSharp/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,8 @@ internal static async Task CheckVersionAsync(BaseDiscordClient client, bool star

try
{
var currentVersion = client.VersionString.Split('-')[0]!.Split('+')[0]!;
var version = manualVersion ?? client.VersionString;
var currentVersion = version.Split('-')[0]!.Split('+')[0]!;
var splitVersion = currentVersion.Split('.');
var api = Convert.ToInt32(splitVersion[0]);
var major = Convert.ToInt32(splitVersion[1]);
Expand All @@ -527,11 +528,11 @@ internal static async Task CheckVersionAsync(BaseDiscordClient client, bool star
var githubMinor = Convert.ToInt32(githubSplitVersion[2]);

if (api < githubApi || (api == githubApi && major < githubMajor) || (api == githubApi && major == githubMajor && minor < githubMinor))
client.Logger.LogWarning("[{Type}] Your version of {Product} is outdated!\n\tCurrent version: v{CurrentVersion}\n\tLatest version: v{LastGitHubRelease}", fromShard ? "ShardedClient" : "Client", productName, client.VersionString, lastGitHubRelease);
client.Logger.LogWarning("[{Type}] Your version of {Product} is outdated!\n\tCurrent version: v{CurrentVersion}\n\tLatest version: v{LastGitHubRelease}", fromShard ? "ShardedClient" : "Client", productName, version, lastGitHubRelease);
else if (githubApi < api || (githubApi == api && githubMajor < major) || (githubApi == api && githubMajor == major && githubMinor < minor))
client.Logger.LogInformation("[{Type}] Your version of {Product} is newer than the latest release!\n\tNote that you are using a pre-release which is not recommended for production.\n\tCurrent version: v{CurrentVersion}\n\tLatest version: v{LastGitHubRelease}", fromShard ? "ShardedClient" : "Client", productName, client.VersionString, lastGitHubRelease);
client.Logger.LogInformation("[{Type}] Your version of {Product} is newer than the latest release!\n\tNote that you are using a pre-release which is not recommended for production.\n\tCurrent version: v{CurrentVersion}\n\tLatest version: v{LastGitHubRelease}", fromShard ? "ShardedClient" : "Client", productName, version, lastGitHubRelease);
else
client.Logger.LogInformation("[{Type}] Your version of {Product} is up to date!\n\tCurrent version: v{CurrentVersion}", fromShard ? "ShardedClient" : "Client", productName, client.VersionString);
client.Logger.LogInformation("[{Type}] Your version of {Product} is up to date!\n\tCurrent version: v{CurrentVersion}", fromShard ? "ShardedClient" : "Client", productName, version);
}
catch
{
Expand Down

0 comments on commit 9726717

Please sign in to comment.