Skip to content

Commit

Permalink
Merge pull request #90 from winglessraven/dev
Browse files Browse the repository at this point in the history
Memory Usage & Time Zone fixes
  • Loading branch information
winglessraven authored Apr 16, 2024
2 parents e2b0239 + b1cd0a4 commit 674d8b7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
24 changes: 12 additions & 12 deletions DiscordBotPlugin/DiscordBotPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,23 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Discord.Net.Commands, Version=3.12.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Discord.Net.Commands.3.12.0\lib\net461\Discord.Net.Commands.dll</HintPath>
<Reference Include="Discord.Net.Commands, Version=3.14.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Discord.Net.Commands.3.14.1\lib\net461\Discord.Net.Commands.dll</HintPath>
</Reference>
<Reference Include="Discord.Net.Core, Version=3.12.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Discord.Net.Core.3.12.0\lib\net461\Discord.Net.Core.dll</HintPath>
<Reference Include="Discord.Net.Core, Version=3.14.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Discord.Net.Core.3.14.1\lib\net461\Discord.Net.Core.dll</HintPath>
</Reference>
<Reference Include="Discord.Net.Interactions, Version=3.12.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Discord.Net.Interactions.3.12.0\lib\net461\Discord.Net.Interactions.dll</HintPath>
<Reference Include="Discord.Net.Interactions, Version=3.14.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Discord.Net.Interactions.3.14.1\lib\net461\Discord.Net.Interactions.dll</HintPath>
</Reference>
<Reference Include="Discord.Net.Rest, Version=3.12.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Discord.Net.Rest.3.12.0\lib\net461\Discord.Net.Rest.dll</HintPath>
<Reference Include="Discord.Net.Rest, Version=3.14.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Discord.Net.Rest.3.14.1\lib\net461\Discord.Net.Rest.dll</HintPath>
</Reference>
<Reference Include="Discord.Net.Webhook, Version=3.12.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Discord.Net.Webhook.3.12.0\lib\netstandard2.0\Discord.Net.Webhook.dll</HintPath>
<Reference Include="Discord.Net.Webhook, Version=3.14.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Discord.Net.Webhook.3.14.1\lib\netstandard2.0\Discord.Net.Webhook.dll</HintPath>
</Reference>
<Reference Include="Discord.Net.WebSocket, Version=3.12.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Discord.Net.WebSocket.3.12.0\lib\net461\Discord.Net.WebSocket.dll</HintPath>
<Reference Include="Discord.Net.WebSocket, Version=3.14.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Discord.Net.WebSocket.3.14.1\lib\net461\Discord.Net.WebSocket.dll</HintPath>
</Reference>
<Reference Include="LocalFileBackupPlugin">
<HintPath>H:\AMPDatastore\Instances\Minecraft01\Plugins\LocalFileBackupPlugin\LocalFileBackupPlugin.dll</HintPath>
Expand Down
9 changes: 6 additions & 3 deletions DiscordBotPlugin/PluginMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using LocalFileBackupPlugin;
using System.Diagnostics;
using System.Diagnostics.Tracing;
using System.Threading.Tasks.Sources;

namespace DiscordBotPlugin
{
Expand Down Expand Up @@ -403,7 +404,8 @@ private async Task GetServerInfo(bool updateExisting, SocketSlashCommand msg, bo
//if server is online, get the uptime info and set the field accordingly
if (application.State == ApplicationState.Ready)
{
TimeSpan uptime = DateTime.Now.Subtract(application.StartTime);

TimeSpan uptime = DateTime.Now.Subtract(application.StartTime.ToLocalTime());
embed.AddField("Uptime", string.Format("{0:D2}:{1:D2}:{2:D2}:{3:D2}", uptime.Days, uptime.Hours, uptime.Minutes, uptime.Seconds), true);
}

Expand Down Expand Up @@ -695,7 +697,7 @@ private async Task UpdateWebPanel(string webPanelPath)
//if server is online, get the uptime info and set the field accordingly
if (application.State == ApplicationState.Ready)
{
TimeSpan up = DateTime.Now.Subtract(application.StartTime);
TimeSpan up = DateTime.Now.Subtract(application.StartTime.ToLocalTime());
uptime = string.Format("{0:D2}:{1:D2}:{2:D2}:{3:D2}", up.Days, up.Hours, up.Minutes, up.Seconds);
}
else
Expand Down Expand Up @@ -2213,7 +2215,8 @@ private string GetMemoryUsage()
double totalAvailable = application.MaxRAMUsage;
if (totalAvailable == 0)
totalAvailable = platform.InstalledRAMMB;
double usage = application.GetRAMUsage();
double usage = application.GetPhysicalRAMUsage();

if(usage >= 1024 || (totalAvailable > 1024 && _settings.MainSettings.ShowMaximumRAM))
gb = true;

Expand Down
14 changes: 7 additions & 7 deletions DiscordBotPlugin/packages.config
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Discord.Net" version="3.12.0" targetFramework="net48" />
<package id="Discord.Net.Commands" version="3.12.0" targetFramework="net48" />
<package id="Discord.Net.Core" version="3.12.0" targetFramework="net48" />
<package id="Discord.Net.Interactions" version="3.12.0" targetFramework="net48" />
<package id="Discord.Net.Rest" version="3.12.0" targetFramework="net48" />
<package id="Discord.Net.Webhook" version="3.12.0" targetFramework="net48" />
<package id="Discord.Net.WebSocket" version="3.12.0" targetFramework="net48" />
<package id="Discord.Net" version="3.14.1" targetFramework="net48" />
<package id="Discord.Net.Commands" version="3.14.1" targetFramework="net48" />
<package id="Discord.Net.Core" version="3.14.1" targetFramework="net48" />
<package id="Discord.Net.Interactions" version="3.14.1" targetFramework="net48" />
<package id="Discord.Net.Rest" version="3.14.1" targetFramework="net48" />
<package id="Discord.Net.Webhook" version="3.14.1" targetFramework="net48" />
<package id="Discord.Net.WebSocket" version="3.14.1" targetFramework="net48" />
<package id="ILMerge" version="3.0.41" targetFramework="net48" />
<package id="ILMerge.MSBuild.Task" version="1.0.7" targetFramework="net48" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net48" />
Expand Down

0 comments on commit 674d8b7

Please sign in to comment.