merge dev to main #133

Merged
Anri merged 3 commits from dev into main 2024-06-01 21:51:38 +02:00
5 changed files with 825 additions and 456 deletions
Showing only changes of commit 0c39c764b1 - Show all commits

1214
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -18,21 +18,21 @@
"license": "AGPL-3.0-only",
"dependencies": {
"@discord-player/extractor": "^4.4.7",
"@discordjs/rest": "^2.2.0",
"@discordjs/rest": "^2.3.0",
"@distube/ytdl-core": "^4.13.3",
"@types/sqlite3": "^3.1.11",
"@types/uuid": "^9.0.8",
"discord-player": "^6.6.8",
"discord.js": "^14.14.1",
"genius-lyrics": "^4.4.6",
"@web-scrobbler/metadata-filter": "^3.1.0",
"discord-player": "^6.6.9",
"discord.js": "^14.15.2",
"mediaplex": "^0.0.9",
"sqlite3": "^5.1.7",
"typescript": "^5.4.3",
"typescript": "^5.4.5",
"uuid": "^9.0.1"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "~7.4.0",
"@typescript-eslint/parser": "~7.4.0",
"@typescript-eslint/eslint-plugin": "~7.11.0",
"@typescript-eslint/parser": "~7.11.0",
"dotenv": "~16.4.5",
"prettier-eslint": "~16.3.0",
"ts-node-dev": "~2.0.0"

View file

@ -84,32 +84,35 @@ export default {
}
try {
data = await player.lyrics.search(request);
data = await player.lyrics.search({ q: request });
} catch {
return await interaction.followUp(`❌ | ${loc.get("c_lyrics2")} \`${request}\``);
}
} else {
const queue = useQueue(interaction.guildId ?? "");
if (queue) {
const title = queue.history.currentTrack?.title;
if (title) {
const track = queue.history.currentTrack;
if (track) {
try {
data = await player.lyrics.search(title + " " + queue.history.currentTrack?.author);
data = await player.lyrics.search({
q: track.cleanTitle + " " + queue.history.currentTrack?.author,
});
} catch {
return await interaction.followUp(`❌ | ${loc.get("c_lyrics2")} \`${title}\``);
return await interaction.followUp(`❌ | ${loc.get("c_lyrics2")} \`${track.title}\``);
}
}
}
}
if (data) {
if (data && data.length > 0) {
const title = data[0];
const limit_desc = 4096;
const nb_embed = Math.ceil(data.lyrics.length / limit_desc);
const nb_embed = Math.ceil(title.plainLyrics.length / limit_desc);
// TODO: If lyrics < 6000, only send one message with multiples embed
for (let i = 0, j = 0; i < nb_embed; i++, j += limit_desc) {
// TODO: Better cut in lyrics
const lyrics = data.lyrics.slice(j, j + limit_desc);
const lyrics = title.plainLyrics.slice(j, j + limit_desc);
let embed;
switch (i) {
@ -117,23 +120,16 @@ export default {
// First embed
embed = new EmbedBuilder();
embed
.setTitle(data.title)
.setURL(data.url)
.setAuthor({
name: data?.artist.name,
iconURL: data?.artist.image,
url: data?.artist.url,
})
.setDescription(lyrics)
.setThumbnail(data.thumbnail);
.setTitle(title.trackName)
.setAuthor({ name: title.artistName })
.setDescription(lyrics);
break;
}
case nb_embed - 1: {
// Footer of last embed in case of multiple embed
embed = new EmbedBuilder().setDescription(lyrics).setFooter({
text: `${data?.artist.name} · ${data.title}`,
iconURL: data?.artist.image,
text: `${title.artistName} · ${title.trackName}`,
});
break;
}

View file

@ -1,16 +0,0 @@
import { LyricsData } from "@discord-player/extractor";
import { Client } from "genius-lyrics";
type LyricsClient = {
search: (query: string) => Promise<LyricsData | null>;
client: Client;
};
export {};
declare module "discord-player" {
export interface Player {
/** Lyrics client */
lyrics: LyricsClient;
}
}

View file

@ -1,4 +1,3 @@
import { lyricsExtractor } from "@discord-player/extractor";
import { Player } from "discord-player";
import { Client, Collection, GatewayIntentBits } from "discord.js";
import { readFileSync } from "fs";
@ -46,8 +45,6 @@ export default async () => {
});
await player.extractors.loadDefault();
player.lyrics = lyricsExtractor();
console.log("Translations progression :");
client.locales = await loadLocales(client.config.default_lang);