merge dev
to main
(#133)
All checks were successful
ci/woodpecker/push/publish Pipeline was successful
All checks were successful
ci/woodpecker/push/publish Pipeline was successful
TODO: remove temporary dependencie @web-scrobbler/metadata-filter Reviewed-on: #133 Co-authored-by: Mylloon <kennel.anri@tutanota.com> Co-committed-by: Mylloon <kennel.anri@tutanota.com>
This commit is contained in:
parent
da300386ce
commit
08edce2bb1
9 changed files with 826 additions and 456 deletions
1214
package-lock.json
generated
1214
package-lock.json
generated
File diff suppressed because it is too large
Load diff
14
package.json
14
package.json
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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";
|
||||
|
@ -39,6 +38,7 @@ export default async () => {
|
|||
};
|
||||
|
||||
const player = Player.singleton(client, {
|
||||
skipFFmpeg: true,
|
||||
ytdlOptions: {
|
||||
filter: "audioonly",
|
||||
quality: "highestaudio",
|
||||
|
@ -46,8 +46,6 @@ export default async () => {
|
|||
});
|
||||
await player.extractors.loadDefault();
|
||||
|
||||
player.lyrics = lyricsExtractor();
|
||||
|
||||
console.log("Translations progression :");
|
||||
client.locales = await loadLocales(client.config.default_lang);
|
||||
|
||||
|
|
Loading…
Reference in a new issue