From 8d2557fac8e57f17030a004eff1c4dd0cfb1c4f3 Mon Sep 17 00:00:00 2001 From: "Jonny_Bro (Nikita)" Date: Thu, 1 Aug 2024 23:23:23 +0500 Subject: [PATCH] fix url shorturl and music (please) --- base/Client.js | 7 +++++- commands/Fun/lmgtfy.js | 10 ++++----- commands/General/shorturl.js | 12 ++++++----- commands/Music/play.c.js | 2 -- commands/Music/play.js | 2 -- config.sample.js | 10 ++++++++- package.json | 4 ++-- pnpm-lock.yaml | 42 ++++++++++++++++-------------------- 8 files changed, 47 insertions(+), 42 deletions(-) diff --git a/base/Client.js b/base/Client.js index f9e0a4ac..e222bc33 100644 --- a/base/Client.js +++ b/base/Client.js @@ -45,7 +45,12 @@ class JaBaClient extends Client { async init() { this.player = new DiscordPlayer(this); - await this.player.extractors.register(YoutubeiExtractor); + await this.player.extractors.register(YoutubeiExtractor, { + authentication: this.config.youtubeCookie, + streamOptions: { + useClient: "ANDROID", + }, + }); await this.player.extractors.register(SpotifyExtractor, { clientId: this.config.spotify.clientId, diff --git a/commands/Fun/lmgtfy.js b/commands/Fun/lmgtfy.js index 872eb40a..e2b19273 100644 --- a/commands/Fun/lmgtfy.js +++ b/commands/Fun/lmgtfy.js @@ -55,17 +55,17 @@ class LMGTFY extends BaseCommand { url = `https://letmegooglethat.com/?q=${encodeURIComponent(query)}`; if (short) { - const res = await fetch("https://plsgo.ru/rest/v3/short-urls", { + const res = await fetch("https://i.jonnybro.ru/api/shorten", { method: "POST", headers: { - "Content-Type": "application/x-www-form-urlencoded", - "X-Api-Key": client.config.apiKeys.shlink, + "Content-Type": "application/json", + Authorization: client.config.apiKeys.zipline, }, - body: new URLSearchParams({ longUrl: url }), + body: JSON.stringify({ url: url }), }).then(res => res.json()); interaction.editReply({ - content: `<${res.shortUrl}>`, + content: `<${res.url}>`, }); } else { interaction.editReply({ diff --git a/commands/General/shorturl.js b/commands/General/shorturl.js index 091b3e1f..ea8e78c9 100644 --- a/commands/General/shorturl.js +++ b/commands/General/shorturl.js @@ -41,17 +41,19 @@ class Shorturl extends BaseCommand { await interaction.deferReply({ ephemeral: true }); const url = interaction.options.getString("url"); - const res = await fetch("https://plsgo.ru/rest/v3/short-urls", { + const res = await fetch("https://i.jonnybro.ru/api/shorten", { method: "POST", headers: { - "Content-Type": "application/x-www-form-urlencoded", - "X-Api-Key": client.config.apiKeys.shlink, + "Content-Type": "application/json", + Authorization: client.config.apiKeys.zipline, }, - body: new URLSearchParams({ longUrl: url }), + body: JSON.stringify({ url: url }), }).then(res => res.json()); + console.log(res); + interaction.editReply({ - content: `<${res.shortUrl}>`, + content: `<${res.url}>`, }); } } diff --git a/commands/Music/play.c.js b/commands/Music/play.c.js index 2813fcf0..29e2cb79 100644 --- a/commands/Music/play.c.js +++ b/commands/Music/play.c.js @@ -40,8 +40,6 @@ class PlayContext extends BaseCommand { }); if (!searchResult.hasTracks()) { - console.log(searchResult); - return interaction.error("music/play:NO_RESULT", { query }, { edit: true }); } else { await client.player.play(voice, searchResult, { diff --git a/commands/Music/play.js b/commands/Music/play.js index f927d3e0..cf003681 100644 --- a/commands/Music/play.js +++ b/commands/Music/play.js @@ -105,8 +105,6 @@ class Play extends BaseCommand { })) .forEach(t => tracks.push({ name: t.name, value: t.value })); - console.log(tracks); - return interaction.respond(tracks); } } diff --git a/config.sample.js b/config.sample.js index 54d5fd4d..92c0b008 100644 --- a/config.sample.js +++ b/config.sample.js @@ -13,6 +13,14 @@ module.exports = { clientId: "XXXXXXXXXXXXXXXXXXXXXXXXXXXX", clientSecret: "XXXXXXXXXXXXXXXXXXXXXXXXXXXX", }, + /* YouTube Cookie */ + youtubeCookie: { + access_token: "XXXXXXXXXXXXXXXXXXXXXXXXXXXX", + refresh_token: "XXXXXXXXXXXXXXXXXXXXXXXXXXXX", + scope: "XXXXXXXXXXXXXXXXXXXXXXXXXXXX", + token_type: "XXXXXXXXXXXXXXXXXXXXXXXXXXXX", + expiry_date: "XXXXXXXXXXXXXXXXXXXXXXXXXXXX", + }, /* Support server */ support: { id: "123456789098765432", // The ID of the support server @@ -41,6 +49,6 @@ module.exports = { }, /* Add your own API keys here */ apiKeys: { - shlink: "12345678-1234-1234-1234-123456789098", /* Shlink.io REST API key */ + shlink: "12345678-1234-1234-1234-123456789098" /* Shlink.io REST API key */, }, }; diff --git a/package.json b/package.json index 94b245eb..b708de05 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,8 @@ "cron": "^2.4.4", "discord-api-types": "^0.37.92", "discord-giveaways": "^6.0.1", - "discord-player": "^6.7.0", - "discord-player-youtubei": "^1.2.0", + "discord-player": "^6.7.1", + "discord-player-youtubei": "^1.2.4", "discord.js": "^14.15.3", "gamedig": "^4.1.0", "i18next": "^21.10.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0bd9607f..0d546b11 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -36,11 +36,11 @@ importers: specifier: ^6.0.1 version: 6.0.1(discord.js@14.15.3) discord-player: - specifier: ^6.7.0 - version: 6.7.0(@discord-player/extractor@4.5.0)(@discordjs/opus@0.9.0) + specifier: ^6.7.1 + version: 6.7.1(@discord-player/extractor@4.5.0)(@discordjs/opus@0.9.0) discord-player-youtubei: - specifier: ^1.2.0 - version: 1.2.0 + specifier: ^1.2.4 + version: 1.2.4 discord.js: specifier: ^14.15.3 version: 14.15.3 @@ -474,12 +474,12 @@ packages: peerDependencies: discord.js: '>=14.0.0' - discord-player-youtubei@1.2.0: - resolution: {integrity: sha512-zI05CH8qVTNi1NcaUD2XKYwfw4Ye+6Ws9/sGZqoQxTI2LN8rVd0fBs/cX4GbRFevTWVqzZy4LvriQRe8OYJxFg==} + discord-player-youtubei@1.2.4: + resolution: {integrity: sha512-kx6cXUz5tMUI+2E6ntRUCckCYYgFNWF872l6N3s4W29Jgmm+kkbefytogfsTM06ePncd1MQp6hBHoufr6b1TVQ==} hasBin: true - discord-player@6.7.0: - resolution: {integrity: sha512-ioSDZo3IreTi9B5ZRKca0Vh2FPbHjM25D4RoXTwhf6ULaGJEMMpi+GAyDPtzFGHbvIO0Fs/pnNcKtehICsODzg==} + discord-player@6.7.1: + resolution: {integrity: sha512-ScQmChpZebpVzs+RMsSkCXSORUIXUR3aHsEssGZSLKrbWnregt3jVc39emftTt6EfarZ2TvTK262mXeAYPzpcQ==} peerDependencies: '@discord-player/extractor': ^4.5.0 @@ -706,9 +706,6 @@ packages: ip@2.0.0: resolution: {integrity: sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==} - ip@2.0.1: - resolution: {integrity: sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==} - is-buffer@1.1.6: resolution: {integrity: sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==} @@ -740,8 +737,8 @@ packages: isomorphic-unfetch@4.0.2: resolution: {integrity: sha512-1Yd+CF/7al18/N2BDbsLBcp6RO3tucSW+jcLq24dqdX5MNbCNTw1z4BsGsp4zNmjr/Izm2cs/cEqZPp4kvWSCA==} - jintr@2.0.0: - resolution: {integrity: sha512-RiVlevxttZ4eHEYB2dXKXDXluzHfRuw0DJQGsYuKCc5IvZj5/GbOakeqVX+Bar/G9kTty9xDJREcxukurkmYLA==} + jintr@2.1.1: + resolution: {integrity: sha512-89cwX4ouogeDGOBsEVsVYsnWWvWjchmwXBB4kiBhmjOKw19FiOKhNhMhpxhTlK2ctl7DS+d/ethfmuBpzoNNgA==} js-yaml@4.1.0: resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==} @@ -1285,8 +1282,8 @@ packages: youtube-sr@4.3.11: resolution: {integrity: sha512-3oHiS2x7PpMiDRW7Cq8nz1bkAIBOJHoOwkPl/oncM/+A9/3xxMDgMLGW2dsBEP1DHFyRXYTVABgfbdwHF8sXXQ==} - youtubei.js@10.2.0: - resolution: {integrity: sha512-JLKW9AHQ1qrTwBbre1aDkH8UJFmNcc4+kOSaVou5jSY7AzfFPFJK0yvX6afnLst0UVC9wfXHrLiNx93sutVErA==} + youtubei.js@10.3.0: + resolution: {integrity: sha512-tLmeJCECK2xF2hZZtF2nEqirdKVNLFSDpa0LhTaXY3tngtL7doQXyy7M2CLueramDTlmCnFaW+rctHirTPFaRQ==} ytdl-core@4.11.5: resolution: {integrity: sha512-27LwsW4n4nyNviRCO1hmr8Wr5J1wLLMawHCQvH8Fk0hiRqrxuIu028WzbJetiYH28K8XDbeinYW4/wcHQD1EXA==} @@ -1707,12 +1704,12 @@ snapshots: discord.js: 14.15.3 serialize-javascript: 6.0.1 - discord-player-youtubei@1.2.0: + discord-player-youtubei@1.2.4: dependencies: undici: 6.19.2 - youtubei.js: 10.2.0 + youtubei.js: 10.3.0 - discord-player@6.7.0(@discord-player/extractor@4.5.0)(@discordjs/opus@0.9.0): + discord-player@6.7.1(@discord-player/extractor@4.5.0)(@discordjs/opus@0.9.0): dependencies: '@discord-player/equalizer': 0.2.3 '@discord-player/extractor': 4.5.0 @@ -1720,7 +1717,6 @@ snapshots: '@discord-player/utils': 0.2.2 '@web-scrobbler/metadata-filter': 3.1.0 discord-voip: 0.1.3(@discordjs/opus@0.9.0) - ip: 2.0.1 libsodium-wrappers: 0.7.13 transitivePeerDependencies: - '@discordjs/opus' @@ -2044,8 +2040,6 @@ snapshots: ip@2.0.0: {} - ip@2.0.1: {} - is-buffer@1.1.6: {} is-extglob@2.1.1: {} @@ -2069,7 +2063,7 @@ snapshots: node-fetch: 3.3.2 unfetch: 5.0.0 - jintr@2.0.0: + jintr@2.1.1: dependencies: acorn: 8.11.2 @@ -2550,9 +2544,9 @@ snapshots: youtube-sr@4.3.11: {} - youtubei.js@10.2.0: + youtubei.js@10.3.0: dependencies: - jintr: 2.0.0 + jintr: 2.1.1 tslib: 2.6.2 undici: 5.27.2