Skip to content

Commit

Permalink
feat(i18next): support ModalSubmitInteraction (#473)
Browse files Browse the repository at this point in the history
* feat(i18next): support ModalSubmitInteraction

* fix: use `BaseInteraction`

---------

Co-authored-by: Jeroen Claassens <support@favware.tech>
  • Loading branch information
DemonWayne and favna committed Aug 29, 2023
1 parent d32d4b1 commit 15e1712
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
13 changes: 2 additions & 11 deletions packages/i18next/src/lib/functions.ts
@@ -1,15 +1,6 @@
import { container } from '@sapphire/pieces';
import { lazy, type NonNullObject } from '@sapphire/utilities';
import {
ChannelType,
CommandInteraction,
Guild,
Locale,
Message,
MessageComponentInteraction,
type APIApplicationCommandOptionChoice,
type LocaleString
} from 'discord.js';
import { BaseInteraction, ChannelType, Guild, Locale, Message, type APIApplicationCommandOptionChoice, type LocaleString } from 'discord.js';
import type { TFuncKey, TOptions } from 'i18next';
import type {
BuilderWithDescription,
Expand Down Expand Up @@ -37,7 +28,7 @@ import type {
*/
export function fetchLanguage(target: Target): Promise<string> {
// Handle Interactions:
if (target instanceof CommandInteraction || target instanceof MessageComponentInteraction) {
if (target instanceof BaseInteraction) {
return resolveLanguage({
user: target.user,
channel: target.channel,
Expand Down
14 changes: 2 additions & 12 deletions packages/i18next/src/lib/types.ts
@@ -1,17 +1,7 @@
import type { Awaitable } from '@sapphire/utilities';
import type { Backend } from '@skyra/i18next-backend';
import type { WatchOptions } from 'chokidar';
import type {
CommandInteraction,
Guild,
Interaction,
LocalizationMap,
Message,
MessageComponentInteraction,
StageChannel,
User,
VoiceChannel
} from 'discord.js';
import type { BaseInteraction, Guild, Interaction, LocalizationMap, Message, StageChannel, User, VoiceChannel } from 'discord.js';
import type { DefaultTFuncReturnWithObject, InitOptions, Namespace, TFuncKey, TFuncReturn, TypeOptions } from 'i18next';

export interface StringMap {
Expand Down Expand Up @@ -179,4 +169,4 @@ export interface BuilderWithDescription {

export type BuilderWithNameAndDescription = BuilderWithName & BuilderWithDescription;
export type ChannelTarget = Message | DiscordChannel;
export type Target = CommandInteraction | ChannelTarget | Guild | MessageComponentInteraction;
export type Target = BaseInteraction | ChannelTarget | Guild;

0 comments on commit 15e1712

Please sign in to comment.