add constants
All checks were successful
PR Check / lint-and-format (pull_request) Successful in 23s
All checks were successful
PR Check / lint-and-format (pull_request) Successful in 23s
This commit is contained in:
parent
f772f71b05
commit
75ec77a880
3 changed files with 21 additions and 6 deletions
|
@ -9,6 +9,10 @@ import {
|
|||
import { getLocale, getLocalizations } from "../../utils/locales";
|
||||
import { Metadata } from "../../utils/metadata";
|
||||
import { getFilename } from "../../utils/misc";
|
||||
import {
|
||||
discord_limit_autocompletion_list_length,
|
||||
discord_limit_autocompletion_value_length,
|
||||
} from "../../utils/constants";
|
||||
|
||||
export default {
|
||||
scope: () => [],
|
||||
|
@ -192,8 +196,8 @@ export default {
|
|||
const player = useMainPlayer();
|
||||
const query = interaction.options.getString(loc_default!.get(`c_${filename}_opt1_name`)!, true);
|
||||
|
||||
const limit_value_discord = 100;
|
||||
const limit_element_discord = 25;
|
||||
const limit_value_discord = discord_limit_autocompletion_value_length;
|
||||
const limit_element_discord = discord_limit_autocompletion_list_length;
|
||||
|
||||
const query_discord = query.slice(0, limit_value_discord);
|
||||
|
||||
|
@ -238,8 +242,8 @@ export default {
|
|||
let author = t.author;
|
||||
let name = `${title} • ${author}`;
|
||||
|
||||
// Slice returned data if needed to not exceed the length limit (100)
|
||||
if (name.length > 100) {
|
||||
// Slice returned data if needed to not exceed the length limit
|
||||
if (name.length > limit_value_discord) {
|
||||
const newTitle = title.substring(0, 40);
|
||||
if (title.length != newTitle.length) {
|
||||
title = `${newTitle}...`;
|
||||
|
|
|
@ -3,6 +3,7 @@ import { GuildQueue, QueueRepeatMode } from "discord-player";
|
|||
import { Client } from "discord.js";
|
||||
import { getLocale } from "../locales";
|
||||
import { blank } from "../misc";
|
||||
import { discord_limit_embed_field } from "../constants";
|
||||
|
||||
export const embedListQueue = (
|
||||
client: Client,
|
||||
|
@ -17,8 +18,7 @@ export const embedListQueue = (
|
|||
// Add the current song at the top of the list
|
||||
tracks.unshift(queue.history.currentTrack!);
|
||||
|
||||
// Limit of discord is 25
|
||||
const limit_fields = 25;
|
||||
const limit_fields = discord_limit_embed_field;
|
||||
|
||||
const pageMax = Math.ceil(tracks.length / limit_fields);
|
||||
|
||||
|
|
11
src/utils/constants.ts
Normal file
11
src/utils/constants.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
/** Max message length */
|
||||
export const discord_limit_message = 2000;
|
||||
|
||||
/** Max embed field an embed can have */
|
||||
export const discord_limit_embed_field = 25;
|
||||
|
||||
/** Max element the autocompletion of slash commands can have */
|
||||
export const discord_limit_autocompletion_list_length = 25;
|
||||
|
||||
/** Max length of an element in autocompletion of slash commands */
|
||||
export const discord_limit_autocompletion_value_length = 100;
|
Loading…
Reference in a new issue