From 0b27bf0d3400050424f7657badf026e69ca93d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Crezan5910=E2=80=9D?= Date: Wed, 17 Apr 2024 12:33:13 +0100 Subject: [PATCH 1/7] install openai and add ssample.env --- package-lock.json | 224 +++++++++++++++++++++++++++++++++++++++++++++- package.json | 3 +- sample.env | 5 ++ 3 files changed, 228 insertions(+), 4 deletions(-) create mode 100644 sample.env diff --git a/package-lock.json b/package-lock.json index 94dfc3f..b650a3e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,8 @@ "license": "ISC", "dependencies": { "discord.js": "^14.14.1", - "dotenv": "^16.4.5" + "dotenv": "^16.4.5", + "openai": "^4.36.0" }, "devDependencies": { "@eslint/js": "^9.0.0", @@ -383,6 +384,15 @@ "undici-types": "~5.26.4" } }, + "node_modules/@types/node-fetch": { + "version": "2.6.11", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.11.tgz", + "integrity": "sha512-24xFj9R5+rfQJLRyM56qh+wnVSYhyXC2tkoBndtY0U+vubqNsYXGjufB2nn8Q6gt0LrARwL6UBtMCSVCwl4B1g==", + "dependencies": { + "@types/node": "*", + "form-data": "^4.0.0" + } + }, "node_modules/@types/semver": { "version": "7.5.8", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.8.tgz", @@ -824,6 +834,17 @@ "npm": ">=7.0.0" } }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, "node_modules/acorn": { "version": "8.11.3", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", @@ -854,6 +875,17 @@ "node": ">=0.4.0" } }, + "node_modules/agentkeepalive": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz", + "integrity": "sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==", + "dependencies": { + "humanize-ms": "^1.2.1" + }, + "engines": { + "node": ">= 8.0.0" + } + }, "node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -915,6 +947,11 @@ "node": ">=8" } }, + "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/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -986,6 +1023,17 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "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/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -1035,6 +1083,14 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, + "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/diff": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", @@ -1286,6 +1342,14 @@ "node": ">=0.10.0" } }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "engines": { + "node": ">=6" + } + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -1400,6 +1464,44 @@ "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", "dev": 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": "1.7.2", + "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.2.tgz", + "integrity": "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A==" + }, + "node_modules/formdata-node": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/formdata-node/-/formdata-node-4.4.1.tgz", + "integrity": "sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==", + "dependencies": { + "node-domexception": "1.0.0", + "web-streams-polyfill": "4.0.0-beta.3" + }, + "engines": { + "node": ">= 12.20" + } + }, + "node_modules/formdata-node/node_modules/web-streams-polyfill": { + "version": "4.0.0-beta.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-4.0.0-beta.3.tgz", + "integrity": "sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==", + "engines": { + "node": ">= 14" + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -1485,6 +1587,14 @@ "node": ">=8" } }, + "node_modules/humanize-ms": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", + "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", + "dependencies": { + "ms": "^2.0.0" + } + }, "node_modules/ignore": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", @@ -1696,6 +1806,25 @@ "node": ">=8.6" } }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -1711,8 +1840,7 @@ "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node_modules/natural-compare": { "version": "1.4.0", @@ -1720,6 +1848,43 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, + "node_modules/node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "github", + "url": "https://paypal.me/jimmywarting" + } + ], + "engines": { + "node": ">=10.5.0" + } + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -1729,6 +1894,32 @@ "wrappy": "1" } }, + "node_modules/openai": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/openai/-/openai-4.36.0.tgz", + "integrity": "sha512-AtYrhhWY64LhB9P6f3H0nV8nTSaQJ89mWPnfNU5CnYg81zlYaV8nkyO+aTNfprdqP/9xv10woNNUgefXINT4Dg==", + "dependencies": { + "@types/node": "^18.11.18", + "@types/node-fetch": "^2.6.4", + "abort-controller": "^3.0.0", + "agentkeepalive": "^4.2.1", + "form-data-encoder": "1.7.2", + "formdata-node": "^4.3.2", + "node-fetch": "^2.6.7", + "web-streams-polyfill": "^3.2.1" + }, + "bin": { + "openai": "bin/cli" + } + }, + "node_modules/openai/node_modules/@types/node": { + "version": "18.19.31", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.31.tgz", + "integrity": "sha512-ArgCD39YpyyrtFKIqMDvjz79jto5fcI/SVUs2HwB+f0dAzq68yqOdyaSivLiLugSziTpNXLQrVb7RZFmdZzbhA==", + "dependencies": { + "undici-types": "~5.26.4" + } + }, "node_modules/optionator": { "version": "0.9.3", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", @@ -2057,6 +2248,11 @@ "node": ">=8.0" } }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, "node_modules/ts-api-utils": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", @@ -2216,6 +2412,28 @@ "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", "dev": true }, + "node_modules/web-streams-polyfill": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", + "engines": { + "node": ">= 8" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/package.json b/package.json index 8fdb522..22c5e3d 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,8 @@ "homepage": "https://github.com/fac31/Jana-Reza-Bot#jana-reza-bot", "dependencies": { "discord.js": "^14.14.1", - "dotenv": "^16.4.5" + "dotenv": "^16.4.5", + "openai": "^4.36.0" }, "devDependencies": { "@eslint/js": "^9.0.0", diff --git a/sample.env b/sample.env new file mode 100644 index 0000000..ba41790 --- /dev/null +++ b/sample.env @@ -0,0 +1,5 @@ +#DISCORD +TOKEN="Discord Bot Token" + +#OPENAI +API_KEY="OPEN AI API Key" From 637c190e175de900b0cdfe72fe4bf95bd490d170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Crezan5910=E2=80=9D?= Date: Wed, 17 Apr 2024 17:44:20 +0100 Subject: [PATCH 2/7] feat: openai fetch, add node-fetch dependency --- .gitignore | 2 +- package-lock.json | 83 ++++++++++++++++++++++++++++++++++++++++------- package.json | 1 + src/openai.ts | 35 ++++++++++++++++++++ 4 files changed, 108 insertions(+), 13 deletions(-) create mode 100644 src/openai.ts diff --git a/.gitignore b/.gitignore index bd23632..853760e 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,4 @@ dist/**/* # ignore yarn.lock yarn.lock - +prod diff --git a/package-lock.json b/package-lock.json index b650a3e..56e1bf6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "dependencies": { "discord.js": "^14.14.1", "dotenv": "^16.4.5", + "node-fetch": "^3.3.2", "openai": "^4.36.0" }, "devDependencies": { @@ -1060,6 +1061,14 @@ "node": ">= 8" } }, + "node_modules/data-uri-to-buffer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", + "engines": { + "node": ">= 12" + } + }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -1404,6 +1413,28 @@ "reusify": "^1.0.4" } }, + "node_modules/fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "paypal", + "url": "https://paypal.me/jimmywarting" + } + ], + "dependencies": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + }, + "engines": { + "node": "^12.20 || >= 14.13" + } + }, "node_modules/file-entry-cache": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", @@ -1502,6 +1533,17 @@ "node": ">= 14" } }, + "node_modules/formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "dependencies": { + "fetch-blob": "^3.1.2" + }, + "engines": { + "node": ">=12.20.0" + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -1867,22 +1909,20 @@ } }, "node_modules/node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", "dependencies": { - "whatwg-url": "^5.0.0" + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" }, "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-fetch" } }, "node_modules/once": { @@ -1920,6 +1960,25 @@ "undici-types": "~5.26.4" } }, + "node_modules/openai/node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, "node_modules/optionator": { "version": "0.9.3", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", diff --git a/package.json b/package.json index 22c5e3d..bbe564b 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "dependencies": { "discord.js": "^14.14.1", "dotenv": "^16.4.5", + "node-fetch": "^3.3.2", "openai": "^4.36.0" }, "devDependencies": { diff --git a/src/openai.ts b/src/openai.ts new file mode 100644 index 0000000..99ea7ec --- /dev/null +++ b/src/openai.ts @@ -0,0 +1,35 @@ +// import OpenAI from 'openai'; +import 'dotenv/config'; + +const API_KEY = process.env.API_KEY; +const API_URL = process.env.API_URL; +console.log(API_KEY, API_URL); +if (!API_URL || !API_KEY) { + throw new Error('API_URL or API_KEY is missing'); +} + +export const fetchOpenAIChatCompletion = async (prompt: string): Promise => { + const response = await fetch(API_URL, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Auhtorization': `Bearer ${API_KEY}` + }, + body: JSON.stringify({ + model: 'gpt-3.5-turbo', + messages: [ + { + role: 'system', + content: 'You are a friendly AI assistant.' + }, + { + role: 'user', + content: prompt + } + ] + + }) + }) + const data = await response.json(); + return data.choices[0].message.content.trim(); +}; \ No newline at end of file From b35424bcc812e463876e27dcb8034e672ec9e187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Crezan5910=E2=80=9D?= Date: Mon, 22 Apr 2024 12:40:40 +0100 Subject: [PATCH 3/7] pushing with issues --- package.json | 2 +- src/commandCenter/Commands.ts | 3 +- src/commandCenter/commands/Assistant.ts | 72 +++++++++++++++++++++++++ src/openai.ts | 54 ++++++++++--------- src/types.ts | 3 ++ 5 files changed, 107 insertions(+), 27 deletions(-) create mode 100644 src/commandCenter/commands/Assistant.ts create mode 100644 src/types.ts diff --git a/package.json b/package.json index bbe564b..31a0150 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "lint": "eslint src --ignore-path .eslintignore --ext .js,.ts", + "lint": "eslint src --ignore-path .eslintignore --ext .js,.ts && prettier --check . ", "start": "ts-node src/index.ts" }, "repository": { diff --git a/src/commandCenter/Commands.ts b/src/commandCenter/Commands.ts index a5f7404..8fac57f 100644 --- a/src/commandCenter/Commands.ts +++ b/src/commandCenter/Commands.ts @@ -1,6 +1,7 @@ import { Command } from "../Command"; import { Howdy } from "./commands/Howdy"; +import { Assistant } from "./commands/Assistant"; export const Commands: Command[] = [ - Howdy + Howdy, Assistant ]; diff --git a/src/commandCenter/commands/Assistant.ts b/src/commandCenter/commands/Assistant.ts new file mode 100644 index 0000000..d1b9be1 --- /dev/null +++ b/src/commandCenter/commands/Assistant.ts @@ -0,0 +1,72 @@ +import { CommandInteraction, Client, ApplicationCommandType, ApplicationCommandOptionType } from "discord.js"; +import { Command } from "../../Command"; +// import OpenAI from "openai"; +import 'dotenv/config'; +import { fetchOpenAIChatCompletion } from "../../openai"; +import { Prompt } from "../../types"; + +// const API_KEY = process.env.API_KEY; +// const API_URL = process.env.API_URL; +// console.log(API_KEY, API_URL); +// if (!API_URL || !API_KEY) { +// throw new Error('API_URL or API_KEY is missing'); +// } +// const openai = new OpenAI(API_KEY); + +export const Assistant: Command = { + name: "asssistant", + description: "assistant command", + type: ApplicationCommandType.ChatInput, + options: [{ + name: "query", + description: " tell me a nerdy joke", + type: ApplicationCommandOptionType.String, + required: true + }], + run: async (_: Client, interaction: CommandInteraction) => { + const userInput = interaction.options.get('query'); + if (userInput === null || userInput === undefined) { + await interaction.reply('Please provide a query'); + return; + } + const prompt: Prompt = { content: 'query' || ''}; + + try { + const generatedText = await fetchOpenAIChatCompletion(prompt); + await interaction.reply(generatedText); + + } catch (error) { + console.error(error); + // Consider providing a more user-friendly error message here + await interaction.reply('An error occurred. Please try again later.'); + } + } +} +// try { +// const openai = new OpenAI(API_KEY); +// // get the user query from the interaction +// const query = interaction.options.get('query'); +// // call the open ai api to get the response + +// // Define the type of params object explicitly +// interface Params { +// messages: { role: string, content: string }[]; +// model: string; +// } + +// // Construct the params object +// const params: Params = { +// messages: [{ role: 'system', content: 'You are a helpful assistant.' }], +// model: "No models available", +// }; + +// // Call the OpenAI API to get the response +// const response = await openai.chat.completions.create(params); + +// const botReply = response.choices[0]?.message.content || 'I am sorry, I did not understand that'; +// // respond back to user with the response +// await interaction.reply(botReply); +// } catch (error) { +// console.error(error); +// await interaction.reply('There was an error while processing your request'); +// } diff --git a/src/openai.ts b/src/openai.ts index 99ea7ec..4b7c0a8 100644 --- a/src/openai.ts +++ b/src/openai.ts @@ -1,5 +1,7 @@ -// import OpenAI from 'openai'; + import 'dotenv/config'; +import OpenAI from "openai"; +import { Prompt } from "./types"; const API_KEY = process.env.API_KEY; const API_URL = process.env.API_URL; @@ -7,29 +9,31 @@ console.log(API_KEY, API_URL); if (!API_URL || !API_KEY) { throw new Error('API_URL or API_KEY is missing'); } +const openai = new OpenAI({ apiKey: process.env.API_KEY }); + -export const fetchOpenAIChatCompletion = async (prompt: string): Promise => { - const response = await fetch(API_URL, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - 'Auhtorization': `Bearer ${API_KEY}` - }, - body: JSON.stringify({ - model: 'gpt-3.5-turbo', + +export async function fetchOpenAIChatCompletion(prompt: Prompt): Promise { + let prompt = '' + try { + const completion = await openai.chat.completions.create({ + model: "gpt-3.5-turbo", messages: [ - { - role: 'system', - content: 'You are a friendly AI assistant.' - }, - { - role: 'user', - content: prompt - } - ] - - }) - }) - const data = await response.json(); - return data.choices[0].message.content.trim(); -}; \ No newline at end of file + { role: "system", content: "You are a helpful assistant." }, + { role: "user", content: "Hello!" }, + ], + stream: true, // Enable streaming for chunks + }); + + let generatedText: string = ""; // Initialize empty string + for await (const chunk of completion) { + generatedText += chunk.choices[0]; + + } + return generatedText; + + } catch (error) { + console.error(error); + throw new Error('An error occurred while processing your request.'); + } +} diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 0000000..435c934 --- /dev/null +++ b/src/types.ts @@ -0,0 +1,3 @@ +export type Prompt ={ + content: string; // Other properties if needed + } \ No newline at end of file From 862724ccbc4c19408757a958ce6732dc218e45b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Crezan5910=E2=80=9D?= Date: Mon, 22 Apr 2024 20:41:32 +0100 Subject: [PATCH 4/7] feat:openai api integration,openai update, assitant function --- package-lock.json | 8 +-- package.json | 2 +- src/commandCenter/commands/Assistant.ts | 91 ++++++++----------------- src/openai.ts | 45 ++++++------ 4 files changed, 56 insertions(+), 90 deletions(-) diff --git a/package-lock.json b/package-lock.json index 56e1bf6..9e6f4da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "discord.js": "^14.14.1", "dotenv": "^16.4.5", "node-fetch": "^3.3.2", - "openai": "^4.36.0" + "openai": "^4.38.3" }, "devDependencies": { "@eslint/js": "^9.0.0", @@ -1935,9 +1935,9 @@ } }, "node_modules/openai": { - "version": "4.36.0", - "resolved": "https://registry.npmjs.org/openai/-/openai-4.36.0.tgz", - "integrity": "sha512-AtYrhhWY64LhB9P6f3H0nV8nTSaQJ89mWPnfNU5CnYg81zlYaV8nkyO+aTNfprdqP/9xv10woNNUgefXINT4Dg==", + "version": "4.38.3", + "resolved": "https://registry.npmjs.org/openai/-/openai-4.38.3.tgz", + "integrity": "sha512-mIL9WtrFNOanpx98mJ+X/wkoepcxdqqu0noWFoNQHl/yODQ47YM7NEYda7qp8JfjqpLFVxY9mQhshoS/Fqac0A==", "dependencies": { "@types/node": "^18.11.18", "@types/node-fetch": "^2.6.4", diff --git a/package.json b/package.json index 31a0150..00de5f7 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "discord.js": "^14.14.1", "dotenv": "^16.4.5", "node-fetch": "^3.3.2", - "openai": "^4.36.0" + "openai": "^4.38.3" }, "devDependencies": { "@eslint/js": "^9.0.0", diff --git a/src/commandCenter/commands/Assistant.ts b/src/commandCenter/commands/Assistant.ts index d1b9be1..dc3073a 100644 --- a/src/commandCenter/commands/Assistant.ts +++ b/src/commandCenter/commands/Assistant.ts @@ -1,72 +1,41 @@ -import { CommandInteraction, Client, ApplicationCommandType, ApplicationCommandOptionType } from "discord.js"; -import { Command } from "../../Command"; -// import OpenAI from "openai"; -import 'dotenv/config'; -import { fetchOpenAIChatCompletion } from "../../openai"; -import { Prompt } from "../../types"; - -// const API_KEY = process.env.API_KEY; -// const API_URL = process.env.API_URL; -// console.log(API_KEY, API_URL); -// if (!API_URL || !API_KEY) { -// throw new Error('API_URL or API_KEY is missing'); -// } -// const openai = new OpenAI(API_KEY); +import { + CommandInteraction, + Client, + ApplicationCommandType, + ApplicationCommandOptionType, +} from 'discord.js' +import { Command } from '../../Command' +import 'dotenv/config' +import { fetchOpenAIChatCompletion } from '../../openai' export const Assistant: Command = { - name: "asssistant", - description: "assistant command", + name: 'asssistant', + description: 'assistant command', type: ApplicationCommandType.ChatInput, - options: [{ - name: "query", - description: " tell me a nerdy joke", - type: ApplicationCommandOptionType.String, - required: true - }], + options: [ + { + name: 'query', + description: ' tell me a nerdy joke', + type: ApplicationCommandOptionType.String, + required: true, + }, + ], run: async (_: Client, interaction: CommandInteraction) => { - const userInput = interaction.options.get('query'); + const userInput = interaction.options.get('query')?.value as string + console.log(userInput) if (userInput === null || userInput === undefined) { - await interaction.reply('Please provide a query'); - return; + // await interaction.reply('Please provide a query'); + return } - const prompt: Prompt = { content: 'query' || ''}; - - try { - const generatedText = await fetchOpenAIChatCompletion(prompt); - await interaction.reply(generatedText); + try { + const generatedText = await fetchOpenAIChatCompletion(userInput) + console.log(generatedText) + await interaction.followUp(generatedText) } catch (error) { - console.error(error); + console.error(error) // Consider providing a more user-friendly error message here - await interaction.reply('An error occurred. Please try again later.'); + // await interaction.reply('An error occurred. Please try again later.'); } - } + }, } -// try { -// const openai = new OpenAI(API_KEY); -// // get the user query from the interaction -// const query = interaction.options.get('query'); -// // call the open ai api to get the response - -// // Define the type of params object explicitly -// interface Params { -// messages: { role: string, content: string }[]; -// model: string; -// } - -// // Construct the params object -// const params: Params = { -// messages: [{ role: 'system', content: 'You are a helpful assistant.' }], -// model: "No models available", -// }; - -// // Call the OpenAI API to get the response -// const response = await openai.chat.completions.create(params); - -// const botReply = response.choices[0]?.message.content || 'I am sorry, I did not understand that'; -// // respond back to user with the response -// await interaction.reply(botReply); -// } catch (error) { -// console.error(error); -// await interaction.reply('There was an error while processing your request'); -// } diff --git a/src/openai.ts b/src/openai.ts index 4b7c0a8..545d78d 100644 --- a/src/openai.ts +++ b/src/openai.ts @@ -1,39 +1,36 @@ +import OpenAI from 'openai' +import 'dotenv/config' -import 'dotenv/config'; -import OpenAI from "openai"; -import { Prompt } from "./types"; +const API_KEY = process.env.API_KEY -const API_KEY = process.env.API_KEY; -const API_URL = process.env.API_URL; -console.log(API_KEY, API_URL); -if (!API_URL || !API_KEY) { - throw new Error('API_URL or API_KEY is missing'); +if (!API_KEY) { + throw new Error('API_URL or API_KEY is missing') } -const openai = new OpenAI({ apiKey: process.env.API_KEY }); +const openai = new OpenAI({ apiKey: process.env.API_KEY }) - - -export async function fetchOpenAIChatCompletion(prompt: Prompt): Promise { - let prompt = '' +export async function fetchOpenAIChatCompletion( + userInput: string +): Promise { try { const completion = await openai.chat.completions.create({ - model: "gpt-3.5-turbo", + model: 'gpt-3.5-turbo', messages: [ - { role: "system", content: "You are a helpful assistant." }, - { role: "user", content: "Hello!" }, + { role: 'system', content: 'You are a helpful assistant.' }, + { role: 'user', content: userInput }, ], stream: true, // Enable streaming for chunks - }); + }) - let generatedText: string = ""; // Initialize empty string + let generatedText: string = '' // Initialize empty string for await (const chunk of completion) { - generatedText += chunk.choices[0]; - + if (chunk.choices[0]?.delta?.content === undefined) { + break + } + generatedText += chunk.choices[0]?.delta?.content } - return generatedText; - + return generatedText } catch (error) { - console.error(error); - throw new Error('An error occurred while processing your request.'); + console.error(error) + throw new Error('An error occurred while processing your request.') } } From a43f93233a6d7a27672a731a29f2b6e3c97f6481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Crezan5910=E2=80=9D?= Date: Mon, 22 Apr 2024 22:06:07 +0100 Subject: [PATCH 5/7] fix linting issues and prettier --write --- README.md | 6 +- package.json | 96 ++++++++++++++--------------- src/Command.ts | 12 ++-- src/commandCenter/Commands.ts | 2 +- src/commandCenter/commands/Howdy.ts | 18 +++--- src/index.ts | 19 +++--- src/listeners/interactionCreator.ts | 27 ++++---- src/listeners/ready.ts | 20 +++--- src/types.ts | 6 +- 9 files changed, 105 insertions(+), 101 deletions(-) diff --git a/README.md b/README.md index b0a2975..4d9ffc7 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Jana-Reza-Bot -To start +To start `npm run start` This will run the bot using ts-node -bot invite link +bot invite link https://v13.discordjs.guide/preparations/adding-your-bot-to-servers.html#bot-invite-links -add your bot token to env as +add your bot token to env as TOKEN="YOUR_TOKEN" in Discord Dev Portal under permissions add the needed permission to your bot dicord bot invite link to your server diff --git a/package.json b/package.json index aef7d4b..966a9de 100644 --- a/package.json +++ b/package.json @@ -1,52 +1,52 @@ { - "name": "jana-reza-bot", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "lint": "eslint src --ignore-path .eslintignore --ext .js,.ts && prettier --check . ", - "start": "ts-node src/index.ts" - }, - "repository": { - "type": "git", - "url": "git+ssh://github.com:fac31/Jana-Reza-Bot.git" - }, - "keywords": [], - "contributors": [ - { - "name": "Reza Ghaniloo", - "email": "email@email.com", - "url": "https://github.com/rghaniloo" + "name": "jana-reza-bot", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "lint": "eslint src --ignore-path .eslintignore --ext .js,.ts && prettier ./src --write ", + "start": "ts-node src/index.ts" }, - { - "name": "Jana Gerrard", - "email": "email@email.com", - "url": "https://github.com/sulphite" + "repository": { + "type": "git", + "url": "git+ssh://github.com:fac31/Jana-Reza-Bot.git" + }, + "keywords": [], + "contributors": [ + { + "name": "Reza Ghaniloo", + "email": "email@email.com", + "url": "https://github.com/rghaniloo" + }, + { + "name": "Jana Gerrard", + "email": "email@email.com", + "url": "https://github.com/sulphite" + } + ], + "license": "ISC", + "bug": { + "url": "https://github.com/fac31/Jana-Reza-Bot/issues" + }, + "homepage": "https://github.com/fac31/Jana-Reza-Bot#jana-reza-bot", + "dependencies": { + "chrono-node": "^2.7.5", + "dayjs": "^1.11.10", + "discord.js": "^14.14.1", + "dotenv": "^16.4.5", + "node-fetch": "^3.3.2", + "openai": "^4.38.3" + }, + "devDependencies": { + "@eslint/js": "^9.0.0", + "@typescript-eslint/eslint-plugin": "^7.6.0", + "@typescript-eslint/parser": "^7.6.0", + "eslint": "^8.57.0", + "globals": "^15.0.0", + "prettier": "^3.2.5", + "ts-node": "^10.9.2", + "typescript": "^5.4.5", + "typescript-eslint": "^7.6.0" } - ], - "license": "ISC", - "bug": { - "url": "https://github.com/fac31/Jana-Reza-Bot/issues" - }, - "homepage": "https://github.com/fac31/Jana-Reza-Bot#jana-reza-bot", - "dependencies": { - "chrono-node": "^2.7.5", - "dayjs": "^1.11.10", - "discord.js": "^14.14.1", - "dotenv": "^16.4.5", - "node-fetch": "^3.3.2", - "openai": "^4.38.3" - }, - "devDependencies": { - "@eslint/js": "^9.0.0", - "@typescript-eslint/eslint-plugin": "^7.6.0", - "@typescript-eslint/parser": "^7.6.0", - "eslint": "^8.57.0", - "globals": "^15.0.0", - "prettier": "^3.2.5", - "ts-node": "^10.9.2", - "typescript": "^5.4.5", - "typescript-eslint": "^7.6.0" - } } diff --git a/src/Command.ts b/src/Command.ts index bca76db..d7516d6 100644 --- a/src/Command.ts +++ b/src/Command.ts @@ -1,8 +1,12 @@ -import { CommandInteraction, ChatInputApplicationCommandData, Client } from "discord.js"; +import { + CommandInteraction, + ChatInputApplicationCommandData, + Client, +} from 'discord.js' /** - * defining the structure of the slash command + * defining the structure of the slash command */ export type Command = ChatInputApplicationCommandData & { - run: (client: Client, interaction: CommandInteraction) => void; -}; \ No newline at end of file + run: (client: Client, interaction: CommandInteraction) => void +} diff --git a/src/commandCenter/Commands.ts b/src/commandCenter/Commands.ts index 089a257..cb33192 100644 --- a/src/commandCenter/Commands.ts +++ b/src/commandCenter/Commands.ts @@ -3,4 +3,4 @@ import { Howdy } from './commands/Howdy' import { Assistant } from './commands/Assistant' import { Time } from './commands/Time' -export const Commands: Command[] = [Howdy, Time, Assistant]; +export const Commands: Command[] = [Howdy, Time, Assistant] diff --git a/src/commandCenter/commands/Howdy.ts b/src/commandCenter/commands/Howdy.ts index d8cc854..fc29288 100644 --- a/src/commandCenter/commands/Howdy.ts +++ b/src/commandCenter/commands/Howdy.ts @@ -1,17 +1,17 @@ -import { CommandInteraction, Client , ApplicationCommandType} from "discord.js"; -import { Command } from "../../Command"; +import { CommandInteraction, Client, ApplicationCommandType } from 'discord.js' +import { Command } from '../../Command' export const Howdy: Command = { - name: "howdy", - description: "Howdy command", + name: 'howdy', + description: 'Howdy command', type: ApplicationCommandType.ChatInput, run: async (client: Client, interaction: CommandInteraction) => { - const content = `Howdy!👋 How are you doing today ${client.user?.username}?`; + const content = `Howdy!👋 How are you doing today ${client.user?.username}?` await interaction.followUp({ //https://discordjs.guide/slash-commands/response-methods.html#ephemeral-responses ephemeral: true, - content - }); - } -} \ No newline at end of file + content, + }) + }, +} diff --git a/src/index.ts b/src/index.ts index fe464f9..fb3f3ce 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,15 +1,14 @@ import 'dotenv/config' -import { Client} from "discord.js" -import ready from './listeners/ready'; -import interactionCreator from './listeners/interactionCreator'; +import { Client } from 'discord.js' +import ready from './listeners/ready' +import interactionCreator from './listeners/interactionCreator' -const token = process.env.TOKEN; +const token = process.env.TOKEN console.log('FACTROID IS starting .....') const client = new Client({ - intents: [] + intents: [], +}) -}); - -ready(client); // registering the listener -interactionCreator(client); //listerning to interactipon -client.login(token); \ No newline at end of file +ready(client) // registering the listener +interactionCreator(client) //listerning to interactipon +client.login(token) diff --git a/src/listeners/interactionCreator.ts b/src/listeners/interactionCreator.ts index 2a84bb5..ffea417 100644 --- a/src/listeners/interactionCreator.ts +++ b/src/listeners/interactionCreator.ts @@ -1,21 +1,24 @@ -import { CommandInteraction, Client, Interaction } from "discord.js"; -import { Commands } from "../commandCenter/Commands"; +import { CommandInteraction, Client, Interaction } from 'discord.js' +import { Commands } from '../commandCenter/Commands' export default (client: Client): void => { - client.on("interactionCreate", async (interaction: Interaction) => { + client.on('interactionCreate', async (interaction: Interaction) => { if (interaction.isCommand()) { await handleSlashCommand(client, interaction) } }) } -const handleSlashCommand = async (client: Client, interaction: CommandInteraction): Promise => { - const slashCommand = Commands.find(command => command.name === interaction.commandName); +const handleSlashCommand = async ( + client: Client, + interaction: CommandInteraction +): Promise => { + const slashCommand = Commands.find( + (command) => command.name === interaction.commandName + ) if (!slashCommand) { - interaction.followUp({content: 'we havea problem'}) - return; + interaction.followUp({ content: 'we havea problem' }) + return } - await interaction.deferReply(); - slashCommand.run(client, interaction); - - -}; \ No newline at end of file + await interaction.deferReply() + slashCommand.run(client, interaction) +} diff --git a/src/listeners/ready.ts b/src/listeners/ready.ts index d62a9c2..f7be493 100644 --- a/src/listeners/ready.ts +++ b/src/listeners/ready.ts @@ -1,22 +1,20 @@ -import { Client } from "discord.js"; +import { Client } from 'discord.js' // we register all the commands with the client in the ready event -import {Commands} from "../commandCenter/Commands"; - +import { Commands } from '../commandCenter/Commands' /** - * sepreating and registering a listner to listen to + * sepreating and registering a listner to listen to * variety of messages, user activities etc - * + * */ export default (client: Client): void => { // :void as its non value returning func - client.on("ready", async () => { + client.on('ready', async () => { if (!client.user || !client.application) { - return; + return } // registering all the commands - await client.application.commands.set(Commands); + await client.application.commands.set(Commands) console.log(`${client?.user?.username} is online and ready !`) - }); - -} \ No newline at end of file + }) +} diff --git a/src/types.ts b/src/types.ts index 435c934..d1b3938 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,3 +1,3 @@ -export type Prompt ={ - content: string; // Other properties if needed - } \ No newline at end of file +export type Prompt = { + content: string // Other properties if needed +} From b09f58a18553a166dbe88a0fa7965371d2f87d72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Crezan5910=E2=80=9D?= Date: Mon, 22 Apr 2024 22:14:47 +0100 Subject: [PATCH 6/7] fix:remove unncesary type file --- src/types.ts | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 src/types.ts diff --git a/src/types.ts b/src/types.ts deleted file mode 100644 index d1b3938..0000000 --- a/src/types.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type Prompt = { - content: string // Other properties if needed -} From 2c5374beb45e12bde1e0e6479f6288d9812724fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Crezan5910=E2=80=9D?= Date: Tue, 23 Apr 2024 11:24:12 +0100 Subject: [PATCH 7/7] fix:name typo --- src/commandCenter/commands/Assistant.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commandCenter/commands/Assistant.ts b/src/commandCenter/commands/Assistant.ts index dc3073a..bcda258 100644 --- a/src/commandCenter/commands/Assistant.ts +++ b/src/commandCenter/commands/Assistant.ts @@ -9,7 +9,7 @@ import 'dotenv/config' import { fetchOpenAIChatCompletion } from '../../openai' export const Assistant: Command = { - name: 'asssistant', + name: 'assistant', description: 'assistant command', type: ApplicationCommandType.ChatInput, options: [