mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-01 14:38:48 +00:00
Localization support
This commit is contained in:
12 files changed
+220
-34
No files matched your search
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"ignorePatterns": ["config/**/*.js"],
|
"ignorePatterns": ["config/**/*.js", "locales/**"],
|
||||||
"env": {
|
"env": {
|
||||||
"node": true,
|
"node": true,
|
||||||
"es2021": true
|
"es2021": true
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"autocomplete": {
|
||||||
|
"trackName": "{{title}} [Author: {{author}}]"
|
||||||
|
},
|
||||||
|
"commands": {
|
||||||
|
"lyrics": {
|
||||||
|
"metadata": {
|
||||||
|
"description": "Search Genius lyrics for current or specified track. TEST",
|
||||||
|
"name": "lyrics",
|
||||||
|
"options": {
|
||||||
|
"query": {
|
||||||
|
"name": "query",
|
||||||
|
"description": "Search query by text or URL. TEST"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autocompleteSearchResult": "{{title}} [Artist: {{artist}}]"
|
||||||
|
},
|
||||||
|
"help": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
Vendored
+8
@@ -0,0 +1,8 @@
|
|||||||
|
import Resources from './resources';
|
||||||
|
|
||||||
|
declare module 'i18next' {
|
||||||
|
interface CustomTypeOptions {
|
||||||
|
defaultNS: 'bot';
|
||||||
|
resources: Resources;
|
||||||
|
}
|
||||||
|
}
|
||||||
Vendored
+25
@@ -0,0 +1,25 @@
|
|||||||
|
interface Resources {
|
||||||
|
"bot": {
|
||||||
|
"autocomplete": {
|
||||||
|
"trackName": "{{title}} [Author: {{author}}]"
|
||||||
|
},
|
||||||
|
"commands": {
|
||||||
|
"lyrics": {
|
||||||
|
"metadata": {
|
||||||
|
"description": "Search Genius lyrics for current or specified track. TEST",
|
||||||
|
"name": "lyrics",
|
||||||
|
"options": {
|
||||||
|
"query": {
|
||||||
|
"name": "query",
|
||||||
|
"description": "Search query by text or URL. TEST"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autocompleteSearchResult": "{{title}} [Artist: {{artist}}]"
|
||||||
|
},
|
||||||
|
"help": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Resources;
|
||||||
+5
-1
@@ -34,7 +34,8 @@
|
|||||||
"deploy": "node ./dist/utils/deploySlashCommands.js",
|
"deploy": "node ./dist/utils/deploySlashCommands.js",
|
||||||
"deploy-pretty": "node ./dist/utils/deploySlashCommands.js | pino-pretty --ignore environment,source,module,action,name,context,executionId,executionTime,shardId,guildId,interactionType",
|
"deploy-pretty": "node ./dist/utils/deploySlashCommands.js | pino-pretty --ignore environment,source,module,action,name,context,executionId,executionTime,shardId,guildId,interactionType",
|
||||||
"eslint": "eslint ./src",
|
"eslint": "eslint ./src",
|
||||||
"build": "tsc"
|
"build": "tsc",
|
||||||
|
"toc": "i18next-resources-for-ts interface -i ./locales/en -o ./locales/resources.d.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discord-player/extractor": "^4.4.5",
|
"@discord-player/extractor": "^4.4.5",
|
||||||
@@ -45,6 +46,8 @@
|
|||||||
"discord-voip": "^0.1.3",
|
"discord-voip": "^0.1.3",
|
||||||
"discord.js": "^14.14.1",
|
"discord.js": "^14.14.1",
|
||||||
"dotenv": "^16.3.1",
|
"dotenv": "^16.3.1",
|
||||||
|
"i18next": "^23.7.9",
|
||||||
|
"i18next-fs-backend": "^2.3.1",
|
||||||
"mediaplex": "^0.0.9",
|
"mediaplex": "^0.0.9",
|
||||||
"node-os-utils": "^1.3.7",
|
"node-os-utils": "^1.3.7",
|
||||||
"pino": "^8.16.2",
|
"pino": "^8.16.2",
|
||||||
@@ -62,6 +65,7 @@
|
|||||||
"eslint": "^8.55.0",
|
"eslint": "^8.55.0",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-plugin-prettier": "^5.0.1",
|
"eslint-plugin-prettier": "^5.0.1",
|
||||||
|
"i18next-resources-for-ts": "^1.4.0",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"prettier": "^3.1.1",
|
"prettier": "^3.1.1",
|
||||||
"ts-jest": "^29.1.1",
|
"ts-jest": "^29.1.1",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Track } from 'discord-player';
|
import { Track } from 'discord-player';
|
||||||
|
import { TFunction } from 'i18next';
|
||||||
|
|
||||||
export function shouldUseLastQuery(query: string, lastQuery?: string, timestamp?: number): boolean {
|
export function shouldUseLastQuery(query: string, lastQuery?: string, timestamp?: number): boolean {
|
||||||
return Boolean(
|
return Boolean(
|
||||||
@@ -10,7 +11,10 @@ export function isQueryTooShort(query: string): boolean {
|
|||||||
return query.length < 3;
|
return query.length < 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTrackName(track: Track): string {
|
export function getTrackName(track: Track, translator: TFunction): string {
|
||||||
const name = `${track.title} [Author: ${track.author}]`;
|
const name = translator('autocomplete.trackName', {
|
||||||
|
title: track.title,
|
||||||
|
author: track.author
|
||||||
|
});
|
||||||
return name.length > 100 ? name.slice(0, 100) : name;
|
return name.length > 100 ? name.slice(0, 100) : name;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
import assert from 'assert';
|
||||||
|
import { APIApplicationCommandOption, Interaction, Locale, SlashCommandBuilder } from 'discord.js';
|
||||||
|
import { lstatSync, readdirSync } from 'fs';
|
||||||
|
import i18n from 'i18next';
|
||||||
|
import i18nextFsBackend, { FsBackendOptions } from 'i18next-fs-backend';
|
||||||
|
import { join } from 'path';
|
||||||
|
|
||||||
|
const translatorInstance = i18n.createInstance();
|
||||||
|
const localeDir = join(__dirname, '..', '..', 'locales');
|
||||||
|
translatorInstance.use(i18nextFsBackend).init<FsBackendOptions>({
|
||||||
|
initImmediate: false,
|
||||||
|
fallbackLng: 'en',
|
||||||
|
preload: readdirSync(localeDir).filter((fileName) => {
|
||||||
|
const joinedPath = join(localeDir, fileName);
|
||||||
|
const isDirectory = lstatSync(joinedPath).isDirectory();
|
||||||
|
return isDirectory;
|
||||||
|
}),
|
||||||
|
ns: 'bot',
|
||||||
|
defaultNS: 'bot',
|
||||||
|
backend: {
|
||||||
|
loadPath: join(localeDir, '{{lng}}', '{{ns}}.json'),
|
||||||
|
addPath: join(localeDir, '{{lng}}', '{{ns}}.missing.json')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export function useServerTranslator(interaction: Interaction) {
|
||||||
|
return translatorInstance.getFixedT(interaction.guildLocale ?? 'en');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useUserTranslator(interaction: Interaction) {
|
||||||
|
return translatorInstance.getFixedT(interaction.locale ?? 'en');
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DISCORD_LOCALES = Object.values(Locale);
|
||||||
|
|
||||||
|
type CommandMetadata = {
|
||||||
|
name?: string;
|
||||||
|
description?: string;
|
||||||
|
options?: Record<
|
||||||
|
string,
|
||||||
|
{
|
||||||
|
name?: string;
|
||||||
|
description?: string;
|
||||||
|
}
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
|
||||||
|
type DeepMutable<T> = { -readonly [P in keyof T]: DeepMutable<T[P]> };
|
||||||
|
export function localizeCommand(command: Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>) {
|
||||||
|
const jsonCommand = command as DeepMutable<typeof command>;
|
||||||
|
|
||||||
|
assert(jsonCommand.name, `Command /${command.name} must have a name using setName.`);
|
||||||
|
const metadataKey = `commands.${jsonCommand.name}.metadata`;
|
||||||
|
const englishData = translatorInstance.getResource('en', 'bot', metadataKey) as CommandMetadata | undefined;
|
||||||
|
assert(englishData, `Command /${command.name} must have English localization data.`);
|
||||||
|
|
||||||
|
// Localizing the top-level command...
|
||||||
|
jsonCommand.description = englishData.description ?? '!MISSING DESCRIPTION!';
|
||||||
|
/* eslint-disable camelcase */
|
||||||
|
jsonCommand.name_localizations = {};
|
||||||
|
/* eslint-disable camelcase */
|
||||||
|
jsonCommand.description_localizations = {};
|
||||||
|
for (const locale of DISCORD_LOCALES) {
|
||||||
|
const localeData = translatorInstance.getResource(locale, 'bot', metadataKey) as CommandMetadata | undefined;
|
||||||
|
if (locale.startsWith('en') || !localeData) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (localeData.name) {
|
||||||
|
jsonCommand.name_localizations[locale] = localeData.name;
|
||||||
|
}
|
||||||
|
if (localeData.description) {
|
||||||
|
jsonCommand.description_localizations[locale] = localeData.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Localizing the command options...
|
||||||
|
if (jsonCommand.options) {
|
||||||
|
assert(englishData.options, `Command /${command.name} must have option localizations.`);
|
||||||
|
for (const unwritableOption of jsonCommand.options) {
|
||||||
|
const option = unwritableOption as never as APIApplicationCommandOption;
|
||||||
|
assert(option.name, `Option in /${command.name} must have a name using setName.`);
|
||||||
|
|
||||||
|
const englishOptionData = englishData.options[option.name];
|
||||||
|
option.description = englishOptionData.description ?? '!MISSING DESCRIPTION!';
|
||||||
|
|
||||||
|
option.name_localizations = {};
|
||||||
|
option.description_localizations = {};
|
||||||
|
for (const locale of DISCORD_LOCALES) {
|
||||||
|
const localeOptionData = (
|
||||||
|
translatorInstance.getResource(locale, 'bot', metadataKey) as CommandMetadata | undefined
|
||||||
|
)?.options?.[option.name];
|
||||||
|
if (locale.startsWith('en') || !localeOptionData) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (localeOptionData.name) {
|
||||||
|
option.name_localizations[locale] = localeOptionData.name;
|
||||||
|
}
|
||||||
|
if (localeOptionData.description) {
|
||||||
|
option.description_localizations[locale] = localeOptionData.description;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return jsonCommand as SlashCommandBuilder;
|
||||||
|
}
|
||||||
+1
-2
@@ -1,6 +1,5 @@
|
|||||||
// .ENV file is loaded automatically by dotenv
|
// .ENV file is loaded auomaically by doenv
|
||||||
import 'dotenv/config';
|
import 'dotenv/config';
|
||||||
|
|
||||||
// Only after loading .ENV file, we can load other modules
|
// Only after loading .ENV file, we can load other modules
|
||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { Client, Shard, ShardEvents, ShardingManager, ShardingManagerOptions } from 'discord.js';
|
import { Client, Shard, ShardEvents, ShardingManager, ShardingManagerOptions } from 'discord.js';
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import { Logger } from 'pino';
|
|||||||
import { BaseAutocompleteInteraction } from '../../classes/interactions';
|
import { BaseAutocompleteInteraction } from '../../classes/interactions';
|
||||||
import { getTrackName, isQueryTooShort, shouldUseLastQuery } from '../../common/autocompleteUtils';
|
import { getTrackName, isQueryTooShort, shouldUseLastQuery } from '../../common/autocompleteUtils';
|
||||||
import { BaseAutocompleteParams, BaseAutocompleteReturnType, RecentQuery } from '../../types/interactionTypes';
|
import { BaseAutocompleteParams, BaseAutocompleteReturnType, RecentQuery } from '../../types/interactionTypes';
|
||||||
|
import { TFunction } from 'i18next';
|
||||||
|
import { useUserTranslator } from '../../common/localeUtil';
|
||||||
class LyricsAutocomplete extends BaseAutocompleteInteraction {
|
class LyricsAutocomplete extends BaseAutocompleteInteraction {
|
||||||
private recentQueries = new Map<string, RecentQuery>();
|
private recentQueries = new Map<string, RecentQuery>();
|
||||||
|
|
||||||
@@ -15,6 +16,7 @@ class LyricsAutocomplete extends BaseAutocompleteInteraction {
|
|||||||
|
|
||||||
async execute({ executionId, interaction }: BaseAutocompleteParams): BaseAutocompleteReturnType {
|
async execute({ executionId, interaction }: BaseAutocompleteParams): BaseAutocompleteReturnType {
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useUserTranslator(interaction);
|
||||||
|
|
||||||
const query: string = interaction.options.getString('query', true);
|
const query: string = interaction.options.getString('query', true);
|
||||||
const { lastQuery, result, timestamp } = this.recentQueries.get(interaction.user.id) || {};
|
const { lastQuery, result, timestamp } = this.recentQueries.get(interaction.user.id) || {};
|
||||||
@@ -29,7 +31,7 @@ class LyricsAutocomplete extends BaseAutocompleteInteraction {
|
|||||||
return interaction.respond([]);
|
return interaction.respond([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const autocompleteChoices = await this.getAutocompleteChoices(query, logger);
|
const autocompleteChoices = await this.getAutocompleteChoices(query, logger, translator);
|
||||||
|
|
||||||
if (!autocompleteChoices || autocompleteChoices.length === 0) {
|
if (!autocompleteChoices || autocompleteChoices.length === 0) {
|
||||||
logger.debug(`Responding with empty results for query '${query}'`);
|
logger.debug(`Responding with empty results for query '${query}'`);
|
||||||
@@ -44,21 +46,23 @@ class LyricsAutocomplete extends BaseAutocompleteInteraction {
|
|||||||
|
|
||||||
private async getAutocompleteChoices(
|
private async getAutocompleteChoices(
|
||||||
query: string,
|
query: string,
|
||||||
logger: Logger
|
logger: Logger,
|
||||||
|
translator: TFunction
|
||||||
): Promise<ApplicationCommandOptionChoiceData<string>[]> {
|
): Promise<ApplicationCommandOptionChoiceData<string>[]> {
|
||||||
const genius = lyricsExtractor();
|
const genius = lyricsExtractor();
|
||||||
const lyricsResult: LyricsData = (await genius.search(query).catch(() => null)) as LyricsData;
|
const lyricsResult: LyricsData = (await genius.search(query).catch(() => null)) as LyricsData;
|
||||||
|
|
||||||
if (!lyricsResult) {
|
if (!lyricsResult) {
|
||||||
return this.getAutocompleteChoicesFallback(query, logger);
|
return this.getAutocompleteChoicesFallback(query, logger, translator);
|
||||||
} else {
|
} else {
|
||||||
return this.getAutocompleteChoicesFromLyricsResult(lyricsResult);
|
return this.getAutocompleteChoicesFromLyricsResult(lyricsResult, translator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getAutocompleteChoicesFallback(
|
private async getAutocompleteChoicesFallback(
|
||||||
query: string,
|
query: string,
|
||||||
logger: Logger
|
logger: Logger,
|
||||||
|
translator: TFunction
|
||||||
): Promise<ApplicationCommandOptionChoiceData<string>[]> {
|
): Promise<ApplicationCommandOptionChoiceData<string>[]> {
|
||||||
logger.debug(`No Genius lyrics found for query '${query}', using player.search() as fallback.`);
|
logger.debug(`No Genius lyrics found for query '${query}', using player.search() as fallback.`);
|
||||||
|
|
||||||
@@ -66,24 +70,28 @@ class LyricsAutocomplete extends BaseAutocompleteInteraction {
|
|||||||
const searchResults: SearchResult = await player.search(query);
|
const searchResults: SearchResult = await player.search(query);
|
||||||
|
|
||||||
return searchResults.tracks.slice(0, 1).map((track) => ({
|
return searchResults.tracks.slice(0, 1).map((track) => ({
|
||||||
name: getTrackName(track),
|
name: getTrackName(track, translator),
|
||||||
value: track.title.slice(0, 100)
|
value: track.title.slice(0, 100)
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private getAutocompleteChoicesFromLyricsResult(
|
private getAutocompleteChoicesFromLyricsResult(
|
||||||
lyricsResult: LyricsData
|
lyricsResult: LyricsData,
|
||||||
|
translator: TFunction
|
||||||
): ApplicationCommandOptionChoiceData<string>[] {
|
): ApplicationCommandOptionChoiceData<string>[] {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
name: this.getLyricsResultName(lyricsResult),
|
name: this.getLyricsResultName(lyricsResult, translator),
|
||||||
value: lyricsResult.title.slice(0, 100)
|
value: lyricsResult.title.slice(0, 100)
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private getLyricsResultName(lyricsResult: LyricsData): string {
|
private getLyricsResultName(lyricsResult: LyricsData, translator: TFunction): string {
|
||||||
return `${lyricsResult.title} [Artist: ${lyricsResult.artist.name}]`.slice(0, 100);
|
return translator('commands.lyrics.autocompleteSearchResult', {
|
||||||
|
title: lyricsResult.title,
|
||||||
|
artist: lyricsResult.artist.name
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateRecentQuery(
|
private updateRecentQuery(
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import { ApplicationCommandOptionChoiceData } from 'discord.js';
|
|||||||
import { BaseAutocompleteInteraction } from '../../classes/interactions';
|
import { BaseAutocompleteInteraction } from '../../classes/interactions';
|
||||||
import { getTrackName, isQueryTooShort, shouldUseLastQuery } from '../../common/autocompleteUtils';
|
import { getTrackName, isQueryTooShort, shouldUseLastQuery } from '../../common/autocompleteUtils';
|
||||||
import { BaseAutocompleteParams, BaseAutocompleteReturnType, RecentQuery } from '../../types/interactionTypes';
|
import { BaseAutocompleteParams, BaseAutocompleteReturnType, RecentQuery } from '../../types/interactionTypes';
|
||||||
|
import { TFunction } from 'i18next';
|
||||||
|
import { useUserTranslator } from '../../common/localeUtil';
|
||||||
|
|
||||||
class PlayAutocomplete extends BaseAutocompleteInteraction {
|
class PlayAutocomplete extends BaseAutocompleteInteraction {
|
||||||
private recentQueries = new Map<string, RecentQuery>();
|
private recentQueries = new Map<string, RecentQuery>();
|
||||||
@@ -14,6 +16,7 @@ class PlayAutocomplete extends BaseAutocompleteInteraction {
|
|||||||
async execute(params: BaseAutocompleteParams): BaseAutocompleteReturnType {
|
async execute(params: BaseAutocompleteParams): BaseAutocompleteReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useUserTranslator(interaction);
|
||||||
|
|
||||||
const query: string = interaction.options.getString('query', true);
|
const query: string = interaction.options.getString('query', true);
|
||||||
|
|
||||||
@@ -29,8 +32,10 @@ class PlayAutocomplete extends BaseAutocompleteInteraction {
|
|||||||
return interaction.respond([]);
|
return interaction.respond([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const autocompleteChoices: ApplicationCommandOptionChoiceData<string>[] =
|
const autocompleteChoices: ApplicationCommandOptionChoiceData<string>[] = await this.getAutocompleteChoices(
|
||||||
await this.getAutocompleteChoices(query);
|
query,
|
||||||
|
translator
|
||||||
|
);
|
||||||
|
|
||||||
if (!autocompleteChoices || autocompleteChoices.length === 0) {
|
if (!autocompleteChoices || autocompleteChoices.length === 0) {
|
||||||
logger.debug(`Responding with empty results for query '${query}'`);
|
logger.debug(`Responding with empty results for query '${query}'`);
|
||||||
@@ -43,11 +48,14 @@ class PlayAutocomplete extends BaseAutocompleteInteraction {
|
|||||||
return interaction.respond(autocompleteChoices);
|
return interaction.respond(autocompleteChoices);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getAutocompleteChoices(query: string): Promise<ApplicationCommandOptionChoiceData<string>[]> {
|
private async getAutocompleteChoices(
|
||||||
|
query: string,
|
||||||
|
translator: TFunction
|
||||||
|
): Promise<ApplicationCommandOptionChoiceData<string>[]> {
|
||||||
const player: Player = useMainPlayer()!;
|
const player: Player = useMainPlayer()!;
|
||||||
const searchResults: SearchResult = await player.search(query);
|
const searchResults: SearchResult = await player.search(query);
|
||||||
return searchResults.tracks.slice(0, 5).map((track) => ({
|
return searchResults.tracks.slice(0, 5).map((track) => ({
|
||||||
name: getTrackName(track),
|
name: getTrackName(track, translator),
|
||||||
value: track.url
|
value: track.url
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,21 +6,24 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
|||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
|
import { localizeCommand } from '../../../common/localeUtil';
|
||||||
|
|
||||||
class LyricsCommand extends BaseSlashCommandInteraction {
|
class LyricsCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
const data = new SlashCommandBuilder()
|
const data = localizeCommand(
|
||||||
.setName('lyrics')
|
new SlashCommandBuilder()
|
||||||
.setDescription('Search Genius lyrics for current or specified track.')
|
.setName('lyrics')
|
||||||
.addStringOption((option) =>
|
// .setDescription('Search Genius lyrics for current or specified track.')
|
||||||
option
|
.addStringOption((option) =>
|
||||||
.setName('query')
|
option
|
||||||
.setDescription('Search query by text or URL.')
|
.setName('query')
|
||||||
.setRequired(false)
|
// .setDescription('Search query by text or URL.')
|
||||||
.setMinLength(2)
|
.setRequired(false)
|
||||||
.setMaxLength(500)
|
.setMinLength(2)
|
||||||
.setAutocomplete(true)
|
.setMaxLength(500)
|
||||||
);
|
.setAutocomplete(true)
|
||||||
|
)
|
||||||
|
);
|
||||||
super(data);
|
super(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -9,6 +9,6 @@
|
|||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"forceConsistentCasingInFileNames": true
|
"forceConsistentCasingInFileNames": true
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts"],
|
"include": ["src/**/*.ts", "locales/**/*.ts"],
|
||||||
"exclude": ["node_modules"]
|
"exclude": ["node_modules"]
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user