Skip to content

Commit

Permalink
Merge branch 'main' into 336-add-ability-to-search-for-a-word-in-context
Browse files Browse the repository at this point in the history
  • Loading branch information
vxern authored Jul 13, 2024
2 parents 7453953 + 5531c32 commit 1a0f2d3
Show file tree
Hide file tree
Showing 112 changed files with 344 additions and 603 deletions.
10 changes: 5 additions & 5 deletions source/library/adapters/dictionaries/dexonline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class DexonlineAdapter extends DictionaryAdapter<Dexonline.Results> {
}

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 [
Expand Down Expand Up @@ -195,7 +195,7 @@ class DexonlineAdapter extends DictionaryAdapter<Dexonline.Results> {
}

const strings = constants.contexts.dexonlineNoun({
localise: this.client.localise.bind(this.client),
localise: this.client.localise,
locale: interaction.locale,
});
const numberColumn = {
Expand Down Expand Up @@ -301,7 +301,7 @@ class DexonlineAdapter extends DictionaryAdapter<Dexonline.Results> {
);

const strings = constants.contexts.dexonlineVerb({
localise: this.client.localise.bind(this.client),
localise: this.client.localise,
locale: interaction.locale,
});
return [
Expand Down Expand Up @@ -463,7 +463,7 @@ class DexonlineAdapter extends DictionaryAdapter<Dexonline.Results> {
}

const strings = constants.contexts.dexonlineAdjective({
localise: this.client.localise.bind(this.client),
localise: this.client.localise,
locale: interaction.locale,
});
return [
Expand Down Expand Up @@ -500,7 +500,7 @@ class DexonlineAdapter extends DictionaryAdapter<Dexonline.Results> {
}

const strings = constants.contexts.dexonlineDeterminer({
localise: this.client.localise.bind(this.client),
localise: this.client.localise,
locale: interaction.locale,
});
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AnswerComposer extends ModalComposer<AnswerFormData, never> {

buildModal(submission: Logos.Interaction, { formData }: { formData: AnswerFormData }): Modal<AnswerFormData> {
const strings = constants.contexts.answerModal({
localise: this.client.localise.bind(this.client),
localise: this.client.localise,
locale: submission.locale,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CorrectionComposer extends ModalComposer<CorrectionFormData, ValidationErr
{ formData }: { formData: CorrectionFormData },
): Modal<CorrectionFormData> {
const strings = constants.contexts.correctionModal({
localise: this.client.localise.bind(this.client),
localise: this.client.localise,
locale: submission.locale,
});

Expand Down Expand Up @@ -79,7 +79,7 @@ class CorrectionComposer extends ModalComposer<CorrectionFormData, ValidationErr
switch (error) {
case "texts-not-different": {
const strings = constants.contexts.correctionTextsNotDifferent({
localise: this.client.localise.bind(this.client),
localise: this.client.localise,
locale: submission.locale,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class EntryRequestComposer extends ModalComposer<EntryRequestFormData, never> {
{ formData }: { formData: EntryRequestFormData },
): Modal<EntryRequestFormData> {
const strings = constants.contexts.verificationModal({
localise: this.client.localise.bind(this.client),
localise: this.client.localise,
locale: submission.locale,
});
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ abstract class ModalComposer<FormData, ValidationError extends string> {
});

const strings = constants.contexts.sureToCancelReport({
localise: this.client.localise.bind(this.client),
localise: this.client.localise,
locale: submission.locale,
});
await this.client.warning(cancelButtonPress, {
Expand Down Expand Up @@ -175,7 +175,7 @@ abstract class ModalComposer<FormData, ValidationError extends string> {
await this.client.registerInteractionCollector(leaveButton);

const strings = constants.contexts.failedToSubmitForm({
localise: this.client.localise.bind(this.client),
localise: this.client.localise,
locale: submission.locale,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { ReportFormData } from "logos/models/report";
class ReportComposer extends ModalComposer<ReportFormData, never> {
buildModal(submission: Logos.Interaction, { formData }: { formData: ReportFormData }): Modal<ReportFormData> {
const strings = constants.contexts.reportModal({
localise: this.client.localise.bind(this.client),
localise: this.client.localise,
locale: submission.locale,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { ResourceFormData } from "logos/models/resource";
class ResourceComposer extends ModalComposer<ResourceFormData, never> {
buildModal(submission: Logos.Interaction, { formData }: { formData: ResourceFormData }): Modal<ResourceFormData> {
const strings = constants.contexts.resourceModal({
localise: this.client.localise.bind(this.client),
localise: this.client.localise,
locale: submission.locale,
});
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SuggestionComposer extends ModalComposer<SuggestionFormData, never> {
{ formData }: { formData: SuggestionFormData },
): Modal<SuggestionFormData> {
const strings = constants.contexts.suggestionModal({
localise: this.client.localise.bind(this.client),
localise: this.client.localise,
locale: submission.locale,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { TicketFormData } from "logos/models/ticket";
class TicketComposer extends ModalComposer<TicketFormData, never> {
buildModal(submission: Logos.Interaction, { formData }: { formData: TicketFormData }): Modal<TicketFormData> {
const strings = constants.contexts.ticketModal({
localise: this.client.localise.bind(this.client),
localise: this.client.localise,
locale: submission.locale,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ abstract class PaginatedView<T> {
title = embed.title;
} else {
const strings = constants.contexts.page({
localise: this.client.localise.bind(this.client),
localise: this.client.localise,
locale: this.#anchor.locale,
});

Expand All @@ -49,7 +49,7 @@ abstract class PaginatedView<T> {

if (!this.#isOnLastPage) {
const strings = constants.contexts.continuedOnNextPage({
localise: this.client.localise.bind(this.client),
localise: this.client.localise,
locale: this.#anchor.locale,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class RemoveSongListingView extends PaginatedView<SongListing> {
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,
});

Expand All @@ -56,7 +56,7 @@ class RemoveSongListingView extends PaginatedView<SongListing> {
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,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SongCollectionView extends PaginatedView<Song> {
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 } };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SongListingView extends PaginatedView<SongListing> {
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 } };
Expand Down
18 changes: 9 additions & 9 deletions source/library/commands/components/role-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down Expand Up @@ -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,
});

Expand All @@ -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,
}),
};
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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,
}),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down Expand Up @@ -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,
});

Expand All @@ -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,
});

Expand Down Expand Up @@ -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,
});

Expand Down Expand Up @@ -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,
});

Expand All @@ -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,
});

Expand Down Expand Up @@ -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,
});

Expand Down
10 changes: 2 additions & 8 deletions source/library/commands/fragments/licence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -43,10 +40,7 @@ async function handleDisplayLicence(
}

async function displayError(client: Client, interaction: Logos.Interaction): Promise<void> {
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,
Expand Down
5 changes: 1 addition & 4 deletions source/library/commands/handlers/acknowledgements.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import type { Client } from "logos/client";

async function handleDisplayAcknowledgements(client: Client, interaction: Logos.Interaction): Promise<void> {
const strings = constants.contexts.acknowledgements({
localise: client.localise.bind(client),
locale: interaction.locale,
});
const fields = constants.acknowledgements.map<Discord.CamelizedDiscordEmbedField>((acknowledgement) => {
const contributorsFormatted = acknowledgement.users.map((contributor) => contributor.username).join(", ");

Expand All @@ -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,
Expand Down
Loading

0 comments on commit 1a0f2d3

Please sign in to comment.