diff --git a/commands/AI/chat.js b/commands/AI/chat.js deleted file mode 100644 index 25b05653..00000000 --- a/commands/AI/chat.js +++ /dev/null @@ -1,108 +0,0 @@ -const { SlashCommandBuilder, range } = require("discord.js"); -const BaseCommand = require("../../base/BaseCommand"); - -class Chat extends BaseCommand { - /** - * - * @param {import("../base/JaBa")} client - */ - constructor(client) { - super({ - command: new SlashCommandBuilder() - .setName("chat") - .setDescription(client.translate("ai/chat:DESCRIPTION")) - .setDescriptionLocalizations({ "uk": client.translate("ai/chat:DESCRIPTION", null, "uk-UA") }) - .setDMPermission(true) - .addStringOption(option => option.setName("prompt") - .setDescription(client.translate("ai/chat:PROMPT")) - .setDescriptionLocalizations({ "uk": client.translate("ai/chat:PROMPT", null, "uk-UA") }) - .setMaxLength(300) - .setRequired(true)), - aliases: [], - dirname: __dirname, - ownerOnly: false, - }); - } - /** - * - * @param {import("../../base/JaBa")} client - */ - async onLoad() { - //... - } - /** - * - * @param {import("../../base/JaBa")} client - * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data - */ - async execute(client, interaction) { - await interaction.deferReply(); - - const prompt = interaction.options.getString("prompt"); - - try { - const completion = await client.openai.createChatCompletion({ - model: "gpt-3.5-turbo", - messages: [{ role: "user", content: prompt }], - user: `user${interaction.user.id}`, - }), - response = completion.data.choices[0].message.content; - - await interaction.editReply({ - content: interaction.translate("ai/chat:THANKS"), - }); - - if (response.length > 1900) { - if (response.includes("```")) { - const parts = response.split("```"); - - for (const i in parts) { - if (i % 2 === 0) { - await interaction.followUp({ - content: parts[i], - }); - } else { - const codeBlock = parts[i].split("\n"); - let formattedCodeBlock = ""; - - for (let line in codeBlock) { - while (line.length > 50) { - formattedCodeBlock += line.slice(0, 50) + "\n"; - line = line.slice(50, line.length); - } - - formattedCodeBlock += line + "\n"; - } - - if (formattedCodeBlock.length > 1900 + 100) { - const codeblockChunks = []; - for (const i in range({ start: 0, end: formattedCodeBlock.length, step: 1900 })) { - codeblockChunks.push(formattedCodeBlock.slice(i, i + 1900)); - } - - for (const i in codeblockChunks) { - await interaction.followUp({ content: `\`\`\`${i}\`\`\`` }); - } - - } else await interaction.followUp({ content: `\`\`\`${formattedCodeBlock}\`\`\`` }); - } - } - } else { - const responseChunks = []; - for (const i in range({ start: 0, end: response.length, step: 1900 })) { - responseChunks.push(response.slice(i, i + 1900)); - } - - for (const i in responseChunks) { - await interaction.followUp({ content: i }); - } - } - } else await interaction.followUp({ content: response }); - } catch (e) { - console.log(e); - } - } -} - -module.exports = Chat; \ No newline at end of file diff --git a/languages/ru-RU/ai/chat.json b/languages/ru-RU/ai/chat.json deleted file mode 100644 index 0045c52d..00000000 --- a/languages/ru-RU/ai/chat.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "DESCRIPTION": "Спросить у ChatGPT", - "USAGE": "[query]", - "EXAMPLES": "chat query:Привет! Как тебя зовут?", - "PROMPT": "Запрос", - "THANKS": "> Спасибо за ожидание!" -} \ No newline at end of file diff --git a/languages/uk-UA/ai/chat.json b/languages/uk-UA/ai/chat.json deleted file mode 100644 index 296a4337..00000000 --- a/languages/uk-UA/ai/chat.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "DESCRIPTION": "Запитати у ChatGPT", - "USAGE": "[query]", - "EXAMPLES": "chat query:Вітання! Як тебе звати?", - "PROMPT": "Запит", - "THANKS": "> Спасибі за очікування!" -} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index c6a6d966..02cbc7c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "4.2.1", "license": "ISC", "dependencies": { + "@discord-player/extractor": "^4.2.1", "@discordjs/opus": "^0.9.0", "@discordjs/rest": "^1.7.0", "@discordjs/voice": "^0.16.0", @@ -19,7 +20,7 @@ "cron": "^2.1.0", "discord-api-types": "^0.37.37", "discord-giveaways": "^6.0.1", - "discord-player": "^6.1.1", + "discord-player": "^6.2.1", "discord.js": "^14.9.0", "ejs": "^3.1.3", "express": "^4.17.1", @@ -32,7 +33,6 @@ "moment": "^2.26.0", "mongoose": "^5.13.15", "ms": "^2.1.3", - "openai": "^3.2.1", "play-dl": "^1.9.6" }, "devDependencies": { @@ -56,10 +56,9 @@ "integrity": "sha512-PPjX8TBwzM85YKEdpYYL8aGbdSLIk9RK1h/uU5jeyiF6Uu5CiLH/XctDfcGW8cSgoaU4J0R6a8svCs9yhzHXSw==" }, "node_modules/@discord-player/extractor": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/@discord-player/extractor/-/extractor-4.1.2.tgz", - "integrity": "sha512-sG0KG3tC9/t2hnzXP7amaURbZ+7KfIXma+sH2UyAJKqX3LgYnFvUxm1deL29lPrqf8wjR9XEEOt5TOxpsyP74Q==", - "peer": true, + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/@discord-player/extractor/-/extractor-4.2.1.tgz", + "integrity": "sha512-z1kqIyAteD5H22KE/VTuujdXq4D+lV9owv6SmpmoS1R/ss+skTCOe/jReHlQC2HBNo5flShgEzMDqtp/HxI7cA==", "dependencies": { "file-type": "^16.5.4", "genius-lyrics": "^4.4.2", @@ -68,10 +67,6 @@ "soundcloud-scraper": "^5.0.3", "spotify-url-info": "^3.2.3", "youtube-sr": "^4.3.4" - }, - "peerDependencies": { - "play-dl": "1.x", - "ytdl-core": "4.x" } }, "node_modules/@discord-player/utils": { @@ -811,19 +806,6 @@ "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==" }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" - }, - "node_modules/axios": { - "version": "0.26.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", - "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", - "dependencies": { - "follow-redirects": "^1.14.8" - } - }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -1173,17 +1155,6 @@ "color-support": "bin.js" } }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dependencies": { - "delayed-stream": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/commander": { "version": "2.8.1", "resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz", @@ -1378,14 +1349,6 @@ "node": ">=10" } }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/delegates": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", @@ -1445,9 +1408,9 @@ } }, "node_modules/discord-player": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/discord-player/-/discord-player-6.1.1.tgz", - "integrity": "sha512-gIN0V+IBT1xcLmzFqfbq9pM8B7crZvbfTwdey1R99P3DdAfaRbg+F1hw9l5ftK2X492O3uAjev+ZBh1CcFU3pQ==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/discord-player/-/discord-player-6.2.1.tgz", + "integrity": "sha512-+uFetp3GPeOH5GARJdnLuT0LeiCV9dLLNZ1wnEpMltxIsxqOMIMUFKr+C1Pgajss3mhyeB7lGjpnZvNAi3Ti+A==", "dependencies": { "@discord-player/equalizer": "*", "@discord-player/utils": "*", @@ -1899,7 +1862,6 @@ "version": "16.5.4", "resolved": "https://registry.npmjs.org/file-type/-/file-type-16.5.4.tgz", "integrity": "sha512-/yFHK0aGjFEgDJjEKP0pWCplsPFPhwyfwevf/pVxiN0tmE4L9LmwWxWukdJSHdoCli4VgQLehjJtwQBnqmsKcw==", - "peer": true, "dependencies": { "readable-web-to-node-stream": "^3.0.0", "strtok3": "^6.2.4", @@ -2004,38 +1966,6 @@ "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", "dev": true }, - "node_modules/follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], - "engines": { - "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } - } - }, - "node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/form-data-encoder": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-2.1.4.tgz", @@ -2163,7 +2093,6 @@ "version": "4.4.3", "resolved": "https://registry.npmjs.org/genius-lyrics/-/genius-lyrics-4.4.3.tgz", "integrity": "sha512-06L8GUg49FrUYEmSQvrSH74RH5S+qyerHwBpvk8vZLwWgpEw4mIWZDob5IpXT1ryhqazM9K6CXGNucKYPO8kng==", - "peer": true, "dependencies": { "cheerio": "^1.0.0-rc.9", "undici": "^5.8.2" @@ -2313,7 +2242,6 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", - "peer": true, "bin": { "he": "bin/he" } @@ -2321,8 +2249,7 @@ "node_modules/himalaya": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/himalaya/-/himalaya-1.1.0.tgz", - "integrity": "sha512-LLase1dHCRMel68/HZTFft0N0wti0epHr3nNY7ynpLbyZpmrKMQ8YIpiOV77TM97cNpC8Wb2n6f66IRggwdWPw==", - "peer": true + "integrity": "sha512-LLase1dHCRMel68/HZTFft0N0wti0epHr3nNY7ynpLbyZpmrKMQ8YIpiOV77TM97cNpC8Wb2n6f66IRggwdWPw==" }, "node_modules/htmlparser2": { "version": "8.0.2", @@ -2718,7 +2645,6 @@ "version": "0.8.6", "resolved": "https://registry.npmjs.org/m3u8stream/-/m3u8stream-0.8.6.tgz", "integrity": "sha512-LZj8kIVf9KCphiHmH7sbFQTVe4tOemb202fWwvJwR9W5ENW/1hxJN6ksAWGhQgSBSa3jyWhnjKU1Fw1GaOdbyA==", - "peer": true, "dependencies": { "miniget": "^4.2.2", "sax": "^1.2.4" @@ -2843,7 +2769,6 @@ "version": "4.2.2", "resolved": "https://registry.npmjs.org/miniget/-/miniget-4.2.2.tgz", "integrity": "sha512-a7voNL1N5lDMxvTMExOkg+Fq89jM2vY8pAi9ZEWzZtfNmdfP6RXkvUtFnCAXoCv2T9k1v/fUJVaAEuepGcvLYA==", - "peer": true, "engines": { "node": ">=12" } @@ -3105,7 +3030,6 @@ "version": "6.1.5", "resolved": "https://registry.npmjs.org/node-html-parser/-/node-html-parser-6.1.5.tgz", "integrity": "sha512-fAaM511feX++/Chnhe475a0NHD8M7AxDInsqQpz6x63GRF7xYNdS8Vo5dKsIVPgsOvG7eioRRTZQnWBrhDHBSg==", - "peer": true, "dependencies": { "css-select": "^5.1.0", "he": "1.2.0" @@ -3201,15 +3125,6 @@ "wrappy": "1" } }, - "node_modules/openai": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/openai/-/openai-3.2.1.tgz", - "integrity": "sha512-762C9BNlJPbjjlWZi4WYK9iM2tAVAv0uUp1UmI34vb0CN5T2mjB/qM6RYBmNKMh/dN9fC+bxqPwWJZUTWW052A==", - "dependencies": { - "axios": "^0.26.0", - "form-data": "^4.0.0" - } - }, "node_modules/optional-require": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/optional-require/-/optional-require-1.0.3.tgz", @@ -3351,7 +3266,6 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/peek-readable/-/peek-readable-4.1.0.tgz", "integrity": "sha512-ZI3LnwUv5nOGbQzD9c2iDG6toheuXSZP5esSHBjopsXH4dg19soufvpUGA3uohi5anFtGb2lhAVdHzH6R/Evvg==", - "peer": true, "engines": { "node": ">=8" }, @@ -3633,7 +3547,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/reverbnation-scraper/-/reverbnation-scraper-2.0.0.tgz", "integrity": "sha512-t1Mew5QC9QEVEry5DXyagvci2O+TgXTGoMHbNoW5NRz6LTOzK/DLHUpnrQwloX8CVX5z1a802vwHM3YgUVOvKg==", - "peer": true, "dependencies": { "node-fetch": "^2.6.0" } @@ -3902,7 +3815,6 @@ "version": "5.0.3", "resolved": "https://registry.npmjs.org/soundcloud-scraper/-/soundcloud-scraper-5.0.3.tgz", "integrity": "sha512-AmS9KmK7mMaPVzHzBk40rANpAttZila3+iAet6EA47EeiTBUzVwjq4B+1LCOLtgPmzDSGk0qn+LZOEd5UhnZTQ==", - "peer": true, "dependencies": { "cheerio": "^1.0.0-rc.10", "m3u8stream": "^0.8.4", @@ -3922,7 +3834,6 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/spotify-uri/-/spotify-uri-3.0.3.tgz", "integrity": "sha512-mMstJ4dAMki6GbUjg94kp/h9ZH+7T7+ro/KUC00WVh+WKoLgMRrTKLkWMIwCZNO53Xa8DRHQw/6jwYtRZrVI3g==", - "peer": true, "engines": { "node": ">= 12" } @@ -3931,7 +3842,6 @@ "version": "3.2.3", "resolved": "https://registry.npmjs.org/spotify-url-info/-/spotify-url-info-3.2.3.tgz", "integrity": "sha512-h7LCEM86kE68uWWAW0+NbKP+33qPC00SsbdJXzvmzNc18aIA/NukTi8gKZKEwHBENusLX0VRsHfIhyKDg7Fong==", - "peer": true, "dependencies": { "himalaya": "~1.1.0", "spotify-uri": "~3.0.3" @@ -4042,7 +3952,6 @@ "version": "6.3.0", "resolved": "https://registry.npmjs.org/strtok3/-/strtok3-6.3.0.tgz", "integrity": "sha512-fZtbhtvI9I48xDSywd/somNqgUHl2L2cstmXCCif0itOf96jeW18MBSyrLuNicYQVkvpOxkZtkzujiTJ9LW5Jw==", - "peer": true, "dependencies": { "@tokenizer/token": "^0.3.0", "peek-readable": "^4.1.0" @@ -4100,7 +4009,6 @@ "version": "4.2.1", "resolved": "https://registry.npmjs.org/token-types/-/token-types-4.2.1.tgz", "integrity": "sha512-6udB24Q737UD/SDsKAHI9FCRP7Bqc9D/MQUV02ORQg5iskjtLJlZJNdN4kKtcdtwCeWIwIHDGaUsTsCCAa8sFQ==", - "peer": true, "dependencies": { "@tokenizer/token": "^0.3.0", "ieee754": "^1.2.1" @@ -4341,22 +4249,7 @@ "node_modules/youtube-sr": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/youtube-sr/-/youtube-sr-4.3.4.tgz", - "integrity": "sha512-olSYcR80XigutCrePEXBX3/RJJrWfonJQj7+/ggBiWU0CzTDLE1q8+lpWTWCG0JpzhzILp/IB/Bq/glGqqr1TQ==", - "peer": true - }, - "node_modules/ytdl-core": { - "version": "4.11.3", - "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-4.11.3.tgz", - "integrity": "sha512-0KerQw+R7Nnhcebxq6WPopO92VLNnsoRVjJuhGhRzgfK1YdrnG1aqaq4zycolMBY+K8TZHXPV7ZNIjcawD/BPA==", - "peer": true, - "dependencies": { - "m3u8stream": "^0.8.6", - "miniget": "^4.2.2", - "sax": "^1.1.3" - }, - "engines": { - "node": ">=12" - } + "integrity": "sha512-olSYcR80XigutCrePEXBX3/RJJrWfonJQj7+/ggBiWU0CzTDLE1q8+lpWTWCG0JpzhzILp/IB/Bq/glGqqr1TQ==" } } } diff --git a/package.json b/package.json index 55c212b7..f3c60919 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "author": "Jonny_Bro#4226", "license": "ISC", "dependencies": { + "@discord-player/extractor": "^4.2.1", "@discordjs/opus": "^0.9.0", "@discordjs/rest": "^1.7.0", "@discordjs/voice": "^0.16.0", @@ -22,7 +23,7 @@ "cron": "^2.1.0", "discord-api-types": "^0.37.37", "discord-giveaways": "^6.0.1", - "discord-player": "^6.1.1", + "discord-player": "^6.2.1", "discord.js": "^14.9.0", "ejs": "^3.1.3", "express": "^4.17.1", @@ -35,7 +36,6 @@ "moment": "^2.26.0", "mongoose": "^5.13.15", "ms": "^2.1.3", - "openai": "^3.2.1", "play-dl": "^1.9.6" }, "devDependencies": {