chore: merge branch dev to main #200

Merged
Anri merged 19 commits from dev into main 2024-11-02 17:36:38 +01:00
3 changed files with 21 additions and 6 deletions
Showing only changes of commit 75ec77a880 - Show all commits

View file

@ -9,6 +9,10 @@ import {
import { getLocale, getLocalizations } from "../../utils/locales"; import { getLocale, getLocalizations } from "../../utils/locales";
import { Metadata } from "../../utils/metadata"; import { Metadata } from "../../utils/metadata";
import { getFilename } from "../../utils/misc"; import { getFilename } from "../../utils/misc";
import {
discord_limit_autocompletion_list_length,
discord_limit_autocompletion_value_length,
} from "../../utils/constants";
export default { export default {
scope: () => [], scope: () => [],
@ -192,8 +196,8 @@ export default {
const player = useMainPlayer(); const player = useMainPlayer();
const query = interaction.options.getString(loc_default!.get(`c_${filename}_opt1_name`)!, true); const query = interaction.options.getString(loc_default!.get(`c_${filename}_opt1_name`)!, true);
const limit_value_discord = 100; const limit_value_discord = discord_limit_autocompletion_value_length;
const limit_element_discord = 25; const limit_element_discord = discord_limit_autocompletion_list_length;
const query_discord = query.slice(0, limit_value_discord); const query_discord = query.slice(0, limit_value_discord);
@ -238,8 +242,8 @@ export default {
let author = t.author; let author = t.author;
let name = `${title}${author}`; let name = `${title}${author}`;
// Slice returned data if needed to not exceed the length limit (100) // Slice returned data if needed to not exceed the length limit
if (name.length > 100) { if (name.length > limit_value_discord) {
const newTitle = title.substring(0, 40); const newTitle = title.substring(0, 40);
if (title.length != newTitle.length) { if (title.length != newTitle.length) {
title = `${newTitle}...`; title = `${newTitle}...`;

View file

@ -3,6 +3,7 @@ import { GuildQueue, QueueRepeatMode } from "discord-player";
import { Client } from "discord.js"; import { Client } from "discord.js";
import { getLocale } from "../locales"; import { getLocale } from "../locales";
import { blank } from "../misc"; import { blank } from "../misc";
import { discord_limit_embed_field } from "../constants";
export const embedListQueue = ( export const embedListQueue = (
client: Client, client: Client,
@ -17,8 +18,7 @@ export const embedListQueue = (
// Add the current song at the top of the list // Add the current song at the top of the list
tracks.unshift(queue.history.currentTrack!); tracks.unshift(queue.history.currentTrack!);
// Limit of discord is 25 const limit_fields = discord_limit_embed_field;
const limit_fields = 25;
const pageMax = Math.ceil(tracks.length / limit_fields); const pageMax = Math.ceil(tracks.length / limit_fields);

11
src/utils/constants.ts Normal file
View 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;