From 4ff2bd5581367bb8afd70af0c61a426cbead2ac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dorian=20Oszcz=C4=99da?= Date: Sat, 13 Jul 2024 12:42:13 +0100 Subject: [PATCH 1/3] misc: Remove redundant check. --- source/loaders/localisations.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/source/loaders/localisations.ts b/source/loaders/localisations.ts index f278c2486..fa5d33e80 100644 --- a/source/loaders/localisations.ts +++ b/source/loaders/localisations.ts @@ -26,10 +26,6 @@ async function loadLocalisations({ const localisationFiles: [language: LocalisationLanguage, path: string, normalise: boolean][] = []; for (const directoryPath of directoryPaths) { - if (!(await fs.stat(directoryPath)).isDirectory()) { - continue; - } - const normalise = directoryPath.endsWith("/commands") || directoryPath.endsWith("/parameters"); for (const entryPath of await fs.readdir(directoryPath)) { From b244cc76582e2c6112625600ea0af983c683d436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dorian=20Oszcz=C4=99da?= Date: Sat, 13 Jul 2024 12:44:50 +0100 Subject: [PATCH 2/3] style: Use type. --- source/library/stores/localisations.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/library/stores/localisations.ts b/source/library/stores/localisations.ts index 2d7b2a52c..2d1d6822e 100644 --- a/source/library/stores/localisations.ts +++ b/source/library/stores/localisations.ts @@ -42,7 +42,7 @@ class LocalisationStore { this.#localisations = LocalisationStore.#buildLocalisations(localisations); } - static #buildLocalisations(localisations: Map>): Localisations { + static #buildLocalisations(localisations: RawLocalisations): Localisations { const builders = new Map>(); for (const [key, languages] of localisations.entries()) { const processors = new Map(); From 5531c32e325ed3ae4bdac2a0e625d428ab81b7ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dorian=20Oszcz=C4=99da?= Date: Sat, 13 Jul 2024 14:25:22 +0100 Subject: [PATCH 3/3] misc: Remove rendundant calls to `.bind()`. --- .../adapters/dictionaries/dexonline.ts | 10 ++-- .../modal-composers/answer-composer.ts | 2 +- .../modal-composers/correction-composer.ts | 4 +- .../modal-composers/entry-request-composer.ts | 2 +- .../modal-composers/modal-composer.ts | 4 +- .../modal-composers/report-composer.ts | 2 +- .../modal-composers/resource-composer.ts | 2 +- .../modal-composers/suggestion-composer.ts | 2 +- .../modal-composers/ticket-composer.ts | 2 +- .../paginated-views/paginated-view.ts | 4 +- .../remove-song-listing-view.ts | 4 +- .../paginated-views/song-collection-view.ts | 2 +- .../paginated-views/song-listing-view.ts | 2 +- .../commands/components/role-selection.ts | 18 +++---- .../source-notices/recognition-notice.ts | 2 +- .../source-notices/source-notice.ts | 2 +- .../source-notices/tatoeba-source-notice.ts | 2 +- .../translation-source-notice.ts | 2 +- .../source-notices/word-source-notice.ts | 2 +- .../tabbed-views/cefr-guide-view.ts | 14 +++--- source/library/commands/fragments/licence.ts | 10 +--- .../commands/handlers/acknowledgements.ts | 5 +- source/library/commands/handlers/answer.ts | 19 ++----- .../library/commands/handlers/correction.ts | 31 +++--------- source/library/commands/handlers/credits.ts | 4 +- source/library/commands/handlers/game.ts | 4 +- .../commands/handlers/information/guild.ts | 20 ++------ .../commands/handlers/licence/software.ts | 10 +--- .../commands/handlers/list/warnings.ts | 6 +-- .../commands/handlers/music/fast-forward.ts | 8 +-- .../commands/handlers/music/history.ts | 4 +- .../library/commands/handlers/music/loop.ts | 15 +++--- source/library/commands/handlers/music/now.ts | 8 +-- .../library/commands/handlers/music/pause.ts | 4 +- .../library/commands/handlers/music/play.ts | 4 +- .../library/commands/handlers/music/queue.ts | 4 +- .../library/commands/handlers/music/remove.ts | 6 +-- .../library/commands/handlers/music/replay.ts | 6 +-- .../library/commands/handlers/music/resume.ts | 10 ++-- .../library/commands/handlers/music/rewind.ts | 15 ++---- .../commands/handlers/music/skip-to.ts | 11 ++-- .../library/commands/handlers/music/skip.ts | 20 +++----- .../library/commands/handlers/music/stop.ts | 6 +-- .../library/commands/handlers/music/unskip.ts | 27 +++------- .../commands/handlers/music/volume/display.ts | 4 +- .../commands/handlers/music/volume/set.ts | 6 +-- source/library/commands/handlers/pardon.ts | 7 +-- source/library/commands/handlers/policy.ts | 5 +- source/library/commands/handlers/praise.ts | 14 ++---- .../library/commands/handlers/profile/view.ts | 2 +- source/library/commands/handlers/purge.ts | 46 +++++------------ source/library/commands/handlers/recognise.ts | 49 ++++++------------ source/library/commands/handlers/report.ts | 13 +---- source/library/commands/handlers/resource.ts | 13 +---- source/library/commands/handlers/resources.ts | 4 +- source/library/commands/handlers/rule.ts | 9 ++-- .../handlers/settings/language/clear.ts | 5 +- .../handlers/settings/language/set.ts | 14 +++--- .../commands/handlers/settings/view.ts | 4 +- source/library/commands/handlers/slowmode.ts | 23 +++------ .../library/commands/handlers/suggestion.ts | 10 +--- .../library/commands/handlers/ticket/open.ts | 7 +-- .../commands/handlers/timeout/clear.ts | 8 +-- .../library/commands/handlers/timeout/set.ts | 11 ++-- source/library/commands/handlers/translate.ts | 50 +++++++------------ source/library/commands/handlers/warn.ts | 22 +++----- source/library/commands/handlers/word.ts | 35 ++++++------- source/library/commands/interactions.ts | 5 +- source/library/commands/praises.ts | 11 ++-- source/library/commands/resolvers/youtube.ts | 5 +- source/library/commands/rules.ts | 2 +- source/library/services/entry.ts | 18 +++---- .../services/interaction-repetition.ts | 4 +- source/library/services/music.ts | 25 ++++------ .../library/services/notices/information.ts | 15 ++---- source/library/services/notices/resources.ts | 10 +--- source/library/services/notices/roles.ts | 3 +- source/library/services/notices/welcome.ts | 5 +- source/library/services/prompts/reports.ts | 6 +-- source/library/services/prompts/resources.ts | 6 +-- source/library/services/prompts/service.ts | 4 +- .../library/services/prompts/suggestions.ts | 6 +-- source/library/services/prompts/tickets.ts | 8 +-- .../library/services/prompts/verification.ts | 20 ++++---- source/library/stores/interactions.ts | 5 +- .../journalling/discord/guild-ban-add.ts | 2 +- .../journalling/discord/guild-ban-remove.ts | 2 +- .../journalling/discord/guild-member-add.ts | 2 +- .../discord/guild-member-remove.ts | 2 +- .../journalling/discord/message-delete.ts | 2 +- .../journalling/discord/message-update.ts | 2 +- .../journalling/logos/entry-request-accept.ts | 2 +- .../journalling/logos/entry-request-reject.ts | 2 +- .../journalling/logos/entry-request-submit.ts | 4 +- .../stores/journalling/logos/inquiry-open.ts | 2 +- .../journalling/logos/member-timeout-add.ts | 2 +- .../logos/member-timeout-remove.ts | 2 +- .../journalling/logos/member-warn-add.ts | 2 +- .../journalling/logos/member-warn-remove.ts | 5 +- .../stores/journalling/logos/praise-add.ts | 2 +- .../stores/journalling/logos/purge-begin.ts | 2 +- .../stores/journalling/logos/purge-end.ts | 2 +- .../stores/journalling/logos/report-submit.ts | 2 +- .../stores/journalling/logos/resource-send.ts | 2 +- .../journalling/logos/slowmode-disable.ts | 2 +- .../journalling/logos/slowmode-downgrade.ts | 2 +- .../journalling/logos/slowmode-enable.ts | 2 +- .../journalling/logos/slowmode-upgrade.ts | 2 +- .../journalling/logos/suggestion-send.ts | 2 +- .../stores/journalling/logos/ticket-open.ts | 2 +- source/library/stores/localisations.ts | 2 +- 111 files changed, 329 insertions(+), 588 deletions(-) diff --git a/source/library/adapters/dictionaries/dexonline.ts b/source/library/adapters/dictionaries/dexonline.ts index 9ad845a62..e88883afd 100644 --- a/source/library/adapters/dictionaries/dexonline.ts +++ b/source/library/adapters/dictionaries/dexonline.ts @@ -147,7 +147,7 @@ class DexonlineAdapter extends DictionaryAdapter { } const strings = constants.contexts.dexonlinePronoun({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.parameters.show ? interaction.guildLocale : interaction.locale, }); return [ @@ -195,7 +195,7 @@ class DexonlineAdapter extends DictionaryAdapter { } const strings = constants.contexts.dexonlineNoun({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); const numberColumn = { @@ -301,7 +301,7 @@ class DexonlineAdapter extends DictionaryAdapter { ); const strings = constants.contexts.dexonlineVerb({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); return [ @@ -463,7 +463,7 @@ class DexonlineAdapter extends DictionaryAdapter { } const strings = constants.contexts.dexonlineAdjective({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); return [ @@ -500,7 +500,7 @@ class DexonlineAdapter extends DictionaryAdapter { } const strings = constants.contexts.dexonlineDeterminer({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); return [ diff --git a/source/library/commands/components/modal-composers/answer-composer.ts b/source/library/commands/components/modal-composers/answer-composer.ts index 831a10f83..cc23e24f5 100644 --- a/source/library/commands/components/modal-composers/answer-composer.ts +++ b/source/library/commands/components/modal-composers/answer-composer.ts @@ -13,7 +13,7 @@ class AnswerComposer extends ModalComposer { buildModal(submission: Logos.Interaction, { formData }: { formData: AnswerFormData }): Modal { const strings = constants.contexts.answerModal({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: submission.locale, }); diff --git a/source/library/commands/components/modal-composers/correction-composer.ts b/source/library/commands/components/modal-composers/correction-composer.ts index f9844defe..aa55a9ed1 100644 --- a/source/library/commands/components/modal-composers/correction-composer.ts +++ b/source/library/commands/components/modal-composers/correction-composer.ts @@ -27,7 +27,7 @@ class CorrectionComposer extends ModalComposer { const strings = constants.contexts.correctionModal({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: submission.locale, }); @@ -79,7 +79,7 @@ class CorrectionComposer extends ModalComposer { { formData }: { formData: EntryRequestFormData }, ): Modal { const strings = constants.contexts.verificationModal({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: submission.locale, }); return { diff --git a/source/library/commands/components/modal-composers/modal-composer.ts b/source/library/commands/components/modal-composers/modal-composer.ts index 4fc7ab7a7..11574eebe 100644 --- a/source/library/commands/components/modal-composers/modal-composer.ts +++ b/source/library/commands/components/modal-composers/modal-composer.ts @@ -134,7 +134,7 @@ abstract class ModalComposer { }); const strings = constants.contexts.sureToCancelReport({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: submission.locale, }); await this.client.warning(cancelButtonPress, { @@ -175,7 +175,7 @@ abstract class ModalComposer { await this.client.registerInteractionCollector(leaveButton); const strings = constants.contexts.failedToSubmitForm({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: submission.locale, }); diff --git a/source/library/commands/components/modal-composers/report-composer.ts b/source/library/commands/components/modal-composers/report-composer.ts index 17eff7e82..e8542b6ba 100644 --- a/source/library/commands/components/modal-composers/report-composer.ts +++ b/source/library/commands/components/modal-composers/report-composer.ts @@ -5,7 +5,7 @@ import type { ReportFormData } from "logos/models/report"; class ReportComposer extends ModalComposer { buildModal(submission: Logos.Interaction, { formData }: { formData: ReportFormData }): Modal { const strings = constants.contexts.reportModal({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: submission.locale, }); diff --git a/source/library/commands/components/modal-composers/resource-composer.ts b/source/library/commands/components/modal-composers/resource-composer.ts index 185eb7d59..e91ae815f 100644 --- a/source/library/commands/components/modal-composers/resource-composer.ts +++ b/source/library/commands/components/modal-composers/resource-composer.ts @@ -5,7 +5,7 @@ import type { ResourceFormData } from "logos/models/resource"; class ResourceComposer extends ModalComposer { buildModal(submission: Logos.Interaction, { formData }: { formData: ResourceFormData }): Modal { const strings = constants.contexts.resourceModal({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: submission.locale, }); return { diff --git a/source/library/commands/components/modal-composers/suggestion-composer.ts b/source/library/commands/components/modal-composers/suggestion-composer.ts index e739c6b95..6d2fe9cab 100644 --- a/source/library/commands/components/modal-composers/suggestion-composer.ts +++ b/source/library/commands/components/modal-composers/suggestion-composer.ts @@ -13,7 +13,7 @@ class SuggestionComposer extends ModalComposer { { formData }: { formData: SuggestionFormData }, ): Modal { const strings = constants.contexts.suggestionModal({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: submission.locale, }); diff --git a/source/library/commands/components/modal-composers/ticket-composer.ts b/source/library/commands/components/modal-composers/ticket-composer.ts index 8ef6c9b39..3ac085c6c 100644 --- a/source/library/commands/components/modal-composers/ticket-composer.ts +++ b/source/library/commands/components/modal-composers/ticket-composer.ts @@ -5,7 +5,7 @@ import type { TicketFormData } from "logos/models/ticket"; class TicketComposer extends ModalComposer { buildModal(submission: Logos.Interaction, { formData }: { formData: TicketFormData }): Modal { const strings = constants.contexts.ticketModal({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: submission.locale, }); diff --git a/source/library/commands/components/paginated-views/paginated-view.ts b/source/library/commands/components/paginated-views/paginated-view.ts index 8b0d9d185..d4fa83a43 100644 --- a/source/library/commands/components/paginated-views/paginated-view.ts +++ b/source/library/commands/components/paginated-views/paginated-view.ts @@ -40,7 +40,7 @@ abstract class PaginatedView { title = embed.title; } else { const strings = constants.contexts.page({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: this.#anchor.locale, }); @@ -49,7 +49,7 @@ abstract class PaginatedView { if (!this.#isOnLastPage) { const strings = constants.contexts.continuedOnNextPage({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: this.#anchor.locale, }); diff --git a/source/library/commands/components/paginated-views/remove-song-listing-view.ts b/source/library/commands/components/paginated-views/remove-song-listing-view.ts index 7fb2a92ee..857cb84ab 100644 --- a/source/library/commands/components/paginated-views/remove-song-listing-view.ts +++ b/source/library/commands/components/paginated-views/remove-song-listing-view.ts @@ -44,7 +44,7 @@ class RemoveSongListingView extends PaginatedView { build(interaction: Logos.Interaction, page: SongListing[], pageIndex: number): View { if (page.length === 0) { const strings = constants.contexts.queueEmpty({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); @@ -56,7 +56,7 @@ class RemoveSongListingView extends PaginatedView { const selectMenu = this.#buildSelectMenu(page, pageIndex); const strings = constants.contexts.selectSongToRemove({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); diff --git a/source/library/commands/components/paginated-views/song-collection-view.ts b/source/library/commands/components/paginated-views/song-collection-view.ts index fa6fd0e64..ce6358c01 100644 --- a/source/library/commands/components/paginated-views/song-collection-view.ts +++ b/source/library/commands/components/paginated-views/song-collection-view.ts @@ -24,7 +24,7 @@ class SongCollectionView extends PaginatedView { build(interaction: Logos.Interaction, page: Song[], pageIndex: number): View { if (page.length === 0) { const strings = constants.contexts.listEmpty({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); return { embed: { title: this.#title, description: strings.listEmpty, color: constants.colours.notice } }; diff --git a/source/library/commands/components/paginated-views/song-listing-view.ts b/source/library/commands/components/paginated-views/song-listing-view.ts index 6ac8493ca..f92e81801 100644 --- a/source/library/commands/components/paginated-views/song-listing-view.ts +++ b/source/library/commands/components/paginated-views/song-listing-view.ts @@ -17,7 +17,7 @@ class SongListingView extends PaginatedView { build(interaction: Logos.Interaction, page: SongListing[], pageIndex: number): View { if (page.length === 0) { const strings = constants.contexts.listEmpty({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); return { embed: { title: this.#title, description: strings.listEmpty, color: constants.colours.notice } }; diff --git a/source/library/commands/components/role-selection.ts b/source/library/commands/components/role-selection.ts index b9ee9c931..1cd6ad617 100644 --- a/source/library/commands/components/role-selection.ts +++ b/source/library/commands/components/role-selection.ts @@ -173,7 +173,7 @@ async function createRoleSelectionMenu( viewData.memberRolesIncludedInMenu.length >= viewData.category.maximum ) { const strings = constants.contexts.roleLimitReached({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); @@ -347,7 +347,7 @@ async function displaySelectMenu( const isInRootCategory = data.browsingData.navigationData.identifiersAccessed.length === 0; if (!isInRootCategory) { const strings = constants.contexts.previousRoleCategory({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); @@ -360,10 +360,10 @@ async function displaySelectMenu( } const strings = { - ...constants.contexts.roleMenu({ localise: client.localise.bind(client), locale: interaction.locale }), + ...constants.contexts.roleMenu({ localise: client.localise, locale: interaction.locale }), ...constants.contexts.role({ - localise: client.localise.bind(client), - localiseRaw: client.localiseRaw.bind(client), + localise: client.localise, + localiseRaw: client.localiseRaw, locale: interaction.locale, }), }; @@ -406,7 +406,7 @@ function createSelectOptionsFromCategories( const selections: Discord.SelectOption[] = []; for (const [name, category] of Object.entries(categorySelections)) { const strings = constants.contexts.roleCategory({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); selections.push({ @@ -441,10 +441,10 @@ function createSelectOptionsFromCollection( const memberHasRole = viewData.memberRolesIncludedInMenu.includes(roleResolved.id); const strings = { - ...constants.contexts.assignedRoles({ localise: client.localise.bind(client), locale: interaction.locale }), + ...constants.contexts.assignedRoles({ localise: client.localise, locale: interaction.locale }), ...constants.contexts.role({ - localise: client.localise.bind(client), - localiseRaw: client.localiseRaw.bind(client), + localise: client.localise, + localiseRaw: client.localiseRaw, locale: interaction.locale, }), }; diff --git a/source/library/commands/components/source-notices/recognition-notice.ts b/source/library/commands/components/source-notices/recognition-notice.ts index 02b6f2162..7788add15 100644 --- a/source/library/commands/components/source-notices/recognition-notice.ts +++ b/source/library/commands/components/source-notices/recognition-notice.ts @@ -5,7 +5,7 @@ import { SourceNotice } from "logos/commands/components/source-notices/source-no class RecognitionSourceNotice extends SourceNotice { constructor(client: Client, { interaction, sources }: { interaction: Logos.Interaction; sources: Licence[] }) { const strings = constants.contexts.recognitionsMadeBy({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.displayLocale, }); diff --git a/source/library/commands/components/source-notices/source-notice.ts b/source/library/commands/components/source-notices/source-notice.ts index 76133bc67..4941a2713 100644 --- a/source/library/commands/components/source-notices/source-notice.ts +++ b/source/library/commands/components/source-notices/source-notice.ts @@ -11,7 +11,7 @@ abstract class SourceNotice { get button(): Discord.ButtonComponent { const strings = constants.contexts.source({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: this.#interaction.displayLocale, }); diff --git a/source/library/commands/components/source-notices/tatoeba-source-notice.ts b/source/library/commands/components/source-notices/tatoeba-source-notice.ts index 49f6e2025..19bbe2771 100644 --- a/source/library/commands/components/source-notices/tatoeba-source-notice.ts +++ b/source/library/commands/components/source-notices/tatoeba-source-notice.ts @@ -14,7 +14,7 @@ class TatoebaSourceNotice extends SourceNotice { const translationLink = constants.links.tatoebaSentence(translationId.toString()); const strings = constants.contexts.sentencesSourcedFrom({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.displayLocale, }); super(client, { diff --git a/source/library/commands/components/source-notices/translation-source-notice.ts b/source/library/commands/components/source-notices/translation-source-notice.ts index 1f9392ae8..4c33d3be3 100644 --- a/source/library/commands/components/source-notices/translation-source-notice.ts +++ b/source/library/commands/components/source-notices/translation-source-notice.ts @@ -5,7 +5,7 @@ import { SourceNotice } from "logos/commands/components/source-notices/source-no class TranslationSourceNotice extends SourceNotice { constructor(client: Client, { interaction, source }: { interaction: Logos.Interaction; source: Licence }) { const strings = constants.contexts.translationsSourcedFrom({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.displayLocale, }); diff --git a/source/library/commands/components/source-notices/word-source-notice.ts b/source/library/commands/components/source-notices/word-source-notice.ts index fdea6f09e..d2fbb076e 100644 --- a/source/library/commands/components/source-notices/word-source-notice.ts +++ b/source/library/commands/components/source-notices/word-source-notice.ts @@ -4,7 +4,7 @@ import { SourceNotice } from "logos/commands/components/source-notices/source-no class WordSourceNotice extends SourceNotice { constructor(client: Client, { interaction, sources }: { interaction: Logos.Interaction; sources: string[] }) { const strings = constants.contexts.sourcedFromDictionaries({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.displayLocale, }); diff --git a/source/library/commands/components/tabbed-views/cefr-guide-view.ts b/source/library/commands/components/tabbed-views/cefr-guide-view.ts index 51e639ccf..20b5f4db0 100644 --- a/source/library/commands/components/tabbed-views/cefr-guide-view.ts +++ b/source/library/commands/components/tabbed-views/cefr-guide-view.ts @@ -48,7 +48,7 @@ class CefrGuideView extends TabbedView<{ groups: TabGroups }> { switch (bracket) { case "a": { const strings = constants.contexts.cefrGuideBracketA({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); @@ -77,7 +77,7 @@ class CefrGuideView extends TabbedView<{ groups: TabGroups }> { } case "b": { const strings = constants.contexts.cefrGuideBracketB({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); @@ -98,7 +98,7 @@ class CefrGuideView extends TabbedView<{ groups: TabGroups }> { } case "c": { const strings = constants.contexts.cefrGuideBracketC({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); @@ -137,7 +137,7 @@ class CefrGuideView extends TabbedView<{ groups: TabGroups }> { switch (bracket) { case "a": { const strings = constants.contexts.cefrExamplesBracketA({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); @@ -166,7 +166,7 @@ class CefrGuideView extends TabbedView<{ groups: TabGroups }> { } case "b": { const strings = constants.contexts.cefrExamplesBracketB({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); @@ -187,7 +187,7 @@ class CefrGuideView extends TabbedView<{ groups: TabGroups }> { } case "c": { const strings = constants.contexts.cefrExamplesBracketC({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); @@ -222,7 +222,7 @@ class CefrGuideView extends TabbedView<{ groups: TabGroups }> { { bracket, mode }: { bracket: Bracket; mode: Mode }, ): Discord.MessageComponents { const strings = constants.contexts.cefrButtons({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); diff --git a/source/library/commands/fragments/licence.ts b/source/library/commands/fragments/licence.ts index aefd77a12..b9caeb816 100644 --- a/source/library/commands/fragments/licence.ts +++ b/source/library/commands/fragments/licence.ts @@ -12,10 +12,7 @@ async function handleDisplayLicence( return; } - const strings = constants.contexts.licence({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.licence({ localise: client.localise, locale: interaction.locale }); await client.notice(interaction, { author: { @@ -43,10 +40,7 @@ async function handleDisplayLicence( } async function displayError(client: Client, interaction: Logos.Interaction): Promise { - const strings = constants.contexts.invalidLicence({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.invalidLicence({ localise: client.localise, locale: interaction.locale }); await client.error(interaction, { title: strings.title, diff --git a/source/library/commands/handlers/acknowledgements.ts b/source/library/commands/handlers/acknowledgements.ts index 3f94a04fd..f2200bbc6 100644 --- a/source/library/commands/handlers/acknowledgements.ts +++ b/source/library/commands/handlers/acknowledgements.ts @@ -1,10 +1,6 @@ import type { Client } from "logos/client"; async function handleDisplayAcknowledgements(client: Client, interaction: Logos.Interaction): Promise { - const strings = constants.contexts.acknowledgements({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); const fields = constants.acknowledgements.map((acknowledgement) => { const contributorsFormatted = acknowledgement.users.map((contributor) => contributor.username).join(", "); @@ -15,6 +11,7 @@ async function handleDisplayAcknowledgements(client: Client, interaction: Logos. }; }); + const strings = constants.contexts.acknowledgements({ localise: client.localise, locale: interaction.locale }); await client.notice(interaction, { title: strings.acknowledgements, fields, diff --git a/source/library/commands/handlers/answer.ts b/source/library/commands/handlers/answer.ts index e1e435f81..1e26f361f 100644 --- a/source/library/commands/handlers/answer.ts +++ b/source/library/commands/handlers/answer.ts @@ -13,30 +13,20 @@ async function handleAnswer(client: Client, interaction: Logos.Interaction): Pro } if (message.author.toggles?.has("bot") || message.content.trim().length === 0) { - const strings = constants.contexts.cannotAnswer({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); - + const strings = constants.contexts.cannotAnswer({ localise: client.localise, locale: interaction.locale }); await client.warning(interaction, { title: strings.title, description: strings.description, }); - return; } if (message.author.id === interaction.user.id) { - const strings = constants.contexts.cannotAnswerOwn({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); - + const strings = constants.contexts.cannotAnswerOwn({ localise: client.localise, locale: interaction.locale }); await client.warning(interaction, { title: strings.title, description: strings.description, }); - return; } @@ -45,10 +35,7 @@ async function handleAnswer(client: Client, interaction: Logos.Interaction): Pro composer.onSubmit(async (submission, { formData }) => { await client.acknowledge(submission); - const strings = constants.contexts.answer({ - localise: client.localise.bind(client), - locale: submission.locale, - }); + const strings = constants.contexts.answer({ localise: client.localise, locale: submission.locale }); await client.bot.helpers .sendMessage(message.channelId, { diff --git a/source/library/commands/handlers/correction.ts b/source/library/commands/handlers/correction.ts index 9a9d41735..d581cd113 100644 --- a/source/library/commands/handlers/correction.ts +++ b/source/library/commands/handlers/correction.ts @@ -27,30 +27,20 @@ async function handleMakeCorrection( } if (message.author.toggles?.has("bot") || message.content.trim().length === 0) { - const strings = constants.contexts.cannotCorrect({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); - + const strings = constants.contexts.cannotCorrect({ localise: client.localise, locale: interaction.locale }); await client.warning(interaction, { title: strings.title, description: strings.description, }); - return; } if (message.author.id === interaction.user.id) { - const strings = constants.contexts.cannotCorrectOwn({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); - + const strings = constants.contexts.cannotCorrectOwn({ localise: client.localise, locale: interaction.locale }); await client.warning(interaction, { title: strings.title, description: strings.description, }); - return; } @@ -65,32 +55,28 @@ async function handleMakeCorrection( if (doNotCorrectMeRoleId !== undefined) { if (correctedMember.roles.some((roleId) => roleId.toString() === doNotCorrectMeRoleId)) { const strings = constants.contexts.userDoesNotWantCorrections({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); - await client.warning(interaction, { title: strings.title, description: strings.description, }); - return; } } if (message.content.length > constants.MAXIMUM_CORRECTION_MESSAGE_LENGTH) { const strings = constants.contexts.correctionTooLong({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); - await client.warning(interaction, { title: strings.title, description: `${strings.description.tooLong} ${strings.description.maximumLength({ character_limit: constants.MAXIMUM_CORRECTION_MESSAGE_LENGTH, })}`, }); - return; } @@ -102,13 +88,8 @@ async function handleMakeCorrection( composer.onSubmit(async (submission, { formData }) => { await client.acknowledge(submission); - - const strings = constants.contexts.correction({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); - - client.bot.helpers + const strings = constants.contexts.correction({ localise: client.localise, locale: interaction.locale }); + await client.bot.helpers .sendMessage(message.channelId, { messageReference: { messageId: message.id, diff --git a/source/library/commands/handlers/credits.ts b/source/library/commands/handlers/credits.ts index e07fadc1c..f0ab0066c 100644 --- a/source/library/commands/handlers/credits.ts +++ b/source/library/commands/handlers/credits.ts @@ -10,8 +10,8 @@ function getTranslationView(client: Client, interaction: Logos.Interaction): Dis const fields: Discord.CamelizedDiscordEmbedField[] = []; const strings = { - ...constants.contexts.credits({ localise: client.localise.bind(client), locale: interaction.locale }), - ...constants.contexts.language({ localise: client.localise.bind(client), locale: interaction.locale }), + ...constants.contexts.credits({ localise: client.localise, locale: interaction.locale }), + ...constants.contexts.language({ localise: client.localise, locale: interaction.locale }), }; for (const [language, data] of ( Object.entries(constants.contributions.translation) as [LocalisationLanguage, Translation][] diff --git a/source/library/commands/handlers/game.ts b/source/library/commands/handlers/game.ts index 4172befb5..40b7c1ad3 100644 --- a/source/library/commands/handlers/game.ts +++ b/source/library/commands/handlers/game.ts @@ -29,7 +29,7 @@ async function handleStartGame(client: Client, interaction: Logos.Interaction): }); if (sentencePairCount === undefined || sentencePairCount === 0) { const strings = constants.contexts.noSentencesAvailable({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.warning(interaction, { @@ -149,7 +149,7 @@ async function getGameView( const wholeWordPattern = constants.patterns.wholeWord(data.sentenceSelection.correctPick[1]); const mask = constants.special.game.mask.repeat(data.sentenceSelection.correctPick[1].length); - const strings = constants.contexts.game({ localise: client.localise.bind(client), locale: interaction.locale }); + const strings = constants.contexts.game({ localise: client.localise, locale: interaction.locale }); return { embeds: [ { diff --git a/source/library/commands/handlers/information/guild.ts b/source/library/commands/handlers/information/guild.ts index eaf065d34..9695d0ae2 100644 --- a/source/library/commands/handlers/information/guild.ts +++ b/source/library/commands/handlers/information/guild.ts @@ -16,10 +16,7 @@ async function handleDisplayGuildInformation(client: Client, interaction: Logos. return; } - const strings = constants.contexts.guildInformation({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.guildInformation({ localise: client.localise, locale: interaction.locale }); await client.notice(interaction, { author: { @@ -89,18 +86,15 @@ function getChannelInformationSection(client: Client, interaction: Logos.Interac const textChannelsCount = getChannelCountByType(channels, Discord.ChannelTypes.GuildText); const voiceChannelsCount = getChannelCountByType(channels, Discord.ChannelTypes.GuildVoice); - const strings = constants.contexts.channelTypes({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.channelTypes({ localise: client.localise, locale: interaction.locale }); return `${constants.emojis.guild.channels.text} ${strings.text} – ${textChannelsCount}\n${constants.emojis.guild.channels.voice} ${strings.voice} – ${voiceChannelsCount}`; } function getLanguageInformationSection(client: Client, interaction: Logos.Interaction, guildDocument: Guild): string { const strings = { - ...constants.contexts.languageTypes({ localise: client.localise.bind(client), locale: interaction.locale }), - ...constants.contexts.language({ localise: client.localise.bind(client), locale: interaction.locale }), + ...constants.contexts.languageTypes({ localise: client.localise, locale: interaction.locale }), + ...constants.contexts.language({ localise: client.localise, locale: interaction.locale }), }; return `${constants.emojis.guild.languages.localisation} ${strings.home} – ${strings.language( @@ -178,11 +172,7 @@ function formatDistribution( const total = roleFrequencies.map(([_, value]) => value).reduce((a, b) => a + b, withoutRole); - const strings = constants.contexts.withoutProficiency({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); - + const strings = constants.contexts.withoutProficiency({ localise: client.localise, locale: interaction.locale }); const stringParts: string[] = [ formatFrequency(withoutRole, getPercentageComposition(withoutRole, total), strings.withoutProficiency), ]; diff --git a/source/library/commands/handlers/licence/software.ts b/source/library/commands/handlers/licence/software.ts index cc1d2abd3..fc3d43f6f 100644 --- a/source/library/commands/handlers/licence/software.ts +++ b/source/library/commands/handlers/licence/software.ts @@ -26,10 +26,7 @@ async function handleDisplaySoftwareLicence( const packageName = interaction.parameters.package; - const strings = constants.contexts.licence({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.licence({ localise: client.localise, locale: interaction.locale }); const view = new SoftwareLicenceView(client, { interaction, @@ -41,10 +38,7 @@ async function handleDisplaySoftwareLicence( } async function displayError(client: Client, interaction: Logos.Interaction): Promise { - const strings = constants.contexts.invalidLicence({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.invalidLicence({ localise: client.localise, locale: interaction.locale }); await client.error(interaction, { title: strings.title, diff --git a/source/library/commands/handlers/list/warnings.ts b/source/library/commands/handlers/list/warnings.ts index f1b2f22e9..1a95f8466 100644 --- a/source/library/commands/handlers/list/warnings.ts +++ b/source/library/commands/handlers/list/warnings.ts @@ -67,7 +67,7 @@ function getWarningPage( if (warnings.length === 0) { if (isSelf) { const strings = constants.contexts.noWarningsForSelf({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); @@ -78,7 +78,7 @@ function getWarningPage( } const strings = constants.contexts.noWarningsForOther({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); @@ -88,7 +88,7 @@ function getWarningPage( }; } - const strings = constants.contexts.warnings({ localise: client.localise.bind(client), locale: interaction.locale }); + const strings = constants.contexts.warnings({ localise: client.localise, locale: interaction.locale }); return { title: strings.title, diff --git a/source/library/commands/handlers/music/fast-forward.ts b/source/library/commands/handlers/music/fast-forward.ts index 87757dba5..bb7a390fc 100644 --- a/source/library/commands/handlers/music/fast-forward.ts +++ b/source/library/commands/handlers/music/fast-forward.ts @@ -9,7 +9,7 @@ async function handleFastForwardAutocomplete( const timestamp = parseTimeExpression(client, interaction, interaction.parameters.timestamp); if (timestamp === undefined) { const strings = constants.contexts.autocompleteTimestamp({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); @@ -35,7 +35,7 @@ async function handleFastForward( if (!musicService.hasSession) { const strings = constants.contexts.noSongToFastForward({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); @@ -56,7 +56,7 @@ async function handleFastForward( await musicService.session.skipTo({ timestamp: musicService.session.player.position + timestamp }); const strings = constants.contexts.noSongToFastForward({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.guildLocale, }); @@ -72,7 +72,7 @@ async function handleFastForward( async function displayInvalidTimestampError(client: Client, interaction: Logos.Interaction): Promise { const strings = constants.contexts.invalidFastForwardTimestamp({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); diff --git a/source/library/commands/handlers/music/history.ts b/source/library/commands/handlers/music/history.ts index 26935ba3d..74cb06944 100644 --- a/source/library/commands/handlers/music/history.ts +++ b/source/library/commands/handlers/music/history.ts @@ -13,7 +13,7 @@ async function handleDisplayPlaybackHistory(client: Client, interaction: Logos.I if (!musicService.hasSession) { const strings = constants.contexts.notPlayingMusicToCheck({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); @@ -26,7 +26,7 @@ async function handleDisplayPlaybackHistory(client: Client, interaction: Logos.I } const strings = constants.contexts.musicHistory({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.parameters.show ? interaction.guildLocale : interaction.locale, }); diff --git a/source/library/commands/handlers/music/loop.ts b/source/library/commands/handlers/music/loop.ts index ab1bd7514..63de0abfc 100644 --- a/source/library/commands/handlers/music/loop.ts +++ b/source/library/commands/handlers/music/loop.ts @@ -15,10 +15,7 @@ async function handleLoopPlayback( } if (!musicService.hasSession) { - const strings = constants.contexts.noSongToLoop({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.noSongToLoop({ localise: client.localise, locale: interaction.locale }); await client.warning(interaction, { title: strings.title, @@ -31,7 +28,7 @@ async function handleLoopPlayback( if (interaction.parameters.collection) { if (!(musicService.session.queueable instanceof SongCollection)) { const strings = constants.contexts.noSongCollectionToLoop({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); @@ -53,7 +50,7 @@ async function handleLoopPlayback( if (interaction.parameters.collection) { if (!musicService.session.queueable.isLooping) { const strings = constants.contexts.loopDisabledForSongCollection({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.guildLocale, }); @@ -70,7 +67,7 @@ async function handleLoopPlayback( } const strings = constants.contexts.loopEnabledForSongCollection({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.guildLocale, }); await client.success( @@ -87,7 +84,7 @@ async function handleLoopPlayback( if (!musicService.session.playable.isLooping) { const strings = constants.contexts.loopDisabledForSong({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.guildLocale, }); await client.success( @@ -103,7 +100,7 @@ async function handleLoopPlayback( } const strings = constants.contexts.loopEnabledForSong({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.guildLocale, }); await client.success( diff --git a/source/library/commands/handlers/music/now.ts b/source/library/commands/handlers/music/now.ts index 16e1456ee..61ca30961 100644 --- a/source/library/commands/handlers/music/now.ts +++ b/source/library/commands/handlers/music/now.ts @@ -18,7 +18,7 @@ async function handleDisplayCurrentlyPlaying( if (!musicService.hasSession) { const strings = constants.contexts.noSongToShowInformationAbout({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); @@ -33,7 +33,7 @@ async function handleDisplayCurrentlyPlaying( if (interaction.parameters.collection) { if (!(musicService.session.queueable instanceof SongCollection)) { const strings = constants.contexts.noSongCollectionToShowInformationAbout({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); @@ -48,7 +48,7 @@ async function handleDisplayCurrentlyPlaying( const collection = musicService.session.queueable as SongCollection; const strings = constants.contexts.nowPlayingSong({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.parameters.show ? interaction.guildLocale : interaction.locale, }); @@ -64,7 +64,7 @@ async function handleDisplayCurrentlyPlaying( } const strings = constants.contexts.nowPlayingSongCollection({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.parameters.show ? interaction.guildLocale : interaction.locale, }); diff --git a/source/library/commands/handlers/music/pause.ts b/source/library/commands/handlers/music/pause.ts index 881589f32..536f1a353 100644 --- a/source/library/commands/handlers/music/pause.ts +++ b/source/library/commands/handlers/music/pause.ts @@ -13,7 +13,7 @@ async function handlePausePlayback(client: Client, interaction: Logos.Interactio if (!musicService.hasSession) { const strings = constants.contexts.notPlayingMusicToManage({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); @@ -33,7 +33,7 @@ async function handlePausePlayback(client: Client, interaction: Logos.Interactio await musicService.session.setPaused(true); const strings = constants.contexts.musicPaused({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.guildLocale, }); diff --git a/source/library/commands/handlers/music/play.ts b/source/library/commands/handlers/music/play.ts index 89eaf1004..1f896aa0f 100644 --- a/source/library/commands/handlers/music/play.ts +++ b/source/library/commands/handlers/music/play.ts @@ -9,7 +9,7 @@ async function handleRequestStreamPlayback( ): Promise { await client.acknowledge(interaction); - const strings = constants.contexts.stream({ localise: client.localise.bind(client), locale: interaction.locale }); + const strings = constants.contexts.stream({ localise: client.localise, locale: interaction.locale }); const listing: SongListing = new SongListing({ queueable: new AudioStream({ title: strings.stream, url: interaction.parameters.url }), userId: interaction.user.id, @@ -39,7 +39,7 @@ async function handleRequestQueryPlayback( const listing = await resolveToSongListing(client, interaction, { query: interaction.parameters.query }); if (listing === undefined) { const strings = constants.contexts.songNotFound({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); diff --git a/source/library/commands/handlers/music/queue.ts b/source/library/commands/handlers/music/queue.ts index 7bf2118ad..39285b872 100644 --- a/source/library/commands/handlers/music/queue.ts +++ b/source/library/commands/handlers/music/queue.ts @@ -13,7 +13,7 @@ async function handleDisplayPlaybackQueue(client: Client, interaction: Logos.Int if (!musicService.hasSession) { const strings = constants.contexts.notPlayingMusicToCheck({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); @@ -26,7 +26,7 @@ async function handleDisplayPlaybackQueue(client: Client, interaction: Logos.Int } const strings = constants.contexts.queue({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.parameters.show ? interaction.guildLocale : interaction.locale, }); diff --git a/source/library/commands/handlers/music/remove.ts b/source/library/commands/handlers/music/remove.ts index 8df264ca2..4048a3d1a 100644 --- a/source/library/commands/handlers/music/remove.ts +++ b/source/library/commands/handlers/music/remove.ts @@ -14,7 +14,7 @@ async function handleRemoveSongListing(client: Client, interaction: Logos.Intera if (!musicService.hasSession) { const strings = constants.contexts.notPlayingMusicToManage({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); @@ -45,7 +45,7 @@ async function handleRemoveSongListing(client: Client, interaction: Logos.Intera const listing = musicService.session.listings.removeFromQueue({ index }); if (listing === undefined) { const strings = constants.contexts.failedToRemoveSong({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); @@ -58,7 +58,7 @@ async function handleRemoveSongListing(client: Client, interaction: Logos.Intera } const strings = constants.contexts.removedSong({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.guildLocale, }); diff --git a/source/library/commands/handlers/music/replay.ts b/source/library/commands/handlers/music/replay.ts index f48ba8dd9..b1b5e6c1f 100644 --- a/source/library/commands/handlers/music/replay.ts +++ b/source/library/commands/handlers/music/replay.ts @@ -16,7 +16,7 @@ async function handleReplayAction( if (!musicService.hasSession) { const strings = constants.contexts.noSongToReplay({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); @@ -31,7 +31,7 @@ async function handleReplayAction( if (interaction.parameters.collection) { if (!(musicService.session.queueable instanceof SongCollection)) { const strings = constants.contexts.noSongCollectionToReplay({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); @@ -45,7 +45,7 @@ async function handleReplayAction( } const strings = constants.contexts.replaying({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.guildLocale, }); await client.success( diff --git a/source/library/commands/handlers/music/resume.ts b/source/library/commands/handlers/music/resume.ts index 99cebb46f..d4ad4a13e 100644 --- a/source/library/commands/handlers/music/resume.ts +++ b/source/library/commands/handlers/music/resume.ts @@ -12,7 +12,7 @@ async function handleResumePlayback(client: Client, interaction: Logos.Interacti if (!musicService.hasSession) { const strings = constants.contexts.notPlayingMusicToManage({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); @@ -26,7 +26,7 @@ async function handleResumePlayback(client: Client, interaction: Logos.Interacti if (!musicService.session.player.paused) { const strings = constants.contexts.notPaused({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); @@ -40,11 +40,7 @@ async function handleResumePlayback(client: Client, interaction: Logos.Interacti await musicService.session.setPaused(false); - const strings = constants.contexts.resumed({ - localise: client.localise.bind(client), - locale: interaction.guildLocale, - }); - + const strings = constants.contexts.resumed({ localise: client.localise, locale: interaction.guildLocale }); await client.success( interaction, { diff --git a/source/library/commands/handlers/music/rewind.ts b/source/library/commands/handlers/music/rewind.ts index e05a37269..19ce1590f 100644 --- a/source/library/commands/handlers/music/rewind.ts +++ b/source/library/commands/handlers/music/rewind.ts @@ -9,7 +9,7 @@ async function handleRewindAutocomplete( const timestamp = parseTimeExpression(client, interaction, interaction.parameters.timestamp); if (timestamp === undefined) { const strings = constants.contexts.autocompleteTimestamp({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); @@ -32,15 +32,13 @@ async function handleRewind(client: Client, interaction: Logos.Interaction { const strings = constants.contexts.invalidRewindTimestamp({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); - await client.error(interaction, { title: strings.title, description: strings.description, diff --git a/source/library/commands/handlers/music/skip-to.ts b/source/library/commands/handlers/music/skip-to.ts index 259ba9a3f..8d41b52b1 100644 --- a/source/library/commands/handlers/music/skip-to.ts +++ b/source/library/commands/handlers/music/skip-to.ts @@ -9,10 +9,9 @@ async function handleSkipToTimestampAutocomplete( const timestamp = parseTimeExpression(client, interaction, interaction.parameters.timestamp); if (timestamp === undefined) { const strings = constants.contexts.autocompleteTimestamp({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); - await client.respond(interaction, [{ name: trim(strings.autocomplete, 100), value: "" }]); return; } @@ -35,15 +34,13 @@ async function handleSkipToTimestamp( if (!musicService.hasSession) { const strings = constants.contexts.noSongToSkipToTimestampInside({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); - await client.warning(interaction, { title: strings.title, description: strings.description, }); - return; } @@ -56,7 +53,7 @@ async function handleSkipToTimestamp( await musicService.session.skipTo({ timestamp }); const strings = constants.contexts.skippedTo({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.guildLocale, }); @@ -72,7 +69,7 @@ async function handleSkipToTimestamp( async function displayInvalidTimestampError(client: Client, interaction: Logos.Interaction): Promise { const strings = constants.contexts.invalidSkipToTimestamp({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); diff --git a/source/library/commands/handlers/music/skip.ts b/source/library/commands/handlers/music/skip.ts index 8575c5e15..e33733ce4 100644 --- a/source/library/commands/handlers/music/skip.ts +++ b/source/library/commands/handlers/music/skip.ts @@ -19,30 +19,26 @@ async function handleSkipAction( if (!musicService.hasSession) { const strings = constants.contexts.noSongToSkip({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); - await client.warning(interaction, { title: strings.title, description: strings.description, }); - return; } if (interaction.parameters.collection) { if (!(musicService.session.queueable instanceof SongCollection)) { const strings = constants.contexts.noSongCollectionToSkip({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); - await client.warning(interaction, { title: strings.title, description: `${strings.description.noSongCollection}\n\n${strings.description.trySongInstead}`, }); - return; } } @@ -50,15 +46,13 @@ async function handleSkipAction( // If both the 'to' and the 'by' parameter have been supplied. if (interaction.parameters.by !== undefined && interaction.parameters.to !== undefined) { const strings = constants.contexts.tooManySkipArguments({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); - await client.warning(interaction, { title: strings.title, description: strings.description, }); - return; } @@ -68,15 +62,13 @@ async function handleSkipAction( (interaction.parameters.to !== undefined && interaction.parameters.to <= 0) ) { const strings = constants.contexts.invalidSkipArgument({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); - await client.error(interaction, { title: strings.title, description: strings.description, }); - return; } @@ -85,12 +77,12 @@ async function handleSkipAction( let strings: { title: string; description: string }; if (isSkippingCollection) { strings = constants.contexts.skippedSongCollection({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.guildLocale, }); } else { strings = constants.contexts.skippedSong({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.guildLocale, }); } diff --git a/source/library/commands/handlers/music/stop.ts b/source/library/commands/handlers/music/stop.ts index a8f348058..f3f438f78 100644 --- a/source/library/commands/handlers/music/stop.ts +++ b/source/library/commands/handlers/music/stop.ts @@ -12,22 +12,20 @@ async function handleStopPlayback(client: Client, interaction: Logos.Interaction if (!musicService.hasSession) { const strings = constants.contexts.notPlayingMusicToManage({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); - await client.warning(interaction, { title: strings.title, description: strings.description, }); - return; } await musicService.stop(); const strings = constants.contexts.stopped({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.guildLocale, }); await client.success( diff --git a/source/library/commands/handlers/music/unskip.ts b/source/library/commands/handlers/music/unskip.ts index 8469790a6..8b7e15204 100644 --- a/source/library/commands/handlers/music/unskip.ts +++ b/source/library/commands/handlers/music/unskip.ts @@ -27,15 +27,13 @@ async function handleUnskipAction( if (!musicService.hasSession) { const strings = constants.contexts.notPlayingMusicToManage({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); - await client.warning(interaction, { title: strings.title, description: strings.description, }); - return; } @@ -57,29 +55,25 @@ async function handleUnskipAction( if (isUnskippingListing && musicService.session.listings.history.isEmpty) { const strings = constants.contexts.unskipHistoryEmpty({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); - await client.warning(interaction, { title: strings.title, description: strings.description, }); - return; } if (musicService.session.listings.queue.isFull) { const strings = constants.contexts.unskipQueueFull({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); - await client.warning(interaction, { title: strings.title, description: strings.description, }); - return; } @@ -88,30 +82,26 @@ async function handleUnskipAction( !(musicService.session.queueable instanceof SongCollection) ) { const strings = constants.contexts.noSongCollectionToUnskip({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); - await client.warning(interaction, { title: strings.title, description: `${strings.description.noSongCollection}\n\n${strings.description.trySongInstead}`, }); - return; } // If both the 'to' and the 'by' parameter have been supplied. if (interaction.parameters.by !== undefined && interaction.parameters.to !== undefined) { const strings = constants.contexts.tooManyUnskipArguments({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); - await client.warning(interaction, { title: strings.title, description: strings.description, }); - return; } @@ -121,23 +111,20 @@ async function handleUnskipAction( (interaction.parameters.to !== undefined && interaction.parameters.to <= 0) ) { const strings = constants.contexts.invalidSkipArgument({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); - await client.error(interaction, { title: strings.title, description: strings.description, }); - return; } const strings = constants.contexts.invalidSkipArgument({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.guildLocale, }); - await client.success( interaction, { diff --git a/source/library/commands/handlers/music/volume/display.ts b/source/library/commands/handlers/music/volume/display.ts index 9f75b5d87..36c24b984 100644 --- a/source/library/commands/handlers/music/volume/display.ts +++ b/source/library/commands/handlers/music/volume/display.ts @@ -12,7 +12,7 @@ async function handleDisplayVolume(client: Client, interaction: Logos.Interactio if (!musicService.hasSession) { const strings = constants.contexts.notPlayingMusicToCheck({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); @@ -25,7 +25,7 @@ async function handleDisplayVolume(client: Client, interaction: Logos.Interactio } const strings = constants.contexts.volume({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.parameters.show ? interaction.guildLocale : interaction.locale, }); diff --git a/source/library/commands/handlers/music/volume/set.ts b/source/library/commands/handlers/music/volume/set.ts index 1c946eee3..44b5aab35 100644 --- a/source/library/commands/handlers/music/volume/set.ts +++ b/source/library/commands/handlers/music/volume/set.ts @@ -12,7 +12,7 @@ async function handleSetVolume(client: Client, interaction: Logos.Interaction constants.MAXIMUM_VOLUME) { const strings = constants.contexts.volumeInvalid({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); @@ -45,7 +45,7 @@ async function handleSetVolume(client: Client, interaction: Logos.Interaction { - const strings = constants.contexts.invalidWarning({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.invalidWarning({ localise: client.localise, locale: interaction.locale }); await client.error(interaction, { title: strings.title, description: strings.description, diff --git a/source/library/commands/handlers/policy.ts b/source/library/commands/handlers/policy.ts index 1540915b0..8d7786012 100644 --- a/source/library/commands/handlers/policy.ts +++ b/source/library/commands/handlers/policy.ts @@ -23,10 +23,7 @@ async function handleDisplayModerationPolicy(client: Client, interaction: Logos. }, ]; - const strings = constants.contexts.moderationPolicy({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.moderationPolicy({ localise: client.localise, locale: interaction.locale }); await client.notice( interaction, { diff --git a/source/library/commands/handlers/praise.ts b/source/library/commands/handlers/praise.ts index 61334562b..b61dfd56f 100644 --- a/source/library/commands/handlers/praise.ts +++ b/source/library/commands/handlers/praise.ts @@ -27,15 +27,11 @@ async function handlePraiseUser( } if (member.id === interaction.member?.id) { - const strings = constants.contexts.cannotPraiseSelf({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.cannotPraiseSelf({ localise: client.localise, locale: interaction.locale }); await client.warning(interaction, { title: strings.title, description: strings.description, }); - return; } @@ -48,15 +44,11 @@ async function handlePraiseUser( configuration.rateLimit ?? constants.defaults.PRAISE_RATE_LIMIT, ); if (crossesRateLimit) { - const strings = constants.contexts.tooManyPraises({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.tooManyPraises({ localise: client.localise, locale: interaction.locale }); await client.pushedBack(interaction, { title: strings.title, description: strings.description, }); - return; } @@ -78,7 +70,7 @@ async function handlePraiseUser( args: [member, praiseDocument, interaction.user], }); - const strings = constants.contexts.praised({ localise: client.localise.bind(client), locale: interaction.locale }); + const strings = constants.contexts.praised({ localise: client.localise, locale: interaction.locale }); await client.succeeded(interaction, { title: strings.title, description: strings.description({ user_mention: mention(member.id, { type: "user" }) }), diff --git a/source/library/commands/handlers/profile/view.ts b/source/library/commands/handlers/profile/view.ts index 1055ff058..a3a98e946 100644 --- a/source/library/commands/handlers/profile/view.ts +++ b/source/library/commands/handlers/profile/view.ts @@ -32,7 +32,7 @@ async function handleDisplayProfile( Warning.getAll(client, { where: { guildId: interaction.guildId.toString(), targetId: member.id.toString() } }), ]); - const strings = constants.contexts.profile({ localise: client.localise.bind(client), locale: interaction.locale }); + const strings = constants.contexts.profile({ localise: client.localise, locale: interaction.locale }); const components: Discord.ActionRow[] | undefined = interaction.parameters.show ? undefined : [ diff --git a/source/library/commands/handlers/purge.ts b/source/library/commands/handlers/purge.ts index 58f69e0ae..6e2e63242 100644 --- a/source/library/commands/handlers/purge.ts +++ b/source/library/commands/handlers/purge.ts @@ -123,10 +123,7 @@ async function handlePurgeMessages( let messages: Discord.Message[] = []; const getMessageFields = (): Discord.CamelizedDiscordEmbedField[] => { - const strings = constants.contexts.purge({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.purge({ localise: client.localise, locale: interaction.locale }); return [ { name: strings.start, @@ -166,10 +163,7 @@ async function handlePurgeMessages( }; const getIndexingProgressResponse = (): Discord.InteractionCallbackData => { - const strings = constants.contexts.indexing({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.indexing({ localise: client.localise, locale: interaction.locale }); return { embeds: [ { @@ -194,10 +188,7 @@ async function handlePurgeMessages( if (messages.length >= constants.MAXIMUM_INDEXABLE_MESSAGES) { clearInterval(indexProgressIntervalId); - const strings = constants.contexts.rangeTooBig({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.rangeTooBig({ localise: client.localise, locale: interaction.locale }); await client.warned(interaction, { title: strings.title, description: `${strings.description.rangeTooBig({ @@ -265,10 +256,7 @@ async function handlePurgeMessages( clearInterval(indexProgressIntervalId); if (messages.length === 0) { - const strings = constants.contexts.indexedNoResults({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.indexedNoResults({ localise: client.localise, locale: interaction.locale }); await client.warned(interaction, { title: strings.title, description: `${strings.description.none}\n\n${strings.description.tryDifferentQuery}`, @@ -303,7 +291,7 @@ async function handlePurgeMessages( await client.registerInteractionCollector(cancelButton); const strings = constants.contexts.tooManyMessagesToDelete({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.editReply(interaction, { @@ -398,7 +386,7 @@ async function handlePurgeMessages( await client.registerInteractionCollector(cancelButton); const strings = constants.contexts.indexedFoundMessagesToDelete({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.editReply(interaction, { @@ -462,7 +450,7 @@ async function handlePurgeMessages( { const strings = constants.contexts.purging({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.noticed(interaction, { @@ -578,7 +566,7 @@ async function handlePurgeMessages( { const strings = constants.contexts.purged({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.succeeded(interaction, { @@ -602,7 +590,7 @@ async function displaySnowflakesInvalidError( const areBothInvalid = isStartInvalid && isEndInvalid; const strings = constants.contexts.invalidPurgeParameters({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.warned( @@ -625,10 +613,7 @@ async function displaySnowflakesInvalidError( } async function displayIdsNotDifferentError(client: Client, interaction: Logos.Interaction): Promise { - const strings = constants.contexts.idsNotDifferent({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.idsNotDifferent({ localise: client.localise, locale: interaction.locale }); await client.warned(interaction, { title: strings.title, description: strings.description, @@ -636,10 +621,7 @@ async function displayIdsNotDifferentError(client: Client, interaction: Logos.In } async function displayFailedError(client: Client, interaction: Logos.Interaction): Promise { - const strings = constants.contexts.purgeFailed({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.purgeFailed({ localise: client.localise, locale: interaction.locale }); await client.failed(interaction, { title: strings.title, description: strings.description, @@ -657,11 +639,7 @@ function getMessageContent( const content = trim(message.content ?? "", 500).trim(); if (content.length === 0) { - const strings = constants.contexts.purgeNoContent({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); - + const strings = constants.contexts.purgeNoContent({ localise: client.localise, locale: interaction.locale }); return `> *${strings.noContent}*`; } diff --git a/source/library/commands/handlers/recognise.ts b/source/library/commands/handlers/recognise.ts index 916597edb..42d09d8e3 100644 --- a/source/library/commands/handlers/recognise.ts +++ b/source/library/commands/handlers/recognise.ts @@ -19,20 +19,17 @@ async function handleRecogniseLanguageMessage(client: Client, interaction: Logos const hasEmbeds = message.embeds !== undefined && message.embeds.length > 0; if (hasEmbeds) { const strings = constants.contexts.cannotUseForRecognition({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.warning(interaction, { title: strings.title, description: strings.description, }); - return; } - const text = message.content; - - await handleRecogniseLanguage(client, interaction, { text, isMessage: true }); + await handleRecogniseLanguage(client, interaction, { text: message.content, isMessage: true }); } async function handleRecogniseLanguage( @@ -42,10 +39,7 @@ async function handleRecogniseLanguage( ): Promise { const isTextEmpty = text.trim().length === 0; if (isTextEmpty) { - const strings = constants.contexts.textEmpty({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.textEmpty({ localise: client.localise, locale: interaction.locale }); await client.warning(interaction, { title: strings.title, description: strings.description, @@ -58,10 +52,7 @@ async function handleRecogniseLanguage( const detectedLanguages = await client.adapters.detectors.detectLanguages({ text }); if (detectedLanguages.likely.length === 0 && detectedLanguages.possible.length === 0) { - const strings = constants.contexts.unknownLanguage({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.unknownLanguage({ localise: client.localise, locale: interaction.locale }); await client.unsupported(interaction, { title: strings.title, description: isMessage ? strings.description.message : strings.description.text, @@ -81,8 +72,8 @@ async function handleRecogniseLanguage( } const strings = { - ...constants.contexts.likelyMatch({ localise: client.localise.bind(client), locale: interaction.locale }), - ...constants.contexts.language({ localise: client.localise.bind(client), locale: interaction.locale }), + ...constants.contexts.likelyMatch({ localise: client.localise, locale: interaction.locale }), + ...constants.contexts.language({ localise: client.localise, locale: interaction.locale }), }; await client.noticed(interaction, { @@ -111,11 +102,8 @@ async function handleRecogniseLanguage( } const strings = { - ...constants.contexts.likelyMatch({ - localise: client.localise.bind(client), - locale: interaction.locale, - }), - ...constants.contexts.language({ localise: client.localise.bind(client), locale: interaction.locale }), + ...constants.contexts.likelyMatch({ localise: client.localise, locale: interaction.locale }), + ...constants.contexts.language({ localise: client.localise, locale: interaction.locale }), }; fields.push({ name: `${constants.emojis.detect.likely} ${strings.title}`, @@ -124,11 +112,8 @@ async function handleRecogniseLanguage( }); } else if (detectedLanguages.likely.length > 0) { const strings = { - ...constants.contexts.likelyMatches({ - localise: client.localise.bind(client), - locale: interaction.locale, - }), - ...constants.contexts.language({ localise: client.localise.bind(client), locale: interaction.locale }), + ...constants.contexts.likelyMatches({ localise: client.localise, locale: interaction.locale }), + ...constants.contexts.language({ localise: client.localise, locale: interaction.locale }), }; const languageNamesLocalised = detectedLanguages.likely.map((language) => strings.language(language)); const languageNamesFormatted = list(languageNamesLocalised.map((languageName) => `***${languageName}***`)); @@ -147,11 +132,8 @@ async function handleRecogniseLanguage( } const strings = { - ...constants.contexts.possibleMatch({ - localise: client.localise.bind(client), - locale: interaction.locale, - }), - ...constants.contexts.language({ localise: client.localise.bind(client), locale: interaction.locale }), + ...constants.contexts.possibleMatch({ localise: client.localise, locale: interaction.locale }), + ...constants.contexts.language({ localise: client.localise, locale: interaction.locale }), }; fields.push({ name: `${constants.emojis.detect.possible} ${strings.title}`, @@ -160,11 +142,8 @@ async function handleRecogniseLanguage( }); } else if (detectedLanguages.possible.length > 0) { const strings = { - ...constants.contexts.possibleMatches({ - localise: client.localise.bind(client), - locale: interaction.locale, - }), - ...constants.contexts.language({ localise: client.localise.bind(client), locale: interaction.locale }), + ...constants.contexts.possibleMatches({ localise: client.localise, locale: interaction.locale }), + ...constants.contexts.language({ localise: client.localise, locale: interaction.locale }), }; const languageNamesLocalised = detectedLanguages.possible.map((language) => strings.language(language)); const languageNamesFormatted = list(languageNamesLocalised.map((languageName) => `***${languageName}***`)); diff --git a/source/library/commands/handlers/report.ts b/source/library/commands/handlers/report.ts index b1666e2e2..b058b0503 100644 --- a/source/library/commands/handlers/report.ts +++ b/source/library/commands/handlers/report.ts @@ -28,16 +28,11 @@ async function handleMakeReport(client: Client, interaction: Logos.Interaction): configuration.rateLimit ?? constants.defaults.REPORT_RATE_LIMIT, ); if (crossesRateLimit) { - const strings = constants.contexts.tooManyReports({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); - + const strings = constants.contexts.tooManyReports({ localise: client.localise, locale: interaction.locale }); await client.warning(interaction, { title: strings.title, description: strings.description, }); - return; } @@ -77,11 +72,7 @@ async function handleMakeReport(client: Client, interaction: Logos.Interaction): reportService.registerPrompt(prompt, user.id, reportDocument); reportService.registerHandler(reportDocument); - const strings = constants.contexts.reportSubmitted({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); - + const strings = constants.contexts.reportSubmitted({ localise: client.localise, locale: interaction.locale }); await client.succeeded(submission, { title: strings.title, description: strings.description, diff --git a/source/library/commands/handlers/resource.ts b/source/library/commands/handlers/resource.ts index 7bcff93d1..050eb6e1c 100644 --- a/source/library/commands/handlers/resource.ts +++ b/source/library/commands/handlers/resource.ts @@ -28,16 +28,11 @@ async function handleSubmitResource(client: Client, interaction: Logos.Interacti configuration.rateLimit ?? constants.defaults.RESOURCE_RATE_LIMIT, ); if (crossesRateLimit) { - const strings = constants.contexts.tooManyResources({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); - + const strings = constants.contexts.tooManyResources({ localise: client.localise, locale: interaction.locale }); await client.warning(interaction, { title: strings.title, description: strings.description, }); - return; } @@ -77,11 +72,7 @@ async function handleSubmitResource(client: Client, interaction: Logos.Interacti resourceService.registerPrompt(prompt, interaction.user.id, resourceDocument); resourceService.registerHandler(resourceDocument); - const strings = constants.contexts.resourceSent({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); - + const strings = constants.contexts.resourceSent({ localise: client.localise, locale: interaction.locale }); await client.succeeded(submission, { title: strings.title, description: strings.description, diff --git a/source/library/commands/handlers/resources.ts b/source/library/commands/handlers/resources.ts index 20868f034..cfad555ef 100644 --- a/source/library/commands/handlers/resources.ts +++ b/source/library/commands/handlers/resources.ts @@ -12,11 +12,11 @@ async function handleDisplayResources(client: Client, interaction: Logos.Interac const strings = { ...constants.contexts.redirect({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.parameters.show ? interaction.guildLocale : interaction.locale, }), ...constants.contexts.language({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.parameters.show ? interaction.guildLocale : interaction.locale, }), }; diff --git a/source/library/commands/handlers/rule.ts b/source/library/commands/handlers/rule.ts index cf9055333..4750a35ea 100644 --- a/source/library/commands/handlers/rule.ts +++ b/source/library/commands/handlers/rule.ts @@ -49,11 +49,11 @@ async function handleCiteRule(client: Client, interaction: Logos.Interaction { - const strings = constants.contexts.ruleInvalid({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.ruleInvalid({ localise: client.localise, locale: interaction.locale }); await client.error(interaction, { title: strings.title, description: strings.description, diff --git a/source/library/commands/handlers/settings/language/clear.ts b/source/library/commands/handlers/settings/language/clear.ts index 5b8e68adf..63661a95e 100644 --- a/source/library/commands/handlers/settings/language/clear.ts +++ b/source/library/commands/handlers/settings/language/clear.ts @@ -7,14 +7,13 @@ async function handleClearLanguage(client: Client, interaction: Logos.Interactio const userDocument = await User.getOrCreate(client, { userId: interaction.user.id.toString() }); if (userDocument.preferredLanguage === undefined) { const strings = constants.contexts.cannotClearSettings({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.warned(interaction, { title: strings.title, description: strings.description, }); - return; } @@ -24,7 +23,7 @@ async function handleClearLanguage(client: Client, interaction: Logos.Interactio { const strings = constants.contexts.settingsCleared({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.succeeded(interaction, { diff --git a/source/library/commands/handlers/settings/language/set.ts b/source/library/commands/handlers/settings/language/set.ts index 8a8a43ebe..96078cd23 100644 --- a/source/library/commands/handlers/settings/language/set.ts +++ b/source/library/commands/handlers/settings/language/set.ts @@ -10,14 +10,14 @@ async function handleSetLanguageAutocomplete( const languageLowercase = interaction.parameters.language.trim().toLowerCase(); if (languageLowercase.length === 0) { const strings = constants.contexts.autocompleteLanguage({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.respond(interaction, [{ name: trim(strings.autocomplete, 100), value: "" }]); return; } - const strings = constants.contexts.language({ localise: client.localise.bind(client), locale: interaction.locale }); + const strings = constants.contexts.language({ localise: client.localise, locale: interaction.locale }); const choices = languages.languages.localisation .map((language) => ({ name: strings.language(language), value: language })) .filter((choice) => choice.name.toLowerCase().includes(languageLowercase)); @@ -42,10 +42,10 @@ async function handleSetLanguage( if (userDocument.preferredLanguage === language) { const strings = { ...constants.contexts.languageAlreadySet({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }), - ...constants.contexts.language({ localise: client.localise.bind(client), locale: interaction.locale }), + ...constants.contexts.language({ localise: client.localise, locale: interaction.locale }), }; await client.warned(interaction, { title: strings.title, @@ -61,8 +61,8 @@ async function handleSetLanguage( const newLocale = getLocaleByLocalisationLanguage(language); const strings = { - ...constants.contexts.languageUpdated({ localise: client.localise.bind(client), locale: newLocale }), - ...constants.contexts.language({ localise: client.localise.bind(client), locale: newLocale }), + ...constants.contexts.languageUpdated({ localise: client.localise, locale: newLocale }), + ...constants.contexts.language({ localise: client.localise, locale: newLocale }), }; await client.succeeded(interaction, { title: strings.title, @@ -72,7 +72,7 @@ async function handleSetLanguage( async function displayError(client: Client, interaction: Logos.Interaction): Promise { const strings = constants.contexts.languageInvalid({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.error(interaction, { diff --git a/source/library/commands/handlers/settings/view.ts b/source/library/commands/handlers/settings/view.ts index 4e5740c08..ee1b6d8d2 100644 --- a/source/library/commands/handlers/settings/view.ts +++ b/source/library/commands/handlers/settings/view.ts @@ -5,8 +5,8 @@ async function handleDisplaySettings(client: Client, interaction: Logos.Interact const userDocument = await User.getOrCreate(client, { userId: interaction.user.id.toString() }); const strings = { - ...constants.contexts.settings({ localise: client.localise.bind(client), locale: interaction.locale }), - ...constants.contexts.language({ localise: client.localise.bind(client), locale: interaction.locale }), + ...constants.contexts.settings({ localise: client.localise, locale: interaction.locale }), + ...constants.contexts.language({ localise: client.localise, locale: interaction.locale }), }; await client.notice(interaction, { title: strings.title, diff --git a/source/library/commands/handlers/slowmode.ts b/source/library/commands/handlers/slowmode.ts index 7ecf54203..c90a83f34 100644 --- a/source/library/commands/handlers/slowmode.ts +++ b/source/library/commands/handlers/slowmode.ts @@ -9,10 +9,7 @@ async function handleToggleSlowmodeAutocomplete( client: Client, interaction: Logos.Interaction, ): Promise { - const strings = constants.contexts.slowmodeLevel({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.slowmodeLevel({ localise: client.localise, locale: interaction.locale }); const levelLowercase = interaction.parameters.level.trim().toLowerCase(); const choices = constants.slowmode.levels .map((level) => ({ name: strings.level(level), value: level })) @@ -27,7 +24,7 @@ async function handleToggleSlowmode( ): Promise { if (interaction.parameters.level !== undefined && !isValidSlowmodeLevel(interaction.parameters.level)) { const strings = constants.contexts.invalidSlowmodeLevel({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.error(interaction, { @@ -77,7 +74,7 @@ async function handleToggleSlowmode( }); const strings = constants.contexts.slowmodeDowngraded({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.guildLocale, }); await client.success( @@ -106,7 +103,7 @@ async function handleToggleSlowmode( }); const strings = constants.contexts.slowmodeUpgraded({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.guildLocale, }); await client.success( @@ -123,7 +120,7 @@ async function handleToggleSlowmode( { const strings = constants.contexts.theSameSlowmodeLevel({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.warning(interaction, { @@ -143,7 +140,7 @@ async function handleToggleSlowmode( const canDisableIn = now + (constants.SLOWMODE_COLLISION_TIMEOUT - timeElapsedSinceUse); const strings = constants.contexts.slowmodeTooSoon({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.pushback(interaction, { @@ -168,7 +165,7 @@ async function handleToggleSlowmode( }); const strings = constants.contexts.slowmodeDisabled({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.guildLocale, }); await client.notice( @@ -179,7 +176,6 @@ async function handleToggleSlowmode( }, { visible: true }, ); - return; } @@ -199,10 +195,7 @@ async function handleToggleSlowmode( args: [interaction.user, channel, interaction.parameters.level ?? "lowest"], }); - const strings = constants.contexts.slowmodeEnabled({ - localise: client.localise.bind(client), - locale: interaction.guildLocale, - }); + const strings = constants.contexts.slowmodeEnabled({ localise: client.localise, locale: interaction.guildLocale }); await client.notice( interaction, { diff --git a/source/library/commands/handlers/suggestion.ts b/source/library/commands/handlers/suggestion.ts index 90ebcc18c..c80b3c857 100644 --- a/source/library/commands/handlers/suggestion.ts +++ b/source/library/commands/handlers/suggestion.ts @@ -29,15 +29,13 @@ async function handleMakeSuggestion(client: Client, interaction: Logos.Interacti ); if (crossesRateLimit) { const strings = constants.contexts.tooManySuggestions({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); - await client.pushback(interaction, { title: strings.title, description: strings.description, }); - return; } @@ -77,11 +75,7 @@ async function handleMakeSuggestion(client: Client, interaction: Logos.Interacti suggestionService.registerPrompt(prompt, interaction.user.id, suggestionDocument); suggestionService.registerHandler(suggestionDocument); - const strings = constants.contexts.suggestionSent({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); - + const strings = constants.contexts.suggestionSent({ localise: client.localise, locale: interaction.locale }); await client.succeeded(submission, { title: strings.title, description: strings.description, diff --git a/source/library/commands/handlers/ticket/open.ts b/source/library/commands/handlers/ticket/open.ts index ef5a17e88..5abb111aa 100644 --- a/source/library/commands/handlers/ticket/open.ts +++ b/source/library/commands/handlers/ticket/open.ts @@ -29,7 +29,7 @@ async function handleOpenTicket(client: Client, interaction: Logos.Interaction): ); if (crossesRateLimit) { const strings = constants.contexts.tooManyTickets({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.pushback(interaction, { @@ -59,10 +59,7 @@ async function handleOpenTicket(client: Client, interaction: Logos.Interaction): return; } - const strings = constants.contexts.ticketSent({ - localise: client.localise.bind(client), - locale: submission.locale, - }); + const strings = constants.contexts.ticketSent({ localise: client.localise, locale: submission.locale }); await client.succeeded(submission, { title: strings.title, description: strings.description, diff --git a/source/library/commands/handlers/timeout/clear.ts b/source/library/commands/handlers/timeout/clear.ts index 43a8a494b..fec67f645 100644 --- a/source/library/commands/handlers/timeout/clear.ts +++ b/source/library/commands/handlers/timeout/clear.ts @@ -40,15 +40,11 @@ async function handleClearTimeout( const notTimedOut = timedOutUntil === undefined || timedOutUntil < Date.now(); if (notTimedOut) { - const strings = constants.contexts.notTimedOut({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.notTimedOut({ localise: client.localise, locale: interaction.locale }); await client.warning(interaction, { title: strings.title, description: strings.description({ user_mention: mention(user.id, { type: "user" }) }), }); - return; } @@ -68,7 +64,7 @@ async function handleClearTimeout( }); const strings = constants.contexts.timeoutCleared({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.success(interaction, { diff --git a/source/library/commands/handlers/timeout/set.ts b/source/library/commands/handlers/timeout/set.ts index ac1965d24..be607dfd2 100644 --- a/source/library/commands/handlers/timeout/set.ts +++ b/source/library/commands/handlers/timeout/set.ts @@ -23,10 +23,9 @@ async function handleSetTimeoutAutocomplete( const timestamp = parseTimeExpression(client, interaction, interaction.parameters.duration); if (timestamp === undefined) { const strings = constants.contexts.autocompleteTimestamp({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); - await client.respond(interaction, [{ name: trim(strings.autocomplete, 100), value: "" }]); return; } @@ -96,7 +95,7 @@ async function handleSetTimeout( args: [member, until, interaction.parameters.reason, interaction.user], }); - const strings = constants.contexts.timedOut({ localise: client.localise.bind(client), locale: interaction.locale }); + const strings = constants.contexts.timedOut({ localise: client.localise, locale: interaction.locale }); await client.notice(interaction, { title: strings.title, description: strings.description({ @@ -108,7 +107,7 @@ async function handleSetTimeout( async function displayDurationInvalidError(client: Client, interaction: Logos.Interaction): Promise { const strings = constants.contexts.timeoutDurationInvalid({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.error(interaction, { @@ -119,7 +118,7 @@ async function displayDurationInvalidError(client: Client, interaction: Logos.In async function displayTooShortWarning(client: Client, interaction: Logos.Interaction): Promise { const strings = constants.contexts.timeoutDurationTooShort({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.warning(interaction, { @@ -130,7 +129,7 @@ async function displayTooShortWarning(client: Client, interaction: Logos.Interac async function displayTooLongWarning(client: Client, interaction: Logos.Interaction): Promise { const strings = constants.contexts.timeoutDurationTooLong({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.warning(interaction, { diff --git a/source/library/commands/handlers/translate.ts b/source/library/commands/handlers/translate.ts index 5116f9f0b..a96a35506 100644 --- a/source/library/commands/handlers/translate.ts +++ b/source/library/commands/handlers/translate.ts @@ -28,7 +28,7 @@ async function handleTranslateChatInputAutocomplete( const languageQueryTrimmed = interaction.parameters[interaction.parameters.focused].trim(); if (languageQueryTrimmed.length === 0) { const strings = constants.contexts.autocompleteLanguage({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.respond(interaction, [{ name: trim(strings.autocomplete, 100), value: "" }]); @@ -38,10 +38,7 @@ async function handleTranslateChatInputAutocomplete( const languageQueryLowercase = languageQueryTrimmed.toLowerCase(); const choices = languages.languages.translation .map((language) => { - const strings = constants.contexts.language({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.language({ localise: client.localise, locale: interaction.locale }); return { name: strings.language(language), value: language, @@ -70,7 +67,7 @@ async function handleTranslateMessage(client: Client, interaction: Logos.Interac const hasEmbeds = message.embeds !== undefined && message.embeds.length > 0; if (hasEmbeds) { const strings = constants.contexts.cannotUseMessageForTranslation({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.warning(interaction, { @@ -93,14 +90,13 @@ async function handleTranslate( const isTextEmpty = text.trim().length === 0; if (isTextEmpty) { const strings = constants.contexts.textEmpty({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.error(interaction, { title: strings.title, description: strings.description, }); - return; } @@ -112,7 +108,7 @@ async function handleTranslate( if (isSourceInvalid && isTargetInvalid) { const strings = constants.contexts.bothLanguagesInvalid({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.error(interaction, { @@ -124,7 +120,7 @@ async function handleTranslate( if (isSourceInvalid) { const strings = constants.contexts.sourceLanguageInvalid({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); @@ -138,30 +134,26 @@ async function handleTranslate( if (isTargetInvalid) { const strings = constants.contexts.targetLanguageInvalid({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); - await client.error(interaction, { title: strings.title, description: strings.description, }); - return; } if (from !== undefined && to !== undefined) { if (from === to) { const strings = constants.contexts.languagesNotDifferent({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); - await client.pushback(interaction, { title: strings.title, description: strings.description, }); - return; } @@ -210,29 +202,25 @@ async function handleTranslate( const translationLanguage = getTranslationLanguage(language); if (translationLanguage === undefined) { const strings = constants.contexts.cannotDetermineTargetLanguage({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); - await client.warning(interaction, { title: strings.title, description: `${strings.description.cannotDetermine}\n\n${strings.description.tryAgain}`, }); - return; } if (translationLanguage === sourceLanguage) { const strings = constants.contexts.cannotDetermineSourceLanguage({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); - await client.warning(interaction, { title: strings.title, description: `${strings.description.cannotDetermine}\n\n${strings.description.tryAgain}`, }); - return; } @@ -250,14 +238,13 @@ async function translateText( const adapters = client.adapters.translators.getTranslators({ languages }); if (adapters === undefined || adapters.length === 0) { const strings = constants.contexts.noTranslationAdapters({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.unsupported(interaction, { title: strings.title, description: strings.description, }); - return; } @@ -276,7 +263,7 @@ async function translateText( if (translation === undefined) { const strings = constants.contexts.failedToTranslate({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.failed(interaction, { @@ -293,8 +280,8 @@ async function translateText( const isLong = text.length > 896; // 7/8 of 1024. Leaves room for text overhead. const strings = { - ...constants.contexts.translation({ localise: client.localise.bind(client), locale: interaction.locale }), - ...constants.contexts.language({ localise: client.localise.bind(client), locale: interaction.locale }), + ...constants.contexts.translation({ localise: client.localise, locale: interaction.locale }), + ...constants.contexts.language({ localise: client.localise, locale: interaction.locale }), }; let embeds: Discord.CamelizedDiscordEmbed[]; if (isLong) { @@ -365,7 +352,7 @@ async function detectLanguage( const detectedLanguage = detectedLanguages.likely.at(0); if (detectedLanguage === undefined) { const strings = constants.contexts.cannotDetermineTargetLanguage({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.warning(interaction, { @@ -379,11 +366,8 @@ async function detectLanguage( const translationLanguage = getTranslationLanguage(detectedLanguage); if (translationLanguage === undefined) { const strings = { - ...constants.contexts.languageNotSupported({ - localise: client.localise.bind(client), - locale: interaction.locale, - }), - ...constants.contexts.language({ localise: client.localise.bind(client), locale: interaction.locale }), + ...constants.contexts.languageNotSupported({ localise: client.localise, locale: interaction.locale }), + ...constants.contexts.language({ localise: client.localise, locale: interaction.locale }), }; await client.unsupported(interaction, { title: strings.title, diff --git a/source/library/commands/handlers/warn.ts b/source/library/commands/handlers/warn.ts index a6d163012..7ae5270ed 100644 --- a/source/library/commands/handlers/warn.ts +++ b/source/library/commands/handlers/warn.ts @@ -34,7 +34,7 @@ async function handleWarnUserAutocomplete( } case "rule": { const strings = constants.contexts.otherRuleOption({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); const ruleLowercase = interaction.parameters.rule.trim().toLowerCase(); @@ -68,10 +68,7 @@ async function handleWarnUser( } if (interaction.parameters.rule !== constants.components.none && !isValidRule(interaction.parameters.rule)) { - const strings = constants.contexts.invalidRule({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.invalidRule({ localise: client.localise, locale: interaction.locale }); await client.error(interaction, { title: strings.title, description: strings.description, @@ -128,11 +125,7 @@ async function handleWarnUser( timeRangeMilliseconds: timeStructToMilliseconds(configuration.expiration ?? constants.defaults.WARN_EXPIRY), }); - const strings = constants.contexts.userWarned({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); - + const strings = constants.contexts.userWarned({ localise: client.localise, locale: interaction.locale }); await client.success(interaction, { title: strings.title, description: strings.description({ @@ -160,7 +153,7 @@ async function handleWarnUser( ); const strings = constants.contexts.warningLimitSurpassedAndTimedOut({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.guildLocale, }); alertService?.alert({ @@ -181,7 +174,7 @@ async function handleWarnUser( }); } else { const strings = constants.contexts.warningLimitSurpassed({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.guildLocale, }); alertService?.alert({ @@ -205,10 +198,7 @@ async function handleWarnUser( const reachedLimit = warningDocumentsActive.length === constants.defaults.WARN_LIMIT; if (reachedLimit) { - const strings = constants.contexts.limitReached({ - localise: client.localise.bind(client), - locale: interaction.guildLocale, - }); + const strings = constants.contexts.limitReached({ localise: client.localise, locale: interaction.guildLocale }); if (guildDocument.hasEnabled("alerts")) { const alertService = client.getAlertService(guild.id); alertService?.alert({ diff --git a/source/library/commands/handlers/word.ts b/source/library/commands/handlers/word.ts index 4023166b4..a097c4c6c 100644 --- a/source/library/commands/handlers/word.ts +++ b/source/library/commands/handlers/word.ts @@ -19,7 +19,7 @@ async function handleFindWordAutocomplete( const languageQueryTrimmed = interaction.parameters.language?.trim(); if (languageQueryTrimmed === undefined || languageQueryTrimmed.length === 0) { const strings = constants.contexts.autocompleteLanguage({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.respond(interaction, [{ name: trim(strings.autocomplete, 100), value: "" }]); @@ -72,7 +72,7 @@ async function handleFindWord( const dictionaries = client.adapters.dictionaries.getAdapters({ learningLanguage }); if (dictionaries === undefined) { const strings = constants.contexts.noDictionaryAdapters({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); await client.reply(interaction, { @@ -158,10 +158,7 @@ async function handleFindWord( } if (entriesByPartOfSpeech.size === 0) { - const strings = constants.contexts.noResults({ - localise: client.localise.bind(client), - locale: interaction.displayLocale, - }); + const strings = constants.contexts.noResults({ localise: client.localise, locale: interaction.displayLocale }); await client.editReply(interaction, { embeds: [ { @@ -306,7 +303,7 @@ async function generateButtons( await client.registerInteractionCollector(nextPageButton); const strings = constants.contexts.wordPage({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.displayLocale, }); paginationControls.push([ @@ -422,7 +419,7 @@ async function generateButtons( if (entry.definitions !== undefined) { const strings = constants.contexts.definitionsView({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.displayLocale, }); row.push({ @@ -436,7 +433,7 @@ async function generateButtons( if (entry.inflectionTable !== undefined) { const strings = constants.contexts.inflectionView({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.displayLocale, }); row.push({ @@ -480,7 +477,7 @@ function entryToEmbeds( let partOfSpeechDisplayed: string; if (entry.partOfSpeech === undefined) { const strings = constants.contexts.partOfSpeechUnknown({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.displayLocale, }); partOfSpeechDisplayed = strings.unknown; @@ -491,7 +488,7 @@ function entryToEmbeds( partOfSpeechDisplayed = original; } else { const strings = constants.contexts.partOfSpeech({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.displayLocale, }); partOfSpeechDisplayed = strings.partOfSpeech(detected); @@ -513,7 +510,7 @@ function entryToEmbeds( if (verbose) { const strings = constants.contexts.nativeDefinitionsForWord({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.displayLocale, }); embeds.push({ @@ -523,7 +520,7 @@ function entryToEmbeds( }); } else { const strings = constants.contexts.nativeDefinitions({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.displayLocale, }); fields.push({ @@ -539,7 +536,7 @@ function entryToEmbeds( if (verbose) { const strings = constants.contexts.definitionsForWord({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.displayLocale, }); embeds.push({ @@ -549,7 +546,7 @@ function entryToEmbeds( }); } else { const strings = constants.contexts.definitions({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.displayLocale, }); fields.push({ @@ -564,7 +561,7 @@ function entryToEmbeds( const expressionsFitted = fitTextToFieldSize(client, interaction, expressionsStringified, verbose); const strings = constants.contexts.expressions({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.displayLocale, }); if (verbose) { @@ -597,7 +594,7 @@ function entryToEmbeds( .join("\n"); const strings = constants.contexts.etymology({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.displayLocale, }); if (verbose) { @@ -675,7 +672,7 @@ function stringifyEntries< if (isDefinition(entry, entryType)) { if (entry.relations !== undefined) { const strings = constants.contexts.wordRelations({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.displayLocale, }); @@ -758,7 +755,7 @@ function fitTextToFieldSize( verbose: boolean, ): string { const strings = constants.contexts.definitionsOmitted({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.displayLocale, }); const characterOverhead = diff --git a/source/library/commands/interactions.ts b/source/library/commands/interactions.ts index 00c06e07e..e4a182958 100644 --- a/source/library/commands/interactions.ts +++ b/source/library/commands/interactions.ts @@ -83,10 +83,7 @@ function parseVerboseTimeExpressionPhrase( const timeUnits = Object.keys(constants.time) as TimeUnit[]; const timeUnitAliasTuples: [TimeUnit, string[]][] = []; - const strings = constants.contexts.timeUnit({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.timeUnit({ localise: client.localise, locale: interaction.locale }); for (const timeUnit of timeUnits) { timeUnitAliasTuples.push([ timeUnit, diff --git a/source/library/commands/praises.ts b/source/library/commands/praises.ts index 6e92f1990..d522798d5 100644 --- a/source/library/commands/praises.ts +++ b/source/library/commands/praises.ts @@ -14,14 +14,14 @@ function getPraisePage( switch (type) { case "author": { strings = constants.contexts.noPraisesForSelfAsAuthor({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); break; } case "target": { strings = constants.contexts.noPraisesForSelfAsTarget({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); break; @@ -38,14 +38,14 @@ function getPraisePage( switch (type) { case "author": { strings = constants.contexts.noPraisesForOtherAsAuthor({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); break; } case "target": { strings = constants.contexts.noPraisesForOtherAsTarget({ - localise: client.localise.bind(client), + localise: client.localise, locale: interaction.locale, }); break; @@ -58,8 +58,7 @@ function getPraisePage( }; } - const strings = constants.contexts.praise({ localise: client.localise.bind(client), locale: interaction.locale }); - + const strings = constants.contexts.praise({ localise: client.localise, locale: interaction.locale }); return { title: strings.title, description: praises diff --git a/source/library/commands/resolvers/youtube.ts b/source/library/commands/resolvers/youtube.ts index 6c0db8cb2..aa6c5ad4a 100644 --- a/source/library/commands/resolvers/youtube.ts +++ b/source/library/commands/resolvers/youtube.ts @@ -88,10 +88,7 @@ async function search(client: Client, interaction: Logos.Interaction, query: str }); } - const strings = constants.contexts.selectSong({ - localise: client.localise.bind(client), - locale: interaction.locale, - }); + const strings = constants.contexts.selectSong({ localise: client.localise, locale: interaction.locale }); await client.notice(interaction, { embeds: [ { diff --git a/source/library/commands/rules.ts b/source/library/commands/rules.ts index 9a8e08ec2..f774d55cc 100644 --- a/source/library/commands/rules.ts +++ b/source/library/commands/rules.ts @@ -9,7 +9,7 @@ function getRuleTitleFormatted( ): string { const index = isValidRule(rule) ? constants.rules.indexOf(rule) : undefined; const indexFormatted = index !== undefined ? index + 1 : "?"; - const strings = constants.contexts.rule({ localise: client.localise.bind(client), locale: interaction.locale }); + const strings = constants.contexts.rule({ localise: client.localise, locale: interaction.locale }); switch (mode) { case "option": return `#${indexFormatted} ${strings.title(rule)} ~ ${strings.summary(rule)}`; diff --git a/source/library/services/entry.ts b/source/library/services/entry.ts index 2dc5813ca..840e1a078 100644 --- a/source/library/services/entry.ts +++ b/source/library/services/entry.ts @@ -52,7 +52,7 @@ class EntryService extends LocalService { await this.client.registerInteractionCollector(languageProficiencyButtons); const strings = constants.contexts.chooseProficiency({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: buttonPress.locale, }); await this.client.notice(buttonPress, { @@ -79,7 +79,7 @@ class EntryService extends LocalService { constants.roles.language.categories.proficiency.collection.list, ).map((proficiencyRole, index) => { const strings = constants.contexts.role({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: buttonPress.locale, }); return { @@ -141,7 +141,7 @@ class EntryService extends LocalService { const isVerified = userDocument.isAuthorisedOn({ guildId: this.guildIdString }); if (!isVerified) { const strings = constants.contexts.getVerified({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: buttonPress.locale, }); await this.client.notice(buttonPress, { @@ -174,7 +174,7 @@ class EntryService extends LocalService { } const strings = constants.contexts.receivedAccess({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: buttonPress.locale, }); await this.client.success(buttonPress, { @@ -216,7 +216,7 @@ class EntryService extends LocalService { if (entryRequestDocument !== undefined) { const strings = constants.contexts.alreadyAnswered({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: buttonPress.locale, }); await this.client.pushback(buttonPress, { @@ -242,7 +242,7 @@ class EntryService extends LocalService { composer.onSubmit(async (submission, { formData }) => { if (entryRequest !== undefined) { const strings = constants.contexts.alreadyAnswered({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: submission.locale, }); await this.client.pushback(submission, { @@ -282,7 +282,7 @@ class EntryService extends LocalService { verificationService.registerHandler(entryRequestDocument); const strings = constants.contexts.verificationAnswersSubmitted({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: submission.locale, }); await this.client.succeeded(submission, { @@ -302,7 +302,7 @@ class EntryService extends LocalService { if (entryRequestDocument !== undefined && !entryRequestDocument.isFinalised) { const strings = constants.contexts.alreadyAnswered({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); await this.client.pushback(interaction, { @@ -319,7 +319,7 @@ class EntryService extends LocalService { if (userDocument.isRejectedOn({ guildId: this.guildIdString })) { const strings = constants.contexts.rejectedBefore({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); await this.client.error(interaction, { diff --git a/source/library/services/interaction-repetition.ts b/source/library/services/interaction-repetition.ts index 50099a03b..c961f8f1c 100644 --- a/source/library/services/interaction-repetition.ts +++ b/source/library/services/interaction-repetition.ts @@ -80,7 +80,7 @@ class InteractionRepetitionService extends GlobalService { await this.client.registerInteractionCollector(cancelButton); const strings = constants.contexts.sureToShow({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: buttonPress.locale, }); await this.client.pushedBack(buttonPress, { @@ -114,7 +114,7 @@ class InteractionRepetitionService extends GlobalService { getShowButton(interaction: Logos.Interaction): Discord.ButtonComponent { const strings = constants.contexts.show({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); return { diff --git a/source/library/services/music.ts b/source/library/services/music.ts index aa103e893..50e800c05 100644 --- a/source/library/services/music.ts +++ b/source/library/services/music.ts @@ -120,7 +120,7 @@ class MusicService extends LocalService { async #handleSessionAbandoned(): Promise { const strings = constants.contexts.stopped({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: this.guildLocale, }); await this.client.bot.helpers @@ -152,7 +152,7 @@ class MusicService extends LocalService { } const strings = constants.contexts.musicHalted({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: this.guildLocale, }); this.client.bot.helpers @@ -179,7 +179,7 @@ class MusicService extends LocalService { await this.session.restore(); const strings = constants.contexts.musicRestored({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: this.guildLocale, }); this.client.bot.helpers @@ -198,41 +198,38 @@ class MusicService extends LocalService { #canPerformAction(interaction: Logos.Interaction, { action }: { action: PlaybackActionType }): boolean { if (this.session.isDisconnected) { const strings = constants.contexts.cannotManageDuringOutage({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: this.guildLocale, }); this.client.unsupported(interaction, { title: strings.title, description: `${strings.description.outage}\n\n${strings.description.backUpSoon}`, }); - return false; } const userChannelId = this.guild.voiceStates.get(interaction.user.id)?.channelId; if (userChannelId === undefined) { const strings = constants.contexts.notInVc({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: this.guildLocale, }); this.client.warning(interaction, { title: strings.title, description: action === "manage" ? strings.description.toManage : strings.description.toCheck, }); - return false; } if (this.hasSession && userChannelId !== this.session.channelId) { const strings = constants.contexts.botInDifferentVc({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: this.guildLocale, }); this.client.warning(interaction, { title: strings.title, description: strings.description, }); - return false; } @@ -254,7 +251,7 @@ class MusicService extends LocalService { if (this.session.listings.queue.isFull) { const strings = constants.contexts.queueFull({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); this.client.warning(interaction, { @@ -503,7 +500,7 @@ class MusicSession extends EventEmitter { this.log.warn(`Failed to play track: ${event.exception}`); const strings = constants.contexts.failedToPlay({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: this.service.guildLocale, }); this.client.bot.helpers @@ -532,7 +529,7 @@ class MusicSession extends EventEmitter { if (this.hasCurrent) { const strings = constants.contexts.queued({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: this.service.guildLocale, }); await this.client.bot.helpers @@ -633,7 +630,7 @@ class MusicSession extends EventEmitter { await this.player.playTrack({ track: track.encoded }); const strings = constants.contexts.nowPlaying({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: this.service.guildLocale, }); this.client.bot.helpers @@ -707,7 +704,7 @@ class MusicSession extends EventEmitter { this.playable.reset(); const strings = constants.contexts.failedToLoadTrack({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: this.service.guildLocale, }); this.client.bot.helpers diff --git a/source/library/services/notices/information.ts b/source/library/services/notices/information.ts index e211d65af..5af7f8a14 100644 --- a/source/library/services/notices/information.ts +++ b/source/library/services/notices/information.ts @@ -9,14 +9,8 @@ class InformationNoticeService extends NoticeService<{ type: "information" }> { generateNotice(): HashableMessageContents | undefined { const informationFields = constants.rules.map((rule, index) => { const strings = { - ...constants.contexts.tldr({ - localise: this.client.localise.bind(this.client), - locale: this.guildLocale, - }), - ...constants.contexts.rule({ - localise: this.client.localise.bind(this.client), - locale: this.guildLocale, - }), + ...constants.contexts.tldr({ localise: this.client.localise, locale: this.guildLocale }), + ...constants.contexts.rule({ localise: this.client.localise, locale: this.guildLocale }), }; return { name: `${constants.emojis.ruleBullet} #${index + 1} ~ **${strings.title(rule).toUpperCase()}** ~ ${ @@ -27,10 +21,7 @@ class InformationNoticeService extends NoticeService<{ type: "information" }> { }; }); - const strings = constants.contexts.invite({ - localise: this.client.localise.bind(this.client), - locale: this.guildLocale, - }); + const strings = constants.contexts.invite({ localise: this.client.localise, locale: this.guildLocale }); return { embeds: [ { diff --git a/source/library/services/notices/resources.ts b/source/library/services/notices/resources.ts index 6a4666a97..1e140c11f 100644 --- a/source/library/services/notices/resources.ts +++ b/source/library/services/notices/resources.ts @@ -14,14 +14,8 @@ class ResourceNoticeService extends NoticeService<{ type: "resources" }> { } const strings = { - ...constants.contexts.resourceNotice({ - localise: this.client.localise.bind(this.client), - locale: this.guildLocale, - }), - ...constants.contexts.language({ - localise: this.client.localise.bind(this.client), - locale: this.guildLocale, - }), + ...constants.contexts.resourceNotice({ localise: this.client.localise, locale: this.guildLocale }), + ...constants.contexts.language({ localise: this.client.localise, locale: this.guildLocale }), }; return { embeds: [ diff --git a/source/library/services/notices/roles.ts b/source/library/services/notices/roles.ts index b0a0a7fcb..7abef037a 100644 --- a/source/library/services/notices/roles.ts +++ b/source/library/services/notices/roles.ts @@ -35,10 +35,9 @@ class RoleNoticeService extends NoticeService<{ type: "roles" }> { generateNotice(): HashableMessageContents | undefined { const strings = constants.contexts.howToSelectRoles({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: this.guildLocale, }); - return { embeds: [ { diff --git a/source/library/services/notices/welcome.ts b/source/library/services/notices/welcome.ts index b293269b3..fde56e21b 100644 --- a/source/library/services/notices/welcome.ts +++ b/source/library/services/notices/welcome.ts @@ -8,10 +8,7 @@ class WelcomeNoticeService extends NoticeService<{ type: "welcome" }> { } generateNotice(): HashableMessageContents | undefined { - const strings = constants.contexts.welcomeNotice({ - localise: this.client.localise.bind(this.client), - locale: this.guildLocale, - }); + const strings = constants.contexts.welcomeNotice({ localise: this.client.localise, locale: this.guildLocale }); return { embeds: [ { diff --git a/source/library/services/prompts/reports.ts b/source/library/services/prompts/reports.ts index 453c6666c..2386e86f8 100644 --- a/source/library/services/prompts/reports.ts +++ b/source/library/services/prompts/reports.ts @@ -32,7 +32,7 @@ class ReportPromptService extends PromptService<{ getPromptContent(user: Logos.User, reportDocument: Report): Discord.CreateMessageOptions | undefined { const strings = constants.contexts.reportPrompt({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: this.guildLocale, }); return { @@ -123,7 +123,7 @@ class ReportPromptService extends PromptService<{ const isResolved = interaction.metadata[2] === "true"; if (isResolved && reportDocument.isResolved) { const strings = constants.contexts.alreadyMarkedResolved({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); await this.client.warning(interaction, { @@ -135,7 +135,7 @@ class ReportPromptService extends PromptService<{ if (!(isResolved || reportDocument.isResolved)) { const strings = constants.contexts.alreadyMarkedUnresolved({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); await this.client.warning(interaction, { diff --git a/source/library/services/prompts/resources.ts b/source/library/services/prompts/resources.ts index 925a4ad25..beec46cac 100644 --- a/source/library/services/prompts/resources.ts +++ b/source/library/services/prompts/resources.ts @@ -32,7 +32,7 @@ class ResourcePromptService extends PromptService<{ getPromptContent(user: Logos.User, resourceDocument: Resource): Discord.CreateMessageOptions | undefined { const strings = constants.contexts.promptControls({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: this.guildLocale, }); return { @@ -91,7 +91,7 @@ class ResourcePromptService extends PromptService<{ const isResolved = interaction.metadata[2] === "true"; if (isResolved && resourceDocument.isResolved) { const strings = constants.contexts.alreadyMarkedResolved({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); await this.client.warning(interaction, { @@ -103,7 +103,7 @@ class ResourcePromptService extends PromptService<{ if (!(isResolved || resourceDocument.isResolved)) { const strings = constants.contexts.alreadyMarkedUnresolved({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); await this.client.warning(interaction, { diff --git a/source/library/services/prompts/service.ts b/source/library/services/prompts/service.ts index f1b8d7c3a..72bd8edb2 100644 --- a/source/library/services/prompts/service.ts +++ b/source/library/services/prompts/service.ts @@ -259,7 +259,7 @@ abstract class PromptService< if (!isAuthorised) { if (this.#deleteMode === "delete") { const strings = constants.contexts.cannotRemovePrompt({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: buttonPress.locale, }); await this.client.warning(buttonPress, { @@ -271,7 +271,7 @@ abstract class PromptService< if (this.#deleteMode === "close") { const strings = constants.contexts.cannotCloseIssue({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: buttonPress.locale, }); await this.client.warning(buttonPress, { diff --git a/source/library/services/prompts/suggestions.ts b/source/library/services/prompts/suggestions.ts index 30a07fb1d..b6b34d80d 100644 --- a/source/library/services/prompts/suggestions.ts +++ b/source/library/services/prompts/suggestions.ts @@ -36,7 +36,7 @@ class SuggestionPromptService extends PromptService<{ getPromptContent(user: Logos.User, suggestionDocument: Suggestion): Discord.CreateMessageOptions | undefined { const strings = constants.contexts.promptControls({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: this.guildLocale, }); return { @@ -95,7 +95,7 @@ class SuggestionPromptService extends PromptService<{ const isResolved = interaction.metadata[2] === "true"; if (isResolved && suggestionDocument.isResolved) { const strings = constants.contexts.alreadyMarkedResolved({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); await this.client.warning(interaction, { @@ -107,7 +107,7 @@ class SuggestionPromptService extends PromptService<{ if (!(isResolved || suggestionDocument.isResolved)) { const strings = constants.contexts.alreadyMarkedUnresolved({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); await this.client.warning(interaction, { diff --git a/source/library/services/prompts/tickets.ts b/source/library/services/prompts/tickets.ts index d862f5341..baaccd0f0 100644 --- a/source/library/services/prompts/tickets.ts +++ b/source/library/services/prompts/tickets.ts @@ -43,7 +43,7 @@ class TicketPromptService extends PromptService<{ } const strings = constants.contexts.promptControls({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: this.guildLocale, }); return { @@ -102,7 +102,7 @@ class TicketPromptService extends PromptService<{ const isResolved = interaction.metadata[2] === "true"; if (isResolved && ticketDocument.isResolved) { const strings = constants.contexts.alreadyMarkedResolved({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); await this.client.warning(interaction, { @@ -115,7 +115,7 @@ class TicketPromptService extends PromptService<{ if (!(isResolved || ticketDocument.isResolved)) { const strings = constants.contexts.alreadyMarkedResolved({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); await this.client.warning(interaction, { @@ -166,7 +166,7 @@ class TicketPromptService extends PromptService<{ } const strings = constants.contexts.inquiry({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: this.guildLocale, }); const channel = await this.client.bot.helpers diff --git a/source/library/services/prompts/verification.ts b/source/library/services/prompts/verification.ts index 058269daf..5122c6d91 100644 --- a/source/library/services/prompts/verification.ts +++ b/source/library/services/prompts/verification.ts @@ -119,7 +119,7 @@ class VerificationPromptService extends PromptService<{ ); const strings = constants.contexts.entryRequestPrompt({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: this.guildLocale, }); return { @@ -322,7 +322,7 @@ class VerificationPromptService extends PromptService<{ await this.client.registerInteractionCollector(cancelButton); const strings = constants.contexts.sureToForceAccept({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); await this.client.pushback(interaction, { @@ -357,7 +357,7 @@ class VerificationPromptService extends PromptService<{ } const strings = constants.contexts.alreadyVotedInFavour({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); await this.client.warning(interaction, { @@ -418,7 +418,7 @@ class VerificationPromptService extends PromptService<{ await this.client.registerInteractionCollector(cancelButton); const strings = constants.contexts.sureToForceReject({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); await this.client.pushback(interaction, { @@ -453,7 +453,7 @@ class VerificationPromptService extends PromptService<{ } const strings = constants.contexts.alreadyVotedAgainst({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); await this.client.warning(interaction, { @@ -470,7 +470,7 @@ class VerificationPromptService extends PromptService<{ if (currentVote !== undefined) { const strings = constants.contexts.stanceChanged({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); await this.client.notice(interaction, { @@ -627,7 +627,7 @@ class VerificationPromptService extends PromptService<{ } const strings = constants.contexts.inquiryChannel({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: this.guildLocale, }); const ticketDocument = await ticketService.openTicket({ @@ -637,7 +637,7 @@ class VerificationPromptService extends PromptService<{ }); if (ticketDocument === undefined) { const strings = constants.contexts.inquiryFailed({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); await this.client.failed(interaction, { @@ -662,7 +662,7 @@ class VerificationPromptService extends PromptService<{ { const strings = constants.contexts.inquiryOpened({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); await this.client.succeeded(interaction, { @@ -716,7 +716,7 @@ class VerificationPromptService extends PromptService<{ async #displayVoteError(interaction: Logos.Interaction): Promise { const strings = constants.contexts.voteFailed({ - localise: this.client.localise.bind(this.client), + localise: this.client.localise, locale: interaction.locale, }); await this.client.failure(interaction, { diff --git a/source/library/stores/interactions.ts b/source/library/stores/interactions.ts index 43dbdd3a3..d278615ed 100644 --- a/source/library/stores/interactions.ts +++ b/source/library/stores/interactions.ts @@ -175,7 +175,7 @@ class InteractionStore { if (interaction.parameters["@repeat"]) { const strings = constants.contexts.thinking({ - localise: this.#client.localise.bind(this.#client), + localise: this.#client.localise, locale: interaction.guildLocale, }); const message = await this.#client.bot.helpers @@ -458,14 +458,13 @@ class InteractionStore { interaction.type === Discord.InteractionTypes.ModalSubmit ) { const strings = constants.contexts.invalidUser({ - localise: this.#client.localise.bind(this.#client), + localise: this.#client.localise, locale: interaction.locale, }); this.error(interaction, { title: strings.title, description: strings.description, }); - return undefined; } diff --git a/source/library/stores/journalling/discord/guild-ban-add.ts b/source/library/stores/journalling/discord/guild-ban-add.ts index fdff5d5fb..ca7d732c4 100644 --- a/source/library/stores/journalling/discord/guild-ban-add.ts +++ b/source/library/stores/journalling/discord/guild-ban-add.ts @@ -1,7 +1,7 @@ import type { EventLogger } from "logos/stores/journalling/loggers"; const logger: EventLogger<"guildBanAdd"> = (client, [user, _], { guildLocale }) => { - const strings = constants.contexts.guildBanAdd({ localise: client.localise.bind(client), locale: guildLocale }); + const strings = constants.contexts.guildBanAdd({ localise: client.localise, locale: guildLocale }); return { embeds: [ { diff --git a/source/library/stores/journalling/discord/guild-ban-remove.ts b/source/library/stores/journalling/discord/guild-ban-remove.ts index 5eba60842..1e6694f72 100644 --- a/source/library/stores/journalling/discord/guild-ban-remove.ts +++ b/source/library/stores/journalling/discord/guild-ban-remove.ts @@ -1,7 +1,7 @@ import type { EventLogger } from "logos/stores/journalling/loggers"; const logger: EventLogger<"guildBanRemove"> = (client, [user, _], { guildLocale }) => { - const strings = constants.contexts.guildBanRemove({ localise: client.localise.bind(client), locale: guildLocale }); + const strings = constants.contexts.guildBanRemove({ localise: client.localise, locale: guildLocale }); return { embeds: [ { diff --git a/source/library/stores/journalling/discord/guild-member-add.ts b/source/library/stores/journalling/discord/guild-member-add.ts index 0fdc33918..a6c182d66 100644 --- a/source/library/stores/journalling/discord/guild-member-add.ts +++ b/source/library/stores/journalling/discord/guild-member-add.ts @@ -1,7 +1,7 @@ import type { EventLogger } from "logos/stores/journalling/loggers"; const logger: EventLogger<"guildMemberAdd"> = (client, [_, user], { guildLocale }) => { - const strings = constants.contexts.guildMemberAdd({ localise: client.localise.bind(client), locale: guildLocale }); + const strings = constants.contexts.guildMemberAdd({ localise: client.localise, locale: guildLocale }); return { embeds: [ { diff --git a/source/library/stores/journalling/discord/guild-member-remove.ts b/source/library/stores/journalling/discord/guild-member-remove.ts index 7124baa02..67df3aa23 100644 --- a/source/library/stores/journalling/discord/guild-member-remove.ts +++ b/source/library/stores/journalling/discord/guild-member-remove.ts @@ -2,7 +2,7 @@ import type { EventLogger } from "logos/stores/journalling/loggers"; const logger: EventLogger<"guildMemberRemove"> = (client, [user, _], { guildLocale }) => { const strings = constants.contexts.guildMemberRemove({ - localise: client.localise.bind(client), + localise: client.localise, locale: guildLocale, }); return { diff --git a/source/library/stores/journalling/discord/message-delete.ts b/source/library/stores/journalling/discord/message-delete.ts index 160240d1c..d27ccc63b 100644 --- a/source/library/stores/journalling/discord/message-delete.ts +++ b/source/library/stores/journalling/discord/message-delete.ts @@ -11,7 +11,7 @@ const logger: EventLogger<"messageDelete"> = (client, [payload, _], { guildLocal return undefined; } - const strings = constants.contexts.messageDelete({ localise: client.localise.bind(client), locale: guildLocale }); + const strings = constants.contexts.messageDelete({ localise: client.localise, locale: guildLocale }); return { embeds: [ { diff --git a/source/library/stores/journalling/discord/message-update.ts b/source/library/stores/journalling/discord/message-update.ts index 3042229a6..6f568ff74 100644 --- a/source/library/stores/journalling/discord/message-update.ts +++ b/source/library/stores/journalling/discord/message-update.ts @@ -11,7 +11,7 @@ const logger: EventLogger<"messageUpdate"> = (client, [message, _], { guildLocal return undefined; } - const strings = constants.contexts.messageUpdate({ localise: client.localise.bind(client), locale: guildLocale }); + const strings = constants.contexts.messageUpdate({ localise: client.localise, locale: guildLocale }); return { embeds: [ { diff --git a/source/library/stores/journalling/logos/entry-request-accept.ts b/source/library/stores/journalling/logos/entry-request-accept.ts index 7056efa03..cc10de28a 100644 --- a/source/library/stores/journalling/logos/entry-request-accept.ts +++ b/source/library/stores/journalling/logos/entry-request-accept.ts @@ -2,7 +2,7 @@ import type { EventLogger } from "logos/stores/journalling/loggers"; const logger: EventLogger<"entryRequestAccept"> = (client, [user, author], { guildLocale }) => { const strings = constants.contexts.entryRequestAccept({ - localise: client.localise.bind(client), + localise: client.localise, locale: guildLocale, }); return { diff --git a/source/library/stores/journalling/logos/entry-request-reject.ts b/source/library/stores/journalling/logos/entry-request-reject.ts index 4fb483f1a..ec4724642 100644 --- a/source/library/stores/journalling/logos/entry-request-reject.ts +++ b/source/library/stores/journalling/logos/entry-request-reject.ts @@ -2,7 +2,7 @@ import type { EventLogger } from "logos/stores/journalling/loggers"; const logger: EventLogger<"entryRequestReject"> = (client, [user, author], { guildLocale }) => { const strings = constants.contexts.entryRequestReject({ - localise: client.localise.bind(client), + localise: client.localise, locale: guildLocale, }); return { diff --git a/source/library/stores/journalling/logos/entry-request-submit.ts b/source/library/stores/journalling/logos/entry-request-submit.ts index 529820beb..6bb2d8b5a 100644 --- a/source/library/stores/journalling/logos/entry-request-submit.ts +++ b/source/library/stores/journalling/logos/entry-request-submit.ts @@ -3,8 +3,8 @@ import type { EventLogger } from "logos/stores/journalling/loggers"; const logger: EventLogger<"entryRequestSubmit"> = (client, [user, entryRequest], { guildLocale, featureLanguage }) => { const strings = { - ...constants.contexts.verificationModal({ localise: client.localise.bind(client), locale: guildLocale }), - ...constants.contexts.entryRequestSubmit({ localise: client.localise.bind(client), locale: guildLocale }), + ...constants.contexts.verificationModal({ localise: client.localise, locale: guildLocale }), + ...constants.contexts.entryRequestSubmit({ localise: client.localise, locale: guildLocale }), }; return { embeds: [ diff --git a/source/library/stores/journalling/logos/inquiry-open.ts b/source/library/stores/journalling/logos/inquiry-open.ts index d80c2fffc..0725485e9 100644 --- a/source/library/stores/journalling/logos/inquiry-open.ts +++ b/source/library/stores/journalling/logos/inquiry-open.ts @@ -1,7 +1,7 @@ import type { EventLogger } from "logos/stores/journalling/loggers"; const logger: EventLogger<"inquiryOpen"> = (client, [member, _], { guildLocale }) => { - const strings = constants.contexts.inquiryOpen({ localise: client.localise.bind(client), locale: guildLocale }); + const strings = constants.contexts.inquiryOpen({ localise: client.localise, locale: guildLocale }); return { embeds: [ { diff --git a/source/library/stores/journalling/logos/member-timeout-add.ts b/source/library/stores/journalling/logos/member-timeout-add.ts index 75e7f5406..cf8b5453a 100644 --- a/source/library/stores/journalling/logos/member-timeout-add.ts +++ b/source/library/stores/journalling/logos/member-timeout-add.ts @@ -3,7 +3,7 @@ import type { EventLogger } from "logos/stores/journalling/loggers"; const logger: EventLogger<"memberTimeoutAdd"> = (client, [member, until, reason, author], { guildLocale }) => { const strings = constants.contexts.memberTimeoutAdd({ - localise: client.localise.bind(client), + localise: client.localise, locale: guildLocale, }); return { diff --git a/source/library/stores/journalling/logos/member-timeout-remove.ts b/source/library/stores/journalling/logos/member-timeout-remove.ts index cd5d16385..7adb85319 100644 --- a/source/library/stores/journalling/logos/member-timeout-remove.ts +++ b/source/library/stores/journalling/logos/member-timeout-remove.ts @@ -2,7 +2,7 @@ import type { EventLogger } from "logos/stores/journalling/loggers"; const logger: EventLogger<"memberTimeoutRemove"> = (client, [member, author], { guildLocale }) => { const strings = constants.contexts.memberTimeoutRemove({ - localise: client.localise.bind(client), + localise: client.localise, locale: guildLocale, }); return { diff --git a/source/library/stores/journalling/logos/member-warn-add.ts b/source/library/stores/journalling/logos/member-warn-add.ts index 6a9793b5f..2d2ba2eb5 100644 --- a/source/library/stores/journalling/logos/member-warn-add.ts +++ b/source/library/stores/journalling/logos/member-warn-add.ts @@ -1,7 +1,7 @@ import type { EventLogger } from "logos/stores/journalling/loggers"; const logger: EventLogger<"memberWarnAdd"> = (client, [member, warning, author], { guildLocale }) => { - const strings = constants.contexts.memberWarnAdd({ localise: client.localise.bind(client), locale: guildLocale }); + const strings = constants.contexts.memberWarnAdd({ localise: client.localise, locale: guildLocale }); return { embeds: [ { diff --git a/source/library/stores/journalling/logos/member-warn-remove.ts b/source/library/stores/journalling/logos/member-warn-remove.ts index 4719f5375..e73369bb3 100644 --- a/source/library/stores/journalling/logos/member-warn-remove.ts +++ b/source/library/stores/journalling/logos/member-warn-remove.ts @@ -1,10 +1,7 @@ import type { EventLogger } from "logos/stores/journalling/loggers"; const logger: EventLogger<"memberWarnRemove"> = (client, [member, warning, author], { guildLocale }) => { - const strings = constants.contexts.memberWarnRemove({ - localise: client.localise.bind(client), - locale: guildLocale, - }); + const strings = constants.contexts.memberWarnRemove({ localise: client.localise, locale: guildLocale }); return { embeds: [ { diff --git a/source/library/stores/journalling/logos/praise-add.ts b/source/library/stores/journalling/logos/praise-add.ts index e12ad7494..5c9e9a494 100644 --- a/source/library/stores/journalling/logos/praise-add.ts +++ b/source/library/stores/journalling/logos/praise-add.ts @@ -1,7 +1,7 @@ import type { EventLogger } from "logos/stores/journalling/loggers"; const logger: EventLogger<"praiseAdd"> = (client, [member, praise, author], { guildLocale }) => { - const strings = constants.contexts.praiseAdd({ localise: client.localise.bind(client), locale: guildLocale }); + const strings = constants.contexts.praiseAdd({ localise: client.localise, locale: guildLocale }); return { embeds: [ { diff --git a/source/library/stores/journalling/logos/purge-begin.ts b/source/library/stores/journalling/logos/purge-begin.ts index 115e92801..7912a8948 100644 --- a/source/library/stores/journalling/logos/purge-begin.ts +++ b/source/library/stores/journalling/logos/purge-begin.ts @@ -2,7 +2,7 @@ import { mention } from "logos:core/formatting"; import type { EventLogger } from "logos/stores/journalling/loggers"; const logger: EventLogger<"purgeBegin"> = (client, [member, channel, messageCount, author], { guildLocale }) => { - const strings = constants.contexts.purgeBegin({ localise: client.localise.bind(client), locale: guildLocale }); + const strings = constants.contexts.purgeBegin({ localise: client.localise, locale: guildLocale }); return { embeds: [ { diff --git a/source/library/stores/journalling/logos/purge-end.ts b/source/library/stores/journalling/logos/purge-end.ts index 26491b888..8716e0cc2 100644 --- a/source/library/stores/journalling/logos/purge-end.ts +++ b/source/library/stores/journalling/logos/purge-end.ts @@ -2,7 +2,7 @@ import { mention } from "logos:core/formatting"; import type { EventLogger } from "logos/stores/journalling/loggers"; const logger: EventLogger<"purgeEnd"> = (client, [member, channel, messageCount, author], { guildLocale }) => { - const strings = constants.contexts.purgeEnd({ localise: client.localise.bind(client), locale: guildLocale }); + const strings = constants.contexts.purgeEnd({ localise: client.localise, locale: guildLocale }); return { embeds: [ { diff --git a/source/library/stores/journalling/logos/report-submit.ts b/source/library/stores/journalling/logos/report-submit.ts index 58bbe29f8..2fb343b55 100644 --- a/source/library/stores/journalling/logos/report-submit.ts +++ b/source/library/stores/journalling/logos/report-submit.ts @@ -1,7 +1,7 @@ import type { EventLogger } from "logos/stores/journalling/loggers"; const logger: EventLogger<"reportSubmit"> = (client, [author, report], { guildLocale }) => { - const strings = constants.contexts.reportSubmit({ localise: client.localise.bind(client), locale: guildLocale }); + const strings = constants.contexts.reportSubmit({ localise: client.localise, locale: guildLocale }); return { embeds: [ { diff --git a/source/library/stores/journalling/logos/resource-send.ts b/source/library/stores/journalling/logos/resource-send.ts index 946ce820e..80c355a16 100644 --- a/source/library/stores/journalling/logos/resource-send.ts +++ b/source/library/stores/journalling/logos/resource-send.ts @@ -1,7 +1,7 @@ import type { EventLogger } from "logos/stores/journalling/loggers"; const logger: EventLogger<"resourceSend"> = (client, [author, resource], { guildLocale }) => { - const strings = constants.contexts.resourceSend({ localise: client.localise.bind(client), locale: guildLocale }); + const strings = constants.contexts.resourceSend({ localise: client.localise, locale: guildLocale }); return { embeds: [ { diff --git a/source/library/stores/journalling/logos/slowmode-disable.ts b/source/library/stores/journalling/logos/slowmode-disable.ts index cefe50dbc..ee4df662e 100644 --- a/source/library/stores/journalling/logos/slowmode-disable.ts +++ b/source/library/stores/journalling/logos/slowmode-disable.ts @@ -2,7 +2,7 @@ import { mention } from "logos:core/formatting"; import type { EventLogger } from "logos/stores/journalling/loggers"; const logger: EventLogger<"slowmodeDisable"> = (client, [user, channel], { guildLocale }) => { - const strings = constants.contexts.slowmodeDisable({ localise: client.localise.bind(client), locale: guildLocale }); + const strings = constants.contexts.slowmodeDisable({ localise: client.localise, locale: guildLocale }); return { embeds: [ { diff --git a/source/library/stores/journalling/logos/slowmode-downgrade.ts b/source/library/stores/journalling/logos/slowmode-downgrade.ts index b9eb991c8..d10eb29f4 100644 --- a/source/library/stores/journalling/logos/slowmode-downgrade.ts +++ b/source/library/stores/journalling/logos/slowmode-downgrade.ts @@ -7,7 +7,7 @@ const logger: EventLogger<"slowmodeDowngrade"> = ( { guildLocale }, ) => { const strings = constants.contexts.slowmodeDowngrade({ - localise: client.localise.bind(client), + localise: client.localise, locale: guildLocale, }); return { diff --git a/source/library/stores/journalling/logos/slowmode-enable.ts b/source/library/stores/journalling/logos/slowmode-enable.ts index eba73b33a..58846d599 100644 --- a/source/library/stores/journalling/logos/slowmode-enable.ts +++ b/source/library/stores/journalling/logos/slowmode-enable.ts @@ -2,7 +2,7 @@ import { mention } from "logos:core/formatting"; import type { EventLogger } from "logos/stores/journalling/loggers"; const logger: EventLogger<"slowmodeEnable"> = (client, [user, channel, level], { guildLocale }) => { - const strings = constants.contexts.slowmodeEnable({ localise: client.localise.bind(client), locale: guildLocale }); + const strings = constants.contexts.slowmodeEnable({ localise: client.localise, locale: guildLocale }); return { embeds: [ { diff --git a/source/library/stores/journalling/logos/slowmode-upgrade.ts b/source/library/stores/journalling/logos/slowmode-upgrade.ts index 821618416..15b746e00 100644 --- a/source/library/stores/journalling/logos/slowmode-upgrade.ts +++ b/source/library/stores/journalling/logos/slowmode-upgrade.ts @@ -6,7 +6,7 @@ const logger: EventLogger<"slowmodeUpgrade"> = ( [user, channel, previousLevel, currentLevel], { guildLocale }, ) => { - const strings = constants.contexts.slowmodeUpgrade({ localise: client.localise.bind(client), locale: guildLocale }); + const strings = constants.contexts.slowmodeUpgrade({ localise: client.localise, locale: guildLocale }); return { embeds: [ { diff --git a/source/library/stores/journalling/logos/suggestion-send.ts b/source/library/stores/journalling/logos/suggestion-send.ts index 7adf10947..19faf128c 100644 --- a/source/library/stores/journalling/logos/suggestion-send.ts +++ b/source/library/stores/journalling/logos/suggestion-send.ts @@ -1,7 +1,7 @@ import type { EventLogger } from "logos/stores/journalling/loggers"; const logger: EventLogger<"suggestionSend"> = (client, [member, suggestion], { guildLocale }) => { - const strings = constants.contexts.suggestionSend({ localise: client.localise.bind(client), locale: guildLocale }); + const strings = constants.contexts.suggestionSend({ localise: client.localise, locale: guildLocale }); return { embeds: [ { diff --git a/source/library/stores/journalling/logos/ticket-open.ts b/source/library/stores/journalling/logos/ticket-open.ts index c68a65a43..070974449 100644 --- a/source/library/stores/journalling/logos/ticket-open.ts +++ b/source/library/stores/journalling/logos/ticket-open.ts @@ -1,7 +1,7 @@ import type { EventLogger } from "logos/stores/journalling/loggers"; const logger: EventLogger<"ticketOpen"> = (client, [member, ticket], { guildLocale }) => { - const strings = constants.contexts.ticketOpen({ localise: client.localise.bind(client), locale: guildLocale }); + const strings = constants.contexts.ticketOpen({ localise: client.localise, locale: guildLocale }); return { embeds: [ { diff --git a/source/library/stores/localisations.ts b/source/library/stores/localisations.ts index 2d1d6822e..f0212ef51 100644 --- a/source/library/stores/localisations.ts +++ b/source/library/stores/localisations.ts @@ -245,7 +245,7 @@ class LocalisationStore { const locale = visibility === "public" ? interaction.guildLocale : interaction.locale; const strings = contexts - .map((builder) => builder({ localise: this.localise.bind(this), locale })) + .map((builder) => builder({ localise: this.localise, locale })) .reduce((combined, context) => Object.assign(combined, context), {} as T); return await scope(strings);