move classes around, name caches more consistently, add more caches
This commit is contained in:
parent
e86b37ce2a
commit
e17dcf90a1
30 changed files with 443 additions and 51 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using System.ComponentModel;
|
||||
using Catalogger.Backend.Cache;
|
||||
using Catalogger.Backend.Cache.InMemoryCache;
|
||||
using Catalogger.Backend.Database;
|
||||
using Catalogger.Backend.Database.Queries;
|
||||
using Catalogger.Backend.Extensions;
|
||||
|
|
@ -26,8 +27,8 @@ namespace Catalogger.Backend.Bot.Commands;
|
|||
public class ChannelCommands(
|
||||
ILogger logger,
|
||||
DatabaseContext db,
|
||||
GuildCacheService guildCache,
|
||||
ChannelCacheService channelCache,
|
||||
GuildCache guildCache,
|
||||
ChannelCache channelCache,
|
||||
IFeedbackService feedbackService,
|
||||
ContextInjectionService contextInjection,
|
||||
InMemoryDataService<Snowflake, ChannelCommandData> dataService) : CommandGroup
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Catalogger.Backend.Cache;
|
||||
using Catalogger.Backend.Cache.InMemoryCache;
|
||||
using Catalogger.Backend.Database;
|
||||
using Catalogger.Backend.Database.Queries;
|
||||
using Catalogger.Backend.Extensions;
|
||||
|
|
@ -22,8 +23,8 @@ namespace Catalogger.Backend.Bot.Commands;
|
|||
public class ChannelCommandsComponents(
|
||||
ILogger logger,
|
||||
DatabaseContext db,
|
||||
GuildCacheService guildCache,
|
||||
ChannelCacheService channelCache,
|
||||
GuildCache guildCache,
|
||||
ChannelCache channelCache,
|
||||
ContextInjectionService contextInjection,
|
||||
IFeedbackService feedbackService,
|
||||
IDiscordRestInteractionAPI interactionApi,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.Json;
|
||||
using App.Metrics;
|
||||
using Catalogger.Backend.Cache;
|
||||
using Catalogger.Backend.Cache.InMemoryCache;
|
||||
using Catalogger.Backend.Database;
|
||||
using Catalogger.Backend.Extensions;
|
||||
using Humanizer;
|
||||
|
|
@ -11,7 +13,11 @@ using Remora.Commands.Attributes;
|
|||
using Remora.Commands.Groups;
|
||||
using Remora.Discord.API.Abstractions.Objects;
|
||||
using Remora.Discord.API.Abstractions.Rest;
|
||||
using Remora.Discord.API.Objects;
|
||||
using Remora.Discord.Commands.Contexts;
|
||||
using Remora.Discord.Commands.Extensions;
|
||||
using Remora.Discord.Commands.Feedback.Services;
|
||||
using Remora.Discord.Commands.Services;
|
||||
using Remora.Discord.Extensions.Embeds;
|
||||
using Remora.Discord.Gateway;
|
||||
using Remora.Results;
|
||||
|
|
@ -26,8 +32,10 @@ public class MetaCommands(
|
|||
IMetrics metrics,
|
||||
DiscordGatewayClient client,
|
||||
IFeedbackService feedbackService,
|
||||
GuildCacheService guildCache,
|
||||
ChannelCacheService channelCache,
|
||||
ContextInjectionService contextInjection,
|
||||
IInviteCache inviteCache,
|
||||
GuildCache guildCache,
|
||||
ChannelCache channelCache,
|
||||
IDiscordRestChannelAPI channelApi) : CommandGroup
|
||||
{
|
||||
[Command("ping")]
|
||||
|
|
@ -65,4 +73,17 @@ public class MetaCommands(
|
|||
|
||||
return (Result)await channelApi.EditMessageAsync(msg.ChannelID, msg.ID, content: "", embeds: embeds);
|
||||
}
|
||||
|
||||
[Command("debug-invites")]
|
||||
[Description("Show a representation of this server's invites")]
|
||||
public async Task<IResult> DebugInvitesAsync()
|
||||
{
|
||||
if (contextInjection.Context is not IInteractionCommandContext ctx) throw new CataloggerError("No context");
|
||||
if (!ctx.TryGetGuildID(out var guildId)) throw new CataloggerError("No guild ID in context");
|
||||
|
||||
var invites = await inviteCache.TryGetAsync(guildId);
|
||||
var text = invites.Select(i => $"{i.Code} in {i.Channel?.ID.Value}");
|
||||
|
||||
return await feedbackService.SendContextualAsync(string.Join("\n", text));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue