Skip to content

Commit

Permalink
remove custom dsp
Browse files Browse the repository at this point in the history
  • Loading branch information
Plerx2493 committed Jul 12, 2024
1 parent 851ecff commit 9e12630
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 50 deletions.
4 changes: 0 additions & 4 deletions .gitmodules

This file was deleted.

1 change: 0 additions & 1 deletion Libs/DSharpPlus
Submodule DSharpPlus deleted from 039166
26 changes: 0 additions & 26 deletions ModularAssistentForDiscordServer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libs", "Libs", "{574BAEF3-5632-4726-A8E1-3A60997E3615}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DSharpPlus", "Libs\DSharpPlus\DSharpPlus\DSharpPlus.csproj", "{4621D464-9FA4-49A9-B83E-7151D0165323}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DSharpPlus.Commands", "Libs\DSharpPlus\DSharpPlus.Commands\DSharpPlus.Commands.csproj", "{68B430C9-249C-4166-B9A1-369596A4A964}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DSharpPlus.Interactivity", "Libs\DSharpPlus\DSharpPlus.Interactivity\DSharpPlus.Interactivity.csproj", "{4D977814-F030-4643-BF67-741FDA152D6A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DSharpPlus.Rest", "Libs\DSharpPlus\DSharpPlus.Rest\DSharpPlus.Rest.csproj", "{C7A08C2E-6CB7-4B8F-BE22-BA835749D3F4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -30,22 +20,6 @@ Global
{13E4FD67-0ADF-48D0-9EF7-837991B465A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{13E4FD67-0ADF-48D0-9EF7-837991B465A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{13E4FD67-0ADF-48D0-9EF7-837991B465A8}.Release|Any CPU.Build.0 = Release|Any CPU
{4621D464-9FA4-49A9-B83E-7151D0165323}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4621D464-9FA4-49A9-B83E-7151D0165323}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4621D464-9FA4-49A9-B83E-7151D0165323}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4621D464-9FA4-49A9-B83E-7151D0165323}.Release|Any CPU.Build.0 = Release|Any CPU
{68B430C9-249C-4166-B9A1-369596A4A964}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{68B430C9-249C-4166-B9A1-369596A4A964}.Debug|Any CPU.Build.0 = Debug|Any CPU
{68B430C9-249C-4166-B9A1-369596A4A964}.Release|Any CPU.ActiveCfg = Release|Any CPU
{68B430C9-249C-4166-B9A1-369596A4A964}.Release|Any CPU.Build.0 = Release|Any CPU
{4D977814-F030-4643-BF67-741FDA152D6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4D977814-F030-4643-BF67-741FDA152D6A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D977814-F030-4643-BF67-741FDA152D6A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D977814-F030-4643-BF67-741FDA152D6A}.Release|Any CPU.Build.0 = Release|Any CPU
{C7A08C2E-6CB7-4B8F-BE22-BA835749D3F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C7A08C2E-6CB7-4B8F-BE22-BA835749D3F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C7A08C2E-6CB7-4B8F-BE22-BA835749D3F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C7A08C2E-6CB7-4B8F-BE22-BA835749D3F4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
7 changes: 3 additions & 4 deletions ModularAssistentForDiscordServer/Commands/Slash/BotStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// limitations under the License.

using System.ComponentModel;
using System.Configuration;
using System.Diagnostics;
using DSharpPlus;
using DSharpPlus.Commands;
Expand Down Expand Up @@ -51,14 +50,14 @@ public async Task GetBotStatsAsync(CommandContext ctx)

_ = await _discordRestClient.GetChannelAsync(ctx.Channel.Id);
swRest.Start();
_ = await _discordRestClient.GetChannelAsync(ctx.Channel.Id);
_ = await _discordRestClient.GetUserAsync(ctx.User.Id);
swRest.Stop();

using Process process = Process.GetCurrentProcess();

int members = db.Users.Count();
int guilds = db.Guilds.Count();
//int ping = ctx.Client.Ping;
TimeSpan ping = ctx.Client.GetConnectionLatency(0);
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true, true);
string heapMemory = $"{process.PrivateMemorySize64 / 1024 / 1024} MB";

Expand All @@ -69,7 +68,7 @@ public async Task GetBotStatsAsync(CommandContext ctx)
.AddField("Membercount:", members.ToString("N0"), true)
.AddField("Guildcount:", guilds.ToString("N0"), true)
.AddField("Threads:", $"{ThreadPool.ThreadCount}", true)
//.AddField("Websocket Latency:", ping.ToString("N0") + " ms", true)
.AddField("Websocket Latency (Shard 0):", ping.TotalMilliseconds.ToString("N0") + " ms", true)
.AddField("DB Latency:", swDb.ElapsedMilliseconds.ToString("N0") + " ms", true)
.AddField("Rest Latency:", swRest.ElapsedMilliseconds.ToString("N0") + " ms", true)
.AddField("Memory:", heapMemory, true)
Expand Down
14 changes: 6 additions & 8 deletions ModularAssistentForDiscordServer/Extensions/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using DSharpPlus;
using DSharpPlus.Entities;
using DSharpPlus.Net;
using MADS.Entities;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
Expand All @@ -23,16 +24,13 @@ namespace MADS.Extensions;

public static class ExtensionMethods
{

public static IServiceCollection AddDiscordRestClient(this IServiceCollection serviceCollection,
MadsConfig config)
MadsConfig config)
{
DiscordConfiguration discordRestConfig = new()
{

};
RestClientOptions discordRestConfig = new();

serviceCollection.AddSingleton(new DiscordRestClient(discordRestConfig, config.Token, TokenType.Bot));
serviceCollection.AddSingleton(services => new DiscordRestClient(discordRestConfig, config.Token, TokenType.Bot,
services.GetRequiredService<ILogger<RestClient>>()));
return serviceCollection;
}

Expand All @@ -51,7 +49,7 @@ public static async Task<DiscordEmbed> GetEmbedAsync(this QuoteDbEntity quote, D
}

public static async Task<DiscordMessageBuilder> GetMessageAsync(this ReminderDbEntity reminder,
DiscordClient client)
DiscordClient client)
{
DiscordMessageBuilder message = new();
if (reminder.MentionedMessage != 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@

<ItemGroup>
<PackageReference Include="DeepL.net" Version="1.9.0" />
<PackageReference Include="DSharpPlus" Version="5.0.0-nightly-02312" />
<PackageReference Include="DSharpPlus.Commands" Version="5.0.0-nightly-02312" />
<PackageReference Include="DSharpPlus.Interactivity" Version="5.0.0-nightly-02312" />
<PackageReference Include="DSharpPlus.Rest" Version="5.0.0-nightly-02312" />
<PackageReference Include="EntityFramework" Version="6.5.1" />
<PackageReference Include="FlexLabs.EntityFrameworkCore.Upsert" Version="8.0.0" />
<PackageReference Include="Humanizer" Version="3.0.0-beta.13" />
Expand All @@ -50,11 +54,4 @@
<PackageReference Include="Testcontainers" Version="3.9.0" />
<PackageReference Include="Testcontainers.MariaDb" Version="3.9.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Libs\DSharpPlus\DSharpPlus.Commands\DSharpPlus.Commands.csproj" />
<ProjectReference Include="..\Libs\DSharpPlus\DSharpPlus.Interactivity\DSharpPlus.Interactivity.csproj" />
<ProjectReference Include="..\Libs\DSharpPlus\DSharpPlus.Rest\DSharpPlus.Rest.csproj" />
<ProjectReference Include="..\Libs\DSharpPlus\DSharpPlus\DSharpPlus.csproj" />
</ItemGroup>
</Project>
5 changes: 5 additions & 0 deletions ModularAssistentForDiscordServer/ModularDiscordBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using DSharpPlus;
using DSharpPlus.Clients;
using DSharpPlus.Extensions;
using DSharpPlus.Net;
using MADS.Entities;
using MADS.EventListeners;
using MADS.Extensions;
Expand Down Expand Up @@ -64,6 +65,10 @@ await Host.CreateDefaultBuilder()
x.HandleZombied(EventListener.OnZombied);
x.HandleMessageCreated(EventListener.DmHandler);
})
.Configure<RestClientOptions>(x =>
{
x.Timeout = TimeSpan.FromSeconds(30);
})
.AddSingleton<DiscordCommandService>()
.AddHostedService(s => s.GetRequiredService<DiscordCommandService>())
.AddDbContextFactory<MadsContext>(
Expand Down

0 comments on commit 9e12630

Please sign in to comment.