Skip to content

Commit

Permalink
Update starboard and update d#+
Browse files Browse the repository at this point in the history
  • Loading branch information
Plerx2493 committed Oct 8, 2023
1 parent 94e4242 commit de1ea69
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 99 deletions.
8 changes: 5 additions & 3 deletions ModularAssistentForDiscordServer/Commands/Slash/Purge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ public async Task PurgeMessages
await ctx.CreateResponseAsync(InteractionResponseType.DeferredChannelMessageWithSource,
new DiscordInteractionResponseBuilder());
var response = await ctx.GetOriginalResponseAsync();

var messagesApi = await ctx.Channel.GetMessagesAsync((int) amount);

List<DiscordMessage> messages = new();
messages.AddRange(messagesApi);
await foreach (var msg in ctx.Channel.GetMessagesAsync((int) amount))
{
messages.Add(msg);
}

messages.RemoveAll(x => (DateTime.UtcNow - x.Timestamp).TotalDays >= 14);
messages.Remove(response);
Expand Down
21 changes: 18 additions & 3 deletions ModularAssistentForDiscordServer/Commands/Text/Base/ExitGuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
using DSharpPlus;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using MADS.Extensions;
using Microsoft.Extensions.DependencyInjection;

namespace MADS.Commands.Text.Base;

Expand All @@ -36,9 +38,22 @@ public async Task LeaveGuildOwner(CommandContext ctx)
}

[Command("test"), Description("Leave given server"), RequireGuild, Hidden, RequireOwner]
public async Task Test(CommandContext ctx)
public async Task Test(CommandContext ctx, DiscordChannel chnl, int limit)
{
var usr1 = await ctx.Client.GetUserAsync(262722553380864011);
await ctx.RespondAsync(usr1.Username);
var client = ModularDiscordBot.Services.GetRequiredService<DiscordRestClient>();
var channel = await client.GetChannelAsync(chnl.Id);
var messages = channel.GetMessagesAfterAsync(ctx.Message.Id + 1221);

messages.ToBlockingEnumerable().Count();


int i = 0;
await foreach (var message in messages)
{
i++;
}

await ctx.RespondAsync($"Found {i} messages");

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public static IServiceCollection AddDiscordRestClient(this IServiceCollection se
{
var discordRestConfig = new DiscordConfiguration
{
Token = config.Token
Token = config.Token,
LoggerFactory = new LoggerFactory().AddSerilog()
};

serviceCollection.AddSingleton(new DiscordRestClient(discordRestConfig));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0-preview.2.23128.3" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0-preview.7.23375.6" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
<PackageReference Include="Quartz" Version="3.6.2" />
<PackageReference Include="Quartz.Extensions.DependencyInjection" Version="3.6.2" />
<PackageReference Include="Quartz.Extensions.Hosting" Version="3.6.2" />
<PackageReference Include="Quartz.Jobs" Version="3.6.2" />
<PackageReference Include="Quartz.Serialization.Json" Version="3.6.2" />
<PackageReference Include="Serilog" Version="3.0.0-dev-02022" />
<PackageReference Include="Quartz" Version="3.7.0" />
<PackageReference Include="Quartz.Extensions.DependencyInjection" Version="3.7.0" />
<PackageReference Include="Quartz.Extensions.Hosting" Version="3.7.0" />
<PackageReference Include="Quartz.Jobs" Version="3.7.0" />
<PackageReference Include="Quartz.Serialization.Json" Version="3.7.0" />
<PackageReference Include="Serilog" Version="3.1.0-dev-02071" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="7.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.1-dev-00910" />
<PackageReference Include="DSharpPlus" Version="5.0.0-nightly-01717" />
<PackageReference Include="DSharpPlus.CommandsNext" Version="5.0.0-nightly-01717" />
<PackageReference Include="DSharpPlus.Interactivity" Version="5.0.0-nightly-01717" />
<PackageReference Include="DSharpPlus.Rest" Version="5.0.0-nightly-01717" />
<PackageReference Include="DSharpPlus.SlashCommands" Version="5.0.0-nightly-01717" />
<PackageReference Include="DSharpPlus.VoiceNext" Version="5.0.0-nightly-01717" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.2.0-dev-00918" />
<PackageReference Include="DSharpPlus" Version="5.0.0-nightly-01826" />
<PackageReference Include="DSharpPlus.CommandsNext" Version="5.0.0-nightly-01815" />
<PackageReference Include="DSharpPlus.Interactivity" Version="5.0.0-nightly-01815" />
<PackageReference Include="DSharpPlus.Rest" Version="5.0.0-nightly-01815" />
<PackageReference Include="DSharpPlus.SlashCommands" Version="5.0.0-nightly-01815" />
<PackageReference Include="DSharpPlus.VoiceNext" Version="5.0.0-nightly-01815" />
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions ModularAssistentForDiscordServer/ModularDiscordBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class ModularDiscordBot
{
public static IServiceProvider Services;
public static DateTimeOffset StartTime = DateTimeOffset.Now;
public static ILogger<ModularDiscordBot> Logger;
private readonly ConfigJson _config;

public ModularDiscordBot()
Expand Down Expand Up @@ -89,6 +90,7 @@ await Host.CreateDefaultBuilder()
.AddHostedService(s => s.GetRequiredService<VoiceAlertService>());

Services = services.BuildServiceProvider();
Logger = Services.GetRequiredService<ILogger<ModularDiscordBot>>();
}
)
.RunConsoleAsync();
Expand Down
Loading

0 comments on commit de1ea69

Please sign in to comment.