From 9a67252a3f230b4b20d194b13ed73c6afe75a4a6 Mon Sep 17 00:00:00 2001 From: SquirrelKiev Date: Sun, 28 Apr 2024 01:54:08 +0100 Subject: [PATCH] some updates --- DibariBot.sln.DotSettings | 5 +++ DibariBot/Apis/MangadexApi.cs | 13 ++----- DibariBot/Apis/PhixivApi.cs | 14 +++----- DibariBot/Apis/QueryStringSerializer.cs | 5 +-- DibariBot/Core/Database/BotDbContext.cs | 6 +--- DibariBot/DibariBot.csproj | 4 +-- DibariBot/Modules/About/AboutModule.cs | 10 +++--- .../ConfigCommand/ConfigCommandModule.cs | 18 +++++----- .../ConfigCommand/ConfigCommandService.cs | 7 +--- .../ConfigCommand/Pages/DefaultMangaPage.cs | 16 ++------- .../ConfigCommand/Pages/RegexFiltersPage.cs | 35 +++++-------------- DibariBot/Modules/Help/HelpModule.cs | 17 +++------ DibariBot/Modules/MDSearch/SearchModule.cs | 19 +++------- DibariBot/Modules/Manga/MangaModule.cs | 13 ++----- DibariBot/Modules/Manga/MangaService.cs | 7 ++-- 15 files changed, 57 insertions(+), 132 deletions(-) diff --git a/DibariBot.sln.DotSettings b/DibariBot.sln.DotSettings index 562552d..8a3a1ff 100644 --- a/DibariBot.sln.DotSettings +++ b/DibariBot.sln.DotSettings @@ -2,6 +2,11 @@ <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Instance" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Instance fields (not private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static fields (not private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> + True True True True diff --git a/DibariBot/Apis/MangadexApi.cs b/DibariBot/Apis/MangadexApi.cs index a526ca4..9c7b03f 100644 --- a/DibariBot/Apis/MangadexApi.cs +++ b/DibariBot/Apis/MangadexApi.cs @@ -4,17 +4,10 @@ namespace DibariBot.Apis; [Inject(Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton)] -public class MangaDexApi +public class MangaDexApi(IHttpClientFactory http, ICacheProvider cache, BotConfig botConfig) { - private readonly Api api; - private readonly Uri baseUri; - - public MangaDexApi(IHttpClientFactory http, ICacheProvider cache, BotConfig botConfig) - { - api = new Api(http, cache); - - baseUri = new Uri(botConfig.MangaDexApiUrl); - } + private readonly Api api = new(http, cache); + private readonly Uri baseUri = new(botConfig.MangaDexApiUrl); public async Task GetMangas(MangaListQueryParams queryParams) { diff --git a/DibariBot/Apis/PhixivApi.cs b/DibariBot/Apis/PhixivApi.cs index 9bca582..feb1144 100644 --- a/DibariBot/Apis/PhixivApi.cs +++ b/DibariBot/Apis/PhixivApi.cs @@ -4,20 +4,14 @@ namespace DibariBot.Apis; [Inject(ServiceLifetime.Singleton)] -public class PhixivApi +public class PhixivApi(IHttpClientFactory http, ICacheProvider cache, BotConfig botConfig) { - private readonly Api api; - private readonly Uri baseUri; + private readonly Api api = new(http, cache); + private readonly Uri baseUri = new(botConfig.PhixivUrl); //private readonly BotConfig botConfig; - public PhixivApi(IHttpClientFactory http, ICacheProvider cache, BotConfig botConfig) - { - //this.botConfig = botConfig; - api = new Api(http, cache); - - baseUri = new Uri(botConfig.PhixivUrl); - } + //this.botConfig = botConfig; public Task GetById(string id) { diff --git a/DibariBot/Apis/QueryStringSerializer.cs b/DibariBot/Apis/QueryStringSerializer.cs index c3a44ed..a02c185 100644 --- a/DibariBot/Apis/QueryStringSerializer.cs +++ b/DibariBot/Apis/QueryStringSerializer.cs @@ -6,8 +6,9 @@ namespace DibariBot.Apis; -// gotta be a faster way of doing this, like,, why is this not built in in some form +// gotta be a faster way of doing this, like, why is this not built-in in some form // if perf was a concern this wouldn't exist +// future me: literally just use Fergun.Interactive why did you do all this work lol public static class QueryStringSerializer { public static string ToQueryParams(object obj) @@ -20,7 +21,7 @@ public static string ToQueryParams(object obj) return string.Join("&", dict.Select(kvp => $"{kvp.Key}={kvp.Value}")); } - public static Dictionary? ToUrlEncodedKeyValue(object obj) + public static Dictionary? ToUrlEncodedKeyValue(object? obj) { if (obj == null) { diff --git a/DibariBot/Core/Database/BotDbContext.cs b/DibariBot/Core/Database/BotDbContext.cs index bf43fd6..88c4341 100644 --- a/DibariBot/Core/Database/BotDbContext.cs +++ b/DibariBot/Core/Database/BotDbContext.cs @@ -4,16 +4,12 @@ namespace DibariBot.Database { - public class BotDbContext : BotDbContextBase + public class BotDbContext(string connectionString) : BotDbContextPrefixBase(connectionString) { public DbSet DefaultMangas { get; set; } public DbSet RegexFilters { get; set; } public DbSet RegexChannelEntries { get; set; } - public BotDbContext(string connectionString) : base(connectionString) - { - } - protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity() diff --git a/DibariBot/DibariBot.csproj b/DibariBot/DibariBot.csproj index 37086e2..4c3f7c7 100644 --- a/DibariBot/DibariBot.csproj +++ b/DibariBot/DibariBot.csproj @@ -8,9 +8,9 @@ - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/DibariBot/Modules/About/AboutModule.cs b/DibariBot/Modules/About/AboutModule.cs index c152ee1..42bc648 100644 --- a/DibariBot/Modules/About/AboutModule.cs +++ b/DibariBot/Modules/About/AboutModule.cs @@ -3,15 +3,13 @@ namespace DibariBot.Modules.About; -public class AboutModule : AboutModuleImpl +[CommandContextType(InteractionContextType.Guild, InteractionContextType.BotDm, InteractionContextType.PrivateChannel)] +[IntegrationType(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)] +public class AboutModule(AboutService aboutService, OverrideTrackerService overrideTrackerService) +: AboutModuleImpl(aboutService, overrideTrackerService) { - public AboutModule(AboutService aboutService, OverrideTrackerService overrideTrackerService) : base(aboutService, overrideTrackerService) - { - } - [SlashCommand("about", "Info about the bot.")] [HelpPageDescription("Pulls up info about the bot.")] - [EnabledInDm(true)] public override Task AboutSlash() { return base.AboutSlash(); diff --git a/DibariBot/Modules/ConfigCommand/ConfigCommandModule.cs b/DibariBot/Modules/ConfigCommand/ConfigCommandModule.cs index 799cf2b..0b42861 100644 --- a/DibariBot/Modules/ConfigCommand/ConfigCommandModule.cs +++ b/DibariBot/Modules/ConfigCommand/ConfigCommandModule.cs @@ -5,17 +5,15 @@ namespace DibariBot.Modules.ConfigCommand; -public class ConfigCommandModule : ConfigCommandModuleBase +[CommandContextType(InteractionContextType.Guild, InteractionContextType.BotDm, InteractionContextType.PrivateChannel)] +[IntegrationType(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)] +[RequireUserPermission(GuildPermission.ManageGuild, Group = BaseModulePrefixes.PERMISSION_GROUP)] +[RequireContext(ContextType.DM | ContextType.Group, Group = BaseModulePrefixes.PERMISSION_GROUP)] +[HasOverride(Group = BaseModulePrefixes.PERMISSION_GROUP)] +public class ConfigCommandModule(ConfigCommandServiceBase configService) + : ConfigCommandModuleBase(configService) { - public ConfigCommandModule(ConfigCommandServiceBase configService) : base(configService) - { - } - - [SlashCommand("config", "Pulls up various options for configuring the bot to the server's needs.")] - [RequireUserPermission(GuildPermission.ManageGuild, Group = BaseModulePrefixes.PERMISSION_GROUP)] - [RequireContext(ContextType.DM | ContextType.Group, Group = BaseModulePrefixes.PERMISSION_GROUP)] - [HasOverride(Group = BaseModulePrefixes.PERMISSION_GROUP)] - [EnabledInDm(true)] + [SlashCommand("config", "Pulls up various options for configuring the bot.")] public override Task ConfigSlash() { return base.ConfigSlash(); diff --git a/DibariBot/Modules/ConfigCommand/ConfigCommandService.cs b/DibariBot/Modules/ConfigCommand/ConfigCommandService.cs index bbe47b0..6fe9cca 100644 --- a/DibariBot/Modules/ConfigCommand/ConfigCommandService.cs +++ b/DibariBot/Modules/ConfigCommand/ConfigCommandService.cs @@ -3,9 +3,4 @@ namespace DibariBot.Modules.ConfigCommand; -public class ConfigCommandService : ConfigCommandServiceBase -{ - public ConfigCommandService(IServiceProvider services) : base(services) - { - } -} \ No newline at end of file +public class ConfigCommandService(IServiceProvider services) : ConfigCommandServiceBase(services); \ No newline at end of file diff --git a/DibariBot/Modules/ConfigCommand/Pages/DefaultMangaPage.cs b/DibariBot/Modules/ConfigCommand/Pages/DefaultMangaPage.cs index 066e55e..de5c035 100644 --- a/DibariBot/Modules/ConfigCommand/Pages/DefaultMangaPage.cs +++ b/DibariBot/Modules/ConfigCommand/Pages/DefaultMangaPage.cs @@ -1,6 +1,5 @@ using DibariBot.Database; using BotBase; -using BotBase.Database; using BotBase.Modules; using BotBase.Modules.ConfigCommand; using Microsoft.EntityFrameworkCore; @@ -8,6 +7,9 @@ namespace DibariBot.Modules.ConfigCommand.Pages; +[RequireUserPermission(GuildPermission.ManageGuild, Group = BaseModulePrefixes.PERMISSION_GROUP)] +[RequireContext(ContextType.DM | ContextType.Group, Group = BaseModulePrefixes.PERMISSION_GROUP)] +[HasOverride(Group = BaseModulePrefixes.PERMISSION_GROUP)] public class DefaultMangaPage : ConfigPage { public class DefaultMangaSetModal : IModal @@ -114,8 +116,6 @@ private static EmbedBuilder GetCurrentDefaultsEmbed(DefaultManga[] defaults) } [ComponentInteraction(ModulePrefixes.CONFIG_DEFAULT_MANGA_REMOVE_DROPDOWN)] - [RequireUserPermission(GuildPermission.ManageGuild, Group = BaseModulePrefixes.PERMISSION_GROUP)] - [HasOverride(Group = BaseModulePrefixes.PERMISSION_GROUP)] public async Task RemoveMangaDropdown(string id) { await DeferAsync(); @@ -142,8 +142,6 @@ await ModifyOriginalResponseAsync(await GetMessageContents( } [ComponentInteraction(ModulePrefixes.CONFIG_DEFAULT_MANGA_REMOVE)] - [RequireUserPermission(GuildPermission.ManageGuild, Group = BaseModulePrefixes.PERMISSION_GROUP)] - [HasOverride(Group = BaseModulePrefixes.PERMISSION_GROUP)] public async Task RemoveMangaButton() { await DeferAsync(); @@ -190,8 +188,6 @@ await ModifyOriginalResponseAsync(new MessageContents(string.Empty, embed.Build( } [ComponentInteraction(ModulePrefixes.CONFIG_DEFAULT_MANGA_SET)] - [RequireUserPermission(GuildPermission.ManageGuild, Group = BaseModulePrefixes.PERMISSION_GROUP)] - [HasOverride(Group = BaseModulePrefixes.PERMISSION_GROUP)] public async Task OpenModal() { await RespondWithModalAsync(ModulePrefixes.CONFIG_DEFAULT_MANGA_SET_MODAL); @@ -199,8 +195,6 @@ public async Task OpenModal() // step 2 - confirm section [ModalInteraction($"{ModulePrefixes.CONFIG_DEFAULT_MANGA_SET_MODAL}")] - [RequireUserPermission(GuildPermission.ManageGuild, Group = BaseModulePrefixes.PERMISSION_GROUP)] - [HasOverride(Group = BaseModulePrefixes.PERMISSION_GROUP)] public async Task OnModalResponse(DefaultMangaSetModal modal) { await DeferAsync(); @@ -227,8 +221,6 @@ public async Task OnModalResponse(DefaultMangaSetModal modal) } [ComponentInteraction(ModulePrefixes.CONFIG_DEFAULT_MANGA_SET_CHANNEL_INPUT + "*")] - [RequireUserPermission(GuildPermission.ManageGuild, Group = BaseModulePrefixes.PERMISSION_GROUP)] - [HasOverride(Group = BaseModulePrefixes.PERMISSION_GROUP)] public async Task OnChannelSet(string id, IChannel[] channel) { // should be doing UpdateAsync but i have no clue how to get that kekw @@ -276,8 +268,6 @@ private MessageContents ConfirmPromptContents(ConfirmState confirmState) // step 3 - we've got a submit!! [ComponentInteraction(ModulePrefixes.CONFIG_DEFAULT_MANGA_SET_SUBMIT_BUTTON + "*")] - [RequireUserPermission(GuildPermission.ManageGuild, Group = BaseModulePrefixes.PERMISSION_GROUP)] - [HasOverride(Group = BaseModulePrefixes.PERMISSION_GROUP)] public async Task OnConfirmed(string id) { await DeferAsync(); diff --git a/DibariBot/Modules/ConfigCommand/Pages/RegexFiltersPage.cs b/DibariBot/Modules/ConfigCommand/Pages/RegexFiltersPage.cs index b58b50a..34af2ca 100644 --- a/DibariBot/Modules/ConfigCommand/Pages/RegexFiltersPage.cs +++ b/DibariBot/Modules/ConfigCommand/Pages/RegexFiltersPage.cs @@ -9,7 +9,13 @@ namespace DibariBot.Modules.ConfigCommand.Pages; -public partial class RegexFiltersPage : ConfigPage +[RequireUserPermission(GuildPermission.ManageGuild, Group = BaseModulePrefixes.PERMISSION_GROUP)] +[HasOverride(Group = BaseModulePrefixes.PERMISSION_GROUP)] +public partial class RegexFiltersPage( + MangaService mangaService, + ConfigCommandServiceBase configCommandService, + BotConfig config) + : ConfigPage { public class SetRegexModal : IModal { @@ -36,16 +42,7 @@ public class SetRegexModal : IModal private const string EMBED_NAME_FILTER_TYPE = "Filter Type"; private const string EMBED_NAME_SCOPE = "Channel Scope"; - private readonly MangaService mangaService; - private readonly ConfigCommandServiceBase configCommandService; - private readonly BotConfig config; - - public RegexFiltersPage(MangaService mangaService, ConfigCommandServiceBase configCommandService, BotConfig config) - { - this.mangaService = mangaService; - this.configCommandService = configCommandService; - this.config = config; - } + private readonly BotConfig config = config; public override async Task GetMessageContents(ConfigCommandServiceBase.State state) { @@ -125,8 +122,6 @@ private static SelectMenuBuilder GetFilterSelectMenu(string customId, IEnumerabl } [ComponentInteraction(ModulePrefixes.CONFIG_FILTERS_REMOVE_BUTTON)] - [RequireUserPermission(GuildPermission.ManageGuild, Group = BaseModulePrefixes.PERMISSION_GROUP)] - [HasOverride(Group = BaseModulePrefixes.PERMISSION_GROUP)] private async Task RemoveButton() { await DeferAsync(); @@ -143,8 +138,6 @@ await ModifyOriginalResponseAsync(x => } [ComponentInteraction(ModulePrefixes.CONFIG_FILTERS_REMOVE_FILTER_SELECT)] - [RequireUserPermission(GuildPermission.ManageGuild, Group = BaseModulePrefixes.PERMISSION_GROUP)] - [HasOverride(Group = BaseModulePrefixes.PERMISSION_GROUP)] private async Task RemoveFilterSelectChanged(string id) { await DeferAsync(); @@ -163,8 +156,6 @@ private async Task RemoveFilterSelectChanged(string id) } [ComponentInteraction(ModulePrefixes.CONFIG_FILTERS_EDIT_BUTTON)] - [RequireUserPermission(GuildPermission.ManageGuild, Group = BaseModulePrefixes.PERMISSION_GROUP)] - [HasOverride(Group = BaseModulePrefixes.PERMISSION_GROUP)] private async Task EditButton() { await DeferAsync(); @@ -181,8 +172,6 @@ await ModifyOriginalResponseAsync(x => } [ComponentInteraction(ModulePrefixes.CONFIG_FILTERS_EDIT_FILTER_SELECT)] - [RequireUserPermission(GuildPermission.ManageGuild, Group = BaseModulePrefixes.PERMISSION_GROUP)] - [HasOverride(Group = BaseModulePrefixes.PERMISSION_GROUP)] private async Task EditFilterSelectChanged(string id) { await DeferAsync(); @@ -199,8 +188,6 @@ private async Task EditFilterSelectChanged(string id) } [ComponentInteraction(ModulePrefixes.CONFIG_FILTERS_OPEN_MODAL_BUTTON + "*")] - [RequireUserPermission(GuildPermission.ManageGuild, Group = BaseModulePrefixes.PERMISSION_GROUP)] - [HasOverride(Group = BaseModulePrefixes.PERMISSION_GROUP)] public async Task OpenModalButton(uint id) { RegexFilter? filter = null; @@ -257,8 +244,6 @@ public async Task ModalResponse(bool existing, SetRegexModal modal) } [ComponentInteraction(ModulePrefixes.CONFIG_FILTERS_CONFIRMATION_ADD_BUTTON)] - [RequireUserPermission(GuildPermission.ManageGuild, Group = BaseModulePrefixes.PERMISSION_GROUP)] - [HasOverride(Group = BaseModulePrefixes.PERMISSION_GROUP)] private async Task ConfirmationAddButton() { await DeferAsync(); @@ -383,8 +368,6 @@ private MessageContents UpsertConfirmation(RegexFilter filter) } [ComponentInteraction(ModulePrefixes.CONFIG_FILTERS_CONFIRMATION_CHANNEL_SELECT)] - [RequireUserPermission(GuildPermission.ManageGuild, Group = BaseModulePrefixes.PERMISSION_GROUP)] - [HasOverride(Group = BaseModulePrefixes.PERMISSION_GROUP)] private async Task UpsertConfirmationChannelSelectChanged(IChannel[] channels) { await DeferAsync(); @@ -407,8 +390,6 @@ private async Task UpsertConfirmationFilterTypeChanged(string id) } [ComponentInteraction(ModulePrefixes.CONFIG_FILTERS_CONFIRMATION_CHANNEL_SCOPE)] - [RequireUserPermission(GuildPermission.ManageGuild, Group = BaseModulePrefixes.PERMISSION_GROUP)] - [HasOverride(Group = BaseModulePrefixes.PERMISSION_GROUP)] private async Task UpsertConfirmationChannelScopeChanged(string id) { await DeferAsync(); diff --git a/DibariBot/Modules/Help/HelpModule.cs b/DibariBot/Modules/Help/HelpModule.cs index a77808a..ac3cf75 100644 --- a/DibariBot/Modules/Help/HelpModule.cs +++ b/DibariBot/Modules/Help/HelpModule.cs @@ -5,22 +5,13 @@ namespace DibariBot.Modules.Help; -public class HelpModule : BotModule +[CommandContextType(InteractionContextType.Guild, InteractionContextType.BotDm, InteractionContextType.PrivateChannel)] +[IntegrationType(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)] +public class HelpModule(DbService dbService, HelpService helpService, BotConfigBase botConfig) + : BotModule { - private readonly DbService dbService; - private readonly HelpService helpService; - private readonly BotConfigBase botConfig; - - public HelpModule(DbService dbService, HelpService helpService, BotConfigBase botConfig) - { - this.dbService = dbService; - this.helpService = helpService; - this.botConfig = botConfig; - } - [SlashCommand("help", "Help! What are all the commands?")] [HelpPageDescription("Pulls up this page!")] - [EnabledInDm(true)] public async Task HelpSlash() { await DeferAsync(); diff --git a/DibariBot/Modules/MDSearch/SearchModule.cs b/DibariBot/Modules/MDSearch/SearchModule.cs index 24be36e..cc88614 100644 --- a/DibariBot/Modules/MDSearch/SearchModule.cs +++ b/DibariBot/Modules/MDSearch/SearchModule.cs @@ -1,27 +1,18 @@ using BotBase; -using BotBase.Modules; using DibariBot.Modules.Manga; namespace DibariBot.Modules.MDSearch; -public class SearchModule : BotModule +[CommandContextType(InteractionContextType.Guild, InteractionContextType.BotDm, InteractionContextType.PrivateChannel)] +[IntegrationType(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)] +public class SearchModule(SearchService search, MangaService mangaService) : BotModule { - private readonly SearchService searchService; - private readonly MangaService mangaService; - - public SearchModule(SearchService search, MangaService mangaService) - { - searchService = search; - this.mangaService = mangaService; - } - [SlashCommand("manga-search", "Searches MangaDex for the query provided. (searches titles, sorted by relevance)")] - [EnabledInDm(true)] public async Task SearchSlash(string query, bool ephemeral = false, bool spoiler = false) { await DeferAsync(ephemeral); - await FollowupAsync(await searchService.GetMessageContents(new SearchService.State() { query = query, isSpoiler = spoiler})); + await FollowupAsync(await search.GetMessageContents(new SearchService.State() { query = query, isSpoiler = spoiler})); } [ComponentInteraction(ModulePrefixes.MANGADEX_SEARCH_BUTTON_PREFIX + "*")] @@ -31,7 +22,7 @@ public async Task SearchButtonInteraction(string id) var state = StateSerializer.DeserializeObject(id); - await ModifyOriginalResponseAsync(await searchService.GetMessageContents(state)); + await ModifyOriginalResponseAsync(await search.GetMessageContents(state)); } [ComponentInteraction(ModulePrefixes.MANGADEX_SEARCH_DROPDOWN_PREFIX + "*")] diff --git a/DibariBot/Modules/Manga/MangaModule.cs b/DibariBot/Modules/Manga/MangaModule.cs index bb9a9b5..078cacf 100644 --- a/DibariBot/Modules/Manga/MangaModule.cs +++ b/DibariBot/Modules/Manga/MangaModule.cs @@ -1,9 +1,10 @@ using BotBase; -using BotBase.Modules; namespace DibariBot.Modules.Manga; -public class MangaModule : BotModule +[CommandContextType(InteractionContextType.Guild, InteractionContextType.BotDm, InteractionContextType.PrivateChannel)] +[IntegrationType(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)] +public class MangaModule(MangaService mangaHandler) : BotModule { public class JumpModal : IModal { @@ -15,15 +16,7 @@ public class JumpModal : IModal public int Page { get; set; } } - private readonly MangaService mangaHandler; - - public MangaModule(MangaService mangaHandler) - { - this.mangaHandler = mangaHandler; - } - [SlashCommand("manga", "Gets a page from a chapter of a manga.")] - [EnabledInDm(true)] public async Task MangaSlash(string url = "", string chapter = "", int page = 1, bool ephemeral = false, bool spoiler = false) { await DeferAsync(ephemeral); diff --git a/DibariBot/Modules/Manga/MangaService.cs b/DibariBot/Modules/Manga/MangaService.cs index adb9573..76469f0 100644 --- a/DibariBot/Modules/Manga/MangaService.cs +++ b/DibariBot/Modules/Manga/MangaService.cs @@ -3,7 +3,6 @@ using System.Text.RegularExpressions; using DibariBot.Database; using BotBase; -using BotBase.Database; using DibariBot.Database.Models; using Microsoft.EntityFrameworkCore; @@ -78,7 +77,7 @@ public async Task MangaCommand(ulong guildId, ulong channelId, return new MessageContents(string.Empty, embed: new EmbedBuilder() .WithDescription( - "This server hasn't set a default manga! Please manually specify the URL.") // TODO: l18n + "This server/channel hasn't got a default manga set! Please manually specify the URL.") // TODO: l18n .WithColor(CommandResult.Failure) .Build(), null); } @@ -123,7 +122,7 @@ public async Task GetMangaMessage(ulong guildId, ulong channelI Log.Warning(ex, "Failed to get manga."); - return new MessageContents(string.Empty, errorEmbed, null); + return new MessageContents(string.Empty, errorEmbed); } var metadata = await manga.GetMetadata(); @@ -137,7 +136,7 @@ public async Task GetMangaMessage(ulong guildId, ulong channelI .WithColor(CommandResult.Failure) .Build(); - return new MessageContents(string.Empty, errorEmbed, null); + return new MessageContents(string.Empty, errorEmbed); } } catch (RegexMatchTimeoutException)