From bf2928471d261286d16274ccea2e672ed6ef7811 Mon Sep 17 00:00:00 2001 From: brblacky Date: Sun, 22 Oct 2023 21:40:37 +0530 Subject: [PATCH] added code format --- .eslintignore | 9 + .eslintrc.json | 94 ++++ .github/workflows/build-docker.yml | 73 ++- .github/workflows/codeql.yml | 103 ++-- .github/workflows/jekyll-gh-pages.yml | 72 +-- .gitignore | 16 +- .prettierignore | 9 + .prettierrc.json | 12 + README.md | 144 ++--- docker-compose.yml | 126 ++--- package.json | 176 ++++--- src/LavaClient.ts | 27 +- .../controllers/guilds/GuildControllers.ts | 14 +- src/api/index.ts | 68 +-- src/api/middlewares/Middlewares.ts | 4 +- src/api/routes/MainRouter.ts | 18 +- src/api/routes/auth/AuthRouter.ts | 36 +- src/api/routes/guilds/GuildRouter.ts | 25 +- src/api/routes/guilds/GuildsRouter.ts | 10 +- src/api/services/guilds/GuildServices.ts | 63 ++- src/api/strategy/discord.ts | 46 +- src/api/types/types.ts | 2 - src/commands/config/247.ts | 121 +++-- src/commands/config/Dj.ts | 312 +++++------ src/commands/config/Prefix.ts | 202 +++---- src/commands/config/Setup.ts | 166 +++--- src/commands/dev/Eval.ts | 10 +- src/commands/dev/GuildLeave.ts | 11 +- src/commands/dev/GuildList.ts | 16 +- src/commands/filters/8d.ts | 108 ++-- src/commands/filters/BassBoost.ts | 114 ++-- src/commands/filters/Distorsion.ts | 124 ++--- src/commands/filters/Karaoke.ts | 116 ++-- src/commands/filters/NightCore.ts | 106 ++-- src/commands/filters/Pitch.ts | 133 ++--- src/commands/filters/Reset.ts | 82 +-- src/commands/filters/Rotation.ts | 106 ++-- src/commands/filters/Speed.ts | 133 ++--- src/commands/filters/Tremolo.ts | 106 ++-- src/commands/filters/Vibrato.ts | 104 ++-- src/commands/filters/lowPass.ts | 104 ++-- src/commands/info/About.ts | 157 +++--- src/commands/info/Help.ts | 189 +++---- src/commands/info/Info.ts | 109 ++-- src/commands/info/Invite.ts | 116 ++-- src/commands/info/LavaLink.ts | 49 +- src/commands/info/Ping.ts | 108 ++-- src/commands/music/Autoplay.ts | 80 +-- src/commands/music/ClearQueue.ts | 84 +-- src/commands/music/Grab.ts | 111 ++-- src/commands/music/Join.ts | 105 ++-- src/commands/music/Leave.ts | 92 ++-- src/commands/music/Loop.ts | 102 ++-- src/commands/music/Nowplaying.ts | 96 ++-- src/commands/music/Pause.ts | 86 +-- src/commands/music/Play.ts | 281 +++++----- src/commands/music/Queue.ts | 128 ++--- src/commands/music/Remove.ts | 140 ++--- src/commands/music/Resume.ts | 84 +-- src/commands/music/Search.ts | 220 ++++---- src/commands/music/Seek.ts | 98 ++-- src/commands/music/Shuffle.ts | 84 +-- src/commands/music/Skip.ts | 100 ++-- src/commands/music/Skipto.ts | 138 ++--- src/commands/music/Stop.ts | 78 +-- src/commands/music/Volume.ts | 130 +++-- src/commands/playlist/Add.ts | 119 +++-- src/commands/playlist/Create.ts | 90 ++-- src/commands/playlist/Delete.ts | 76 +-- src/commands/playlist/Load.ts | 78 +-- src/config.ts | 118 +++-- src/database/server.ts | 68 +-- src/database/user.ts | 16 +- src/events/client/GuildCreate.ts | 34 +- src/events/client/GuildDelete.ts | 32 +- src/events/client/InteractionCreate.ts | 383 +++++++------- src/events/client/MessageCreate.ts | 404 +++++++------- src/events/client/Ready.ts | 34 +- src/events/client/SetupButtons.ts | 245 +++++++-- src/events/client/SetupSystem.ts | 57 +- src/events/client/VoiceStateUpdate.ts | 153 +++--- src/events/player/NodeConnect.ts | 45 +- src/events/player/QueueEnd.ts | 9 +- src/events/player/TrackEnd.ts | 35 +- src/events/player/TrackStart.ts | 497 ++++++++++-------- src/index.ts | 54 +- src/plugin/index.ts | 32 +- src/plugin/plugins/advicePlugin.ts | 43 +- src/plugin/plugins/antiCrash.ts | 24 +- src/structures/Command.ts | 169 +++--- src/structures/Context.ts | 175 +++--- src/structures/Dispatcher.ts | 425 +++++++-------- src/structures/Event.ts | 34 +- src/structures/Lavamusic.ts | 271 +++++----- src/structures/Logger.ts | 102 ++-- src/structures/Queue.ts | 113 ++-- src/structures/Shoukaku.ts | 50 +- src/structures/index.ts | 6 +- src/types.ts | 6 +- src/utils/Buttons.ts | 42 +- src/utils/SetupSystem.ts | 366 +++++++++---- src/utils/Utils.ts | 337 ++++++------ tsconfig.build.json | 9 - tsconfig.json | 17 +- 104 files changed, 6053 insertions(+), 5001 deletions(-) create mode 100644 .eslintignore create mode 100644 .eslintrc.json create mode 100644 .prettierignore create mode 100644 .prettierrc.json delete mode 100644 tsconfig.build.json diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..f29759856 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,9 @@ +# Folders +/.cache +/.git +/dist +/dashboard +/docs +/misc +/node_modules +/temp diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 000000000..d20691599 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,94 @@ +{ + "root": true, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "project": "./tsconfig.json" + }, + "plugins": ["@typescript-eslint", "import", "unicorn"], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking", + "plugin:import/recommended", + "plugin:import/typescript" + ], + "rules": { + "@typescript-eslint/explicit-function-return-type": [ + "error", + { + "allowExpressions": true + } + ], + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-floating-promises": "off", + "@typescript-eslint/no-inferrable-types": [ + "error", + { + "ignoreParameters": true + } + ], + "@typescript-eslint/no-misused-promises": "off", + "@typescript-eslint/no-unsafe-argument": "off", + "@typescript-eslint/no-unsafe-assignment": "off", + "@typescript-eslint/no-unsafe-call": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/no-unsafe-return": "off", + "@typescript-eslint/no-unused-vars": [ + "error", + { + "argsIgnorePattern": "^_", + "varsIgnorePattern": "^_" + } + ], + "@typescript-eslint/no-var-requires": "off", + "@typescript-eslint/require-await": "off", + "@typescript-eslint/restrict-template-expressions": "off", + "@typescript-eslint/return-await": ["error", "always"], + "@typescript-eslint/typedef": [ + "error", + { + "parameter": true, + "propertyDeclaration": true + } + ], + + "import/no-extraneous-dependencies": "error", + "import/no-unresolved": "off", + "import/no-useless-path-segments": "error", + "import/order": [ + "error", + { + "alphabetize": { + "caseInsensitive": true, + "order": "asc" + }, + "groups": [ + ["builtin", "external", "object", "type"], + ["internal", "parent", "sibling", "index"] + ], + "newlines-between": "always" + } + ], + "no-return-await": "off", + "no-unused-vars": "off", + "prefer-const": "off", + "quotes": [ + "error", + "single", + { + "allowTemplateLiterals": true + } + ], + "sort-imports": [ + "error", + { + "allowSeparatedGroups": true, + "ignoreCase": true, + "ignoreDeclarationSort": true, + "ignoreMemberSort": false, + "memberSyntaxSortOrder": ["none", "all", "multiple", "single"] + } + ], + "unicorn/prefer-node-protocol": "error" + } +} diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 82770eec9..9725587da 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -2,44 +2,37 @@ name: Build and publish a Docker image to ghcr.io on: push jobs: - docker_publish: - runs-on: "ubuntu-20.04" + docker_publish: + runs-on: 'ubuntu-20.04' - steps: - - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - - name: Available platforms - run: echo ${{ steps.buildx.outputs.platforms }} - - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: ghcr.io/brblacky/lavamusic - - - name: Login to Github Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v3 - with: - context: . - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - platforms: | - linux/amd64 - linux/arm64 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + - name: Available platforms + run: echo ${{ steps.buildx.outputs.platforms }} + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: ghcr.io/brblacky/lavamusic + - name: Login to Github Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v3 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: | + linux/amd64 + linux/arm64 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index b273f2555..ef78493cb 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -9,68 +9,67 @@ # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # -name: "CodeQL" +name: 'CodeQL' on: - push: - branches: [ "main" ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ "main" ] - schedule: - - cron: '18 20 * * 3' + push: + branches: ['main'] + pull_request: + # The branches below must be a subset of the branches above + branches: ['main'] + schedule: + - cron: '18 20 * * 3' jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write - strategy: - fail-fast: false - matrix: - language: [ 'javascript' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Use only 'java' to analyze code written in Java, Kotlin or both - # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + strategy: + fail-fast: false + matrix: + language: ['javascript'] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Use only 'java' to analyze code written in Java, Kotlin or both + # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - steps: - - name: Checkout repository - uses: actions/checkout@v3 + steps: + - name: Checkout repository + uses: actions/checkout@v3 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: '/language:${{matrix.language}}' diff --git a/.github/workflows/jekyll-gh-pages.yml b/.github/workflows/jekyll-gh-pages.yml index 6dd01a690..f3bedf8b4 100644 --- a/.github/workflows/jekyll-gh-pages.yml +++ b/.github/workflows/jekyll-gh-pages.yml @@ -2,50 +2,50 @@ name: Deploy Jekyll with GitHub Pages dependencies preinstalled on: - # Runs on pushes targeting the default branch - push: - branches: ["main"] + # Runs on pushes targeting the default branch + push: + branches: ['main'] - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: - contents: read - pages: write - id-token: write + contents: read + pages: write + id-token: write # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. concurrency: - group: "pages" - cancel-in-progress: false + group: 'pages' + cancel-in-progress: false jobs: - # Build job - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup Pages - uses: actions/configure-pages@v3 - - name: Build with Jekyll - uses: actions/jekyll-build-pages@v1 - with: - source: ./ - destination: ./_site - - name: Upload artifact - uses: actions/upload-pages-artifact@v1 + # Build job + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Pages + uses: actions/configure-pages@v3 + - name: Build with Jekyll + uses: actions/jekyll-build-pages@v1 + with: + source: ./ + destination: ./_site + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 - # Deployment job - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - needs: build - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v1 + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1 diff --git a/.gitignore b/.gitignore index 1827534c6..f734a5113 100644 --- a/.gitignore +++ b/.gitignore @@ -13,17 +13,21 @@ # Ignore target folder -target +/target -yarn.lock +/yarn.lock -.next +/.next /node_modules -pnpm-lock.yaml +/pnpm-lock.yaml -yarn-error.log +/yarn-error.log -yarn.lock \ No newline at end of file +/yarn.lock + +/.eslintcache + +/package-lock.json \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..f29759856 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,9 @@ +# Folders +/.cache +/.git +/dist +/dashboard +/docs +/misc +/node_modules +/temp diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 000000000..ad2cf87f5 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,12 @@ +{ + "printWidth": 100, + "tabWidth": 4, + "useTabs": false, + "semi": true, + "singleQuote": true, + "quoteProps": "as-needed", + "trailingComma": "es5", + "bracketSpacing": true, + "arrowParens": "avoid", + "endOfLine": "auto" +} diff --git a/README.md b/README.md index 0afcebb07..a4e094f65 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -
[![Version][version-shield]](version-url) @@ -30,45 +29,46 @@ ## đŸ”Ĩ Unique Features -- Developed using Typescript and Discord.js v14 -- Advanced Music System -- Customizable Prefix -- Powerful Search Engine -- 12 + Music Filters -- Hybrid Command Handling (Slash and Normal Commands) -- Highly Configurable -- User-friendly and Easy to Use -- 24/7 Music Playback -- Playlist commands -- Setup music channel -- Dashboard (Work in progress) +- Developed using Typescript and Discord.js v14 +- Advanced Music System +- Customizable Prefix +- Powerful Search Engine +- 12 + Music Filters +- Hybrid Command Handling (Slash and Normal Commands) +- Highly Configurable +- User-friendly and Easy to Use +- 24/7 Music Playback +- Playlist commands +- Setup music channel +- Dashboard (Work in progress) + ## đŸŽļ Support Sources 🔍 **Default Sources**: -- ![YouTube](https://img.shields.io/badge/YouTube-FF0000?style=plastic&logo=youtube&logoColor=white) -- ![SoundCloud](https://img.shields.io/badge/SoundCloud-FF3300?style=plastic&logo=soundcloud&logoColor=white) -- ![Twitch](https://img.shields.io/badge/Twitch-9146FF?style=plastic&logo=twitch&logoColor=white) -- ![Bandcamp](https://img.shields.io/badge/Bandcamp-629AA9?style=plastic&logo=bandcamp&logoColor=white) -- ![Vimeo](https://img.shields.io/badge/Vimeo-1AB7EA?style=plastic&logo=vimeo&logoColor=white) -- ![http](https://img.shields.io/badge/http-FFA500?style=plastic&logo=http&logoColor=white) +- ![YouTube](https://img.shields.io/badge/YouTube-FF0000?style=plastic&logo=youtube&logoColor=white) +- ![SoundCloud](https://img.shields.io/badge/SoundCloud-FF3300?style=plastic&logo=soundcloud&logoColor=white) +- ![Twitch](https://img.shields.io/badge/Twitch-9146FF?style=plastic&logo=twitch&logoColor=white) +- ![Bandcamp](https://img.shields.io/badge/Bandcamp-629AA9?style=plastic&logo=bandcamp&logoColor=white) +- ![Vimeo](https://img.shields.io/badge/Vimeo-1AB7EA?style=plastic&logo=vimeo&logoColor=white) +- ![http](https://img.shields.io/badge/http-FFA500?style=plastic&logo=http&logoColor=white) 🔌 **Plugin Sources**: `(Require: LavaLink v3.6.x)` **Note: You need to install the plugins to use these sources** -- ![Spotify](https://img.shields.io/badge/Spotify-1ED760?style=plastic&logo=spotify&logoColor=white) ([Required Plugin][LavaSry]) -- ![Deezer](https://img.shields.io/badge/Deezer-FF0000?style=plastic&logo=deezer&logoColor=white) ([Required Plugin][LavaSry]) -- ![Apple Music](https://img.shields.io/badge/Apple%20Music-000000?style=plastic&logo=apple-music&logoColor=white) ([Required Plugin][LavaSry]) -- ![Yandex Music](https://img.shields.io/badge/Yandex%20Music-FF0066?style=plastic&logo=yandex-music&logoColor=white) ([Required Plugin][LavaSry]) -- ![Mixcloud](https://img.shields.io/badge/Mixcloud-51C4D3?style=plastic&logo=mixcloud&logoColor=white) ([Required Plugin][skybot-lavalink-plugin]) -- ![Ocremix](https://img.shields.io/badge/Ocremix-FF6600?style=plastic&logo=ocremix&logoColor=white) ([Required Plugin][skybot-lavalink-plugin]) -- ![Clyp](https://img.shields.io/badge/Clyp-6BB5A6?style=plastic&logo=clyp&logoColor=white) ([Required Plugin][skybot-lavalink-plugin]) -- ![Reddit](https://img.shields.io/badge/Reddit-FF4500?style=plastic&logo=reddit&logoColor=white) ([Required Plugin][skybot-lavalink-plugin]) -- ![Getyarn](https://img.shields.io/badge/Getyarn-FF9000?style=plastic&logo=getyarn&logoColor=white) ([Required Plugin][skybot-lavalink-plugin]) -- ![TikTok](https://img.shields.io/badge/TikTok-FF2D55?style=plastic&logo=tiktok&logoColor=white) ([Required Plugin][skybot-lavalink-plugin]) -- ![Soundgasm](https://img.shields.io/badge/Soundgasm-F1672F?style=plastic&logo=soundgasm&logoColor=white) ([Required Plugin][skybot-lavalink-plugin]) -- ![Text To Speech](https://img.shields.io/badge/Text%20To%20Speech-3080ff?style=plastic&logo=google-translate&logoColor=white) ([Required Plugin][skybot-lavalink-plugin]) +- ![Spotify](https://img.shields.io/badge/Spotify-1ED760?style=plastic&logo=spotify&logoColor=white) ([Required Plugin][LavaSry]) +- ![Deezer](https://img.shields.io/badge/Deezer-FF0000?style=plastic&logo=deezer&logoColor=white) ([Required Plugin][LavaSry]) +- ![Apple Music](https://img.shields.io/badge/Apple%20Music-000000?style=plastic&logo=apple-music&logoColor=white) ([Required Plugin][LavaSry]) +- ![Yandex Music](https://img.shields.io/badge/Yandex%20Music-FF0066?style=plastic&logo=yandex-music&logoColor=white) ([Required Plugin][LavaSry]) +- ![Mixcloud](https://img.shields.io/badge/Mixcloud-51C4D3?style=plastic&logo=mixcloud&logoColor=white) ([Required Plugin][skybot-lavalink-plugin]) +- ![Ocremix](https://img.shields.io/badge/Ocremix-FF6600?style=plastic&logo=ocremix&logoColor=white) ([Required Plugin][skybot-lavalink-plugin]) +- ![Clyp](https://img.shields.io/badge/Clyp-6BB5A6?style=plastic&logo=clyp&logoColor=white) ([Required Plugin][skybot-lavalink-plugin]) +- ![Reddit](https://img.shields.io/badge/Reddit-FF4500?style=plastic&logo=reddit&logoColor=white) ([Required Plugin][skybot-lavalink-plugin]) +- ![Getyarn](https://img.shields.io/badge/Getyarn-FF9000?style=plastic&logo=getyarn&logoColor=white) ([Required Plugin][skybot-lavalink-plugin]) +- ![TikTok](https://img.shields.io/badge/TikTok-FF2D55?style=plastic&logo=tiktok&logoColor=white) ([Required Plugin][skybot-lavalink-plugin]) +- ![Soundgasm](https://img.shields.io/badge/Soundgasm-F1672F?style=plastic&logo=soundgasm&logoColor=white) ([Required Plugin][skybot-lavalink-plugin]) +- ![Text To Speech](https://img.shields.io/badge/Text%20To%20Speech-3080ff?style=plastic&logo=google-translate&logoColor=white) ([Required Plugin][skybot-lavalink-plugin]) [LavaSry]: https://github.com/TopiSenpai/LavaSrc [skybot-lavalink-plugin]: https://github.com/DuncteBot/skybot-lavalink-plugin @@ -79,29 +79,29 @@
Click to View Commands -| Name | Description | Options | -|-------------|------------------------------------------|-------------------------------------------| -| `prefix` | Shows the bot's prefix | | -| `help` | Shows the help menu | `command`: The command you want to get info | -| | | on | -| `info` | Shows information about the bot | | -| `invite` | Sends the bot's invite link | | -| `ping` | Shows the bot's ping | | -| `clearqueue` | Clears the queue | | -| `join` | Joins the voice channel | | -| `leave` | Leaves the voice channel | | -| `nowplaying` | Shows the currently playing song | | -| `play` | Plays a song from YouTube or Spotify | `song`: The song you want to play | -| `pause` | Pauses the current song | | -| `queue` | Shows the current queue | | -| `remove` | Removes a song from the queue | `song`: The song number | -| `resume` | Resumes the current song | | -| `seek` | Seeks to a certain time in the song | | -| `shuffle` | Shuffles the queue | | -| `skip` | Skips the current song | | -| `skipto` | Skips to a specific song in the queue | | -| `stop` | Stops the music and clears the queue | | -| `volume` | Sets the volume of the player | `number`: The volume you want to set | +| Name | Description | Options | +| ------------ | ------------------------------------- | ------------------------------------------- | +| `prefix` | Shows the bot's prefix | | +| `help` | Shows the help menu | `command`: The command you want to get info | +| | | on | +| `info` | Shows information about the bot | | +| `invite` | Sends the bot's invite link | | +| `ping` | Shows the bot's ping | | +| `clearqueue` | Clears the queue | | +| `join` | Joins the voice channel | | +| `leave` | Leaves the voice channel | | +| `nowplaying` | Shows the currently playing song | | +| `play` | Plays a song from YouTube or Spotify | `song`: The song you want to play | +| `pause` | Pauses the current song | | +| `queue` | Shows the current queue | | +| `remove` | Removes a song from the queue | `song`: The song number | +| `resume` | Resumes the current song | | +| `seek` | Seeks to a certain time in the song | | +| `shuffle` | Shuffles the queue | | +| `skip` | Skips the current song | | +| `skipto` | Skips to a specific song in the queue | | +| `stop` | Stops the music and clears the queue | | +| `volume` | Sets the volume of the player | `number`: The volume you want to set |
@@ -109,16 +109,16 @@ Before starting with the installation, you need to have the following: -- ![Node.js](https://img.shields.io/badge/Node.js-43853D?style=for-the-badge&logo=node.js&logoColor=white) [v18.17.1 or higher](https://nodejs.org/en/download/) -- ![MongoDB](https://img.shields.io/badge/MongoDB-4EA94B?style=for-the-badge&logo=mongodb&logoColor=white) [v4.4.0 or higher](https://www.mongodb.com/try/download/community) -- ![Lavalink](https://img.shields.io/badge/Lavalink-7289DA?style=for-the-badge&logo=discord&logoColor=white) [v3.7.8 or higher](https://github.com/freyacodes/Lavalink) +- ![Node.js](https://img.shields.io/badge/Node.js-43853D?style=for-the-badge&logo=node.js&logoColor=white) [v18.17.1 or higher](https://nodejs.org/en/download/) +- ![MongoDB](https://img.shields.io/badge/MongoDB-4EA94B?style=for-the-badge&logo=mongodb&logoColor=white) [v4.4.0 or higher](https://www.mongodb.com/try/download/community) +- ![Lavalink](https://img.shields.io/badge/Lavalink-7289DA?style=for-the-badge&logo=discord&logoColor=white) [v3.7.8 or higher](https://github.com/freyacodes/Lavalink) ## 🚀 Installation from source 1. Clone the Lavamusic repository: - ```bash - git clone https://github.com/brblacky/lavamusic.git +```bash +git clone https://github.com/brblacky/lavamusic.git ``` 2. change the directory to Lavamusic @@ -137,7 +137,7 @@ npm i Create a `.env` file in the root directory of your project with the following variables: - ```bash +```bash TOKEN="." # Your bot token PREFIX="!" # Your prefix OWNER_IDS="859640640640640640, 859640640640640640" # Your ID @@ -166,16 +166,16 @@ generator client { } ``` - and then run this command +and then run this command - ```bash - npx prisma generate +```bash +npx prisma generate ``` 6. Run the bot: - ```bash - npm run start or npm start +```bash +npm run start or npm start ``` 7. Invite the bot to your server: @@ -232,13 +232,13 @@ Do note that the bot will restart itself to update to the latest! ## 🔗 Useful Links -- ![Node.js](https://img.shields.io/badge/Node.js-43853D?style=for-the-badge&logo=node.js&logoColor=white) [Node.js](https://nodejs.org/en/download/) -- ![Discord.js](https://img.shields.io/badge/Discord.js-7289DA?style=for-the-badge&logo=discord&logoColor=white) [Discord.js](https://discord.js.org/#/) -- ![Prisma](https://img.shields.io/badge/Prisma-1B222D?style=for-the-badge&logo=prisma&logoColor=white) [Prisma](https://www.prisma.io/) -- ![Lavalink](https://img.shields.io/badge/Lavalink-7289DA?style=for-the-badge&logo=discord&logoColor=white) [Lavalink](https://github.com/freyacodes/Lavalink) -- ![MongoDB](https://img.shields.io/badge/MongoDB-4EA94B?style=for-the-badge&logo=mongodb&logoColor=white) [MongoDB](https://www.mongodb.com/) -- ![Docker](https://img.shields.io/badge/Docker-2496ED?style=for-the-badge&logo=docker&logoColor=white) [Docker](https://www.docker.com/) -- ![Docker-Compose](https://img.shields.io/badge/Docker--Compose-2496ED?style=for-the-badge&logo=docker&logoColor=white) [Docker-Compose](https://docs.docker.com/compose/) +- ![Node.js](https://img.shields.io/badge/Node.js-43853D?style=for-the-badge&logo=node.js&logoColor=white) [Node.js](https://nodejs.org/en/download/) +- ![Discord.js](https://img.shields.io/badge/Discord.js-7289DA?style=for-the-badge&logo=discord&logoColor=white) [Discord.js](https://discord.js.org/#/) +- ![Prisma](https://img.shields.io/badge/Prisma-1B222D?style=for-the-badge&logo=prisma&logoColor=white) [Prisma](https://www.prisma.io/) +- ![Lavalink](https://img.shields.io/badge/Lavalink-7289DA?style=for-the-badge&logo=discord&logoColor=white) [Lavalink](https://github.com/freyacodes/Lavalink) +- ![MongoDB](https://img.shields.io/badge/MongoDB-4EA94B?style=for-the-badge&logo=mongodb&logoColor=white) [MongoDB](https://www.mongodb.com/) +- ![Docker](https://img.shields.io/badge/Docker-2496ED?style=for-the-badge&logo=docker&logoColor=white) [Docker](https://www.docker.com/) +- ![Docker-Compose](https://img.shields.io/badge/Docker--Compose-2496ED?style=for-the-badge&logo=docker&logoColor=white) [Docker-Compose](https://docs.docker.com/compose/) ## 📝 Tutorial diff --git a/docker-compose.yml b/docker-compose.yml index 80c352333..aaa6e29cf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,65 +1,65 @@ services: - mongodb: - container_name: lavamusic-mongodb - # higher versions don't work on Apple Silicon - image: "bitnami/mongodb:4.4" - environment: - MONGODB_ADVERTISED_HOSTNAME: 127.0.0.1 - MONGODB_REPLICA_SET_MODE: primary - MONGODB_ROOT_USER: mongoadmin - MONGODB_ROOT_PASSWORD: mongopassword - MONGODB_REPLICA_SET_KEY: replicasetkey123 - restart: on-failure - volumes: - - mongodb_data:/data/db - lavalink: - container_name: lavamusic-lavalink - image: ghcr.io/lavalink-devs/lavalink - environment: - SERVER_PORT: 2333 - SERVER_ADDRESS: 0.0.0.0 - LAVALINK_SERVER_PASSWORD: "youshallnotpass" - LAVALINK_SERVER_SOURCES_YOUTUBE: "true" - LAVALINK_SERVER_SOURCES_BANDCAMP: "true" - LAVALINK_SERVER_SOURCES_SOUNDCLOUD: "true" - LAVALINK_SERVER_SOURCES_TWITCH: "true" - LAVALINK_SERVER_SOURCES_VIMEO: "true" - LAVALINK_SERVER_SOURCES_HTTP: "true" - LAVALINK_SERVER_SOURCES_LOCAL: "false" - LAVALINK_SERVER_BUFFER_DURATION_MS: 400 - LAVALINK_SERVER_FRAME_BUFFER_DURATIONS_MS: 5000 - LAVALINK_SERVER_TRACK_STRUCK_THRESHOLD_MS: 10000 - LAVALINK_SERVER_YOUTUBE_PLAYLIST_LOAD_LIMIT: 6 - LAVALINK_SERVER_PLAYER_UPDATE_INTERVAL: 5 - LAVALINK_SERVER_YOUTUBE_SEARCH_ENABLED: "true" - LAVALINK_SERVER_SOUNDCLOUD_SEARCH_ENABLED: "true" - #LAVALINK_SERVER_YOUTUBE_CONFIG_EMAIL: - #LAVALINK_SERVER_YOUTUBE_CONFIG_PASSWORD: - LAVALINK_SERVER_SENTRY_DSN: "" - volumes: - - ./plugins/:/opt/Lavalink/plugins/ # persist plugins between restarts, make sure to set the correct permissions (user: 322, group: 322) - restart: on-failure - lavamusic: - container_name: lavamusic - image: ghcr.io/brblacky/lavamusic:main - environment: - TOKEN: "your bot token" # Your bot token - PREFIX: "your bot prefix" # Your bot prefix - OWNER_IDS: "your id" # Your id - CLIENT_ID: "your bot id" # Your bot id - GUILD_ID: "" # Your server Id if you want to use the for single server - PRODUCTION: "true" # true for production - SEARCH_ENGINE: "ytsearch" # ytsearch, scsearch or ytmsearch - MAX_PLAYLIST_SIZE: "100" # Max playlist size - MAX_QUEUE_SIZE: "100" # Max queue size - DATABASE_URL: "mongodb://mongoadmin:mongopassword@mongodb/lavamusic?authSource=admin&directConnection=true" # Your mongodb url - LAVALINK_URL: "lavalink:2333" # Your lavalink url - LAVALINK_AUTH: "youshallnotpass" # Your lavalink password - LAVALINK_NAME: "Blacky" # Your lavalink name - LAVALINK_SECURE: "false" # true if you are using https - restart: on-failure - depends_on: - - lavalink - - mongodb + mongodb: + container_name: lavamusic-mongodb + # higher versions don't work on Apple Silicon + image: 'bitnami/mongodb:4.4' + environment: + MONGODB_ADVERTISED_HOSTNAME: 127.0.0.1 + MONGODB_REPLICA_SET_MODE: primary + MONGODB_ROOT_USER: mongoadmin + MONGODB_ROOT_PASSWORD: mongopassword + MONGODB_REPLICA_SET_KEY: replicasetkey123 + restart: on-failure + volumes: + - mongodb_data:/data/db + lavalink: + container_name: lavamusic-lavalink + image: ghcr.io/lavalink-devs/lavalink + environment: + SERVER_PORT: 2333 + SERVER_ADDRESS: 0.0.0.0 + LAVALINK_SERVER_PASSWORD: 'youshallnotpass' + LAVALINK_SERVER_SOURCES_YOUTUBE: 'true' + LAVALINK_SERVER_SOURCES_BANDCAMP: 'true' + LAVALINK_SERVER_SOURCES_SOUNDCLOUD: 'true' + LAVALINK_SERVER_SOURCES_TWITCH: 'true' + LAVALINK_SERVER_SOURCES_VIMEO: 'true' + LAVALINK_SERVER_SOURCES_HTTP: 'true' + LAVALINK_SERVER_SOURCES_LOCAL: 'false' + LAVALINK_SERVER_BUFFER_DURATION_MS: 400 + LAVALINK_SERVER_FRAME_BUFFER_DURATIONS_MS: 5000 + LAVALINK_SERVER_TRACK_STRUCK_THRESHOLD_MS: 10000 + LAVALINK_SERVER_YOUTUBE_PLAYLIST_LOAD_LIMIT: 6 + LAVALINK_SERVER_PLAYER_UPDATE_INTERVAL: 5 + LAVALINK_SERVER_YOUTUBE_SEARCH_ENABLED: 'true' + LAVALINK_SERVER_SOUNDCLOUD_SEARCH_ENABLED: 'true' + #LAVALINK_SERVER_YOUTUBE_CONFIG_EMAIL: + #LAVALINK_SERVER_YOUTUBE_CONFIG_PASSWORD: + LAVALINK_SERVER_SENTRY_DSN: '' + volumes: + - ./plugins/:/opt/Lavalink/plugins/ # persist plugins between restarts, make sure to set the correct permissions (user: 322, group: 322) + restart: on-failure + lavamusic: + container_name: lavamusic + image: ghcr.io/brblacky/lavamusic:main + environment: + TOKEN: 'your bot token' # Your bot token + PREFIX: 'your bot prefix' # Your bot prefix + OWNER_IDS: 'your id' # Your id + CLIENT_ID: 'your bot id' # Your bot id + GUILD_ID: '' # Your server Id if you want to use the for single server + PRODUCTION: 'true' # true for production + SEARCH_ENGINE: 'ytsearch' # ytsearch, scsearch or ytmsearch + MAX_PLAYLIST_SIZE: '100' # Max playlist size + MAX_QUEUE_SIZE: '100' # Max queue size + DATABASE_URL: 'mongodb://mongoadmin:mongopassword@mongodb/lavamusic?authSource=admin&directConnection=true' # Your mongodb url + LAVALINK_URL: 'lavalink:2333' # Your lavalink url + LAVALINK_AUTH: 'youshallnotpass' # Your lavalink password + LAVALINK_NAME: 'Blacky' # Your lavalink name + LAVALINK_SECURE: 'false' # true if you are using https + restart: on-failure + depends_on: + - lavalink + - mongodb volumes: - mongodb_data: + mongodb_data: diff --git a/package.json b/package.json index c92f20544..f9230e690 100644 --- a/package.json +++ b/package.json @@ -1,87 +1,97 @@ { - "name": "lavamusic", - "version": "3.3.0", - "description": "LavaMusic is a music bot for Discord, written in JavaScript using the Discord.js, Typescript, Shoukaku (Lavalink) library.", - "main": "dist/index.js", - "type": "commonjs", - "scripts": { - "start": "npm run start:bot", - "prisma:generate": "npx prisma generate", - "start:bot": "npm run build && node dist/index.js", - "build": "tsc --project tsconfig.json", - "clean": "rm -rf dist" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/brblacky/lavamusic.git" - }, - "keywords": [ - "discord", - "music", - "bot", - "lavalink", - "shoukaku", - "lavamusic", - "typescript", - "prisma" - ], - "author": "blacky", - "license": "GPL-3.0", - "bugs": { - "url": "https://github.com/brblacky/lavamusic/issues" - }, - "homepage": "https://github.com/brblacky/lavamusic#readme", - "devDependencies": { - "@types/cors": "^2.8.13", - "@types/express": "^4.17.17", - "@types/express-session": "^1.17.7", - "@types/node": "^20.5.6", - "@types/passport": "^1.0.12", - "@types/passport-discord": "^0.1.6", - "@types/signale": "^1.4.4", - "prisma": "^5.2.0", - "ts-node": "^10.9.1", - "typescript": "^5.2.2" - }, - "dependencies": { - "@prisma/client": "^5.2.0", - "connect-mongo": "^5.0.0", - "discord.js": "^14.13.0", - "dotenv": "^16.3.1", - "express": "^4.18.2", - "express-session": "^1.17.3", - "passport": "^0.6.0", - "passport-discord": "^0.1.4", - "shoukaku": "^3.4.0", - "signale": "^1.4.0", - "socket.io": "^4.7.2", - "tslib": "^2.6.2", - "undici": "^5.23.0" - }, - "signale": { - "displayScope": true, - "displayBadge": true, - "displayDate": true, - "displayFilename": true, - "displayLabel": true, - "displayTimestamp": true, - "underlineLabel": true - }, - "jest": { - "moduleFileExtensions": [ - "js", - "json", - "ts" - ], - "rootDir": "src", - "testRegex": ".*\\.spec\\.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" + "name": "lavamusic", + "version": "3.3.0", + "description": "LavaMusic is a music bot for Discord, written in JavaScript using the Discord.js, Typescript, Shoukaku (Lavalink) library.", + "main": "dist/index.js", + "type": "commonjs", + "scripts": { + "start": "npm run start:bot", + "prisma:generate": "npx prisma generate", + "start:bot": "npm run build && node dist/index.js", + "build": "tsc --project tsconfig.json", + "clean": "rm -rf dist", + "lint": "eslint . --cache --ext .js,.jsx,.ts,.tsx", + "lint:fix": "eslint . --fix --cache --ext .js,.jsx,.ts,.tsx", + "format": "prettier --check .", + "format:fix": "prettier --write ." + }, + "repository": { + "type": "git", + "url": "git+https://github.com/brblacky/lavamusic.git" }, - "collectCoverageFrom": [ - "**/*.(t|j)s" + "keywords": [ + "discord", + "music", + "bot", + "lavalink", + "shoukaku", + "lavamusic", + "typescript", + "prisma" ], - "coverageDirectory": "../coverage", - "testEnvironment": "node" - } + "author": "blacky", + "license": "GPL-3.0", + "bugs": { + "url": "https://github.com/brblacky/lavamusic/issues" + }, + "homepage": "https://github.com/brblacky/lavamusic#readme", + "devDependencies": { + "@types/cors": "^2.8.15", + "@types/express": "^4.17.20", + "@types/express-session": "^1.17.9", + "@types/node": "^20.8.7", + "@types/passport": "^1.0.14", + "@types/passport-discord": "^0.1.10", + "@types/signale": "^1.4.6", + "@typescript-eslint/eslint-plugin": "^6.8.0", + "@typescript-eslint/parser": "^6.8.0", + "eslint": "^8.52.0", + "eslint-plugin-import": "^2.28.1", + "eslint-plugin-unicorn": "^48.0.1", + "prettier": "^3.0.3", + "prisma": "^5.4.2", + "ts-node": "^10.9.1", + "typescript": "^5.2.2" + }, + "dependencies": { + "@prisma/client": "^5.4.2", + "connect-mongo": "^5.1.0", + "discord.js": "^14.12.1", + "dotenv": "^16.3.1", + "express": "^4.18.2", + "express-session": "^1.17.3", + "passport": "^0.6.0", + "passport-discord": "^0.1.4", + "shoukaku": "^3.4.0", + "signale": "^1.4.0", + "socket.io": "^4.7.2", + "tslib": "^2.6.2", + "undici": "^5.26.4" + }, + "signale": { + "displayScope": true, + "displayBadge": true, + "displayDate": true, + "displayFilename": true, + "displayLabel": true, + "displayTimestamp": true, + "underlineLabel": true + }, + "jest": { + "moduleFileExtensions": [ + "js", + "json", + "ts" + ], + "rootDir": "src", + "testRegex": ".*\\.spec\\.ts$", + "transform": { + "^.+\\.(t|j)s$": "ts-jest" + }, + "collectCoverageFrom": [ + "**/*.(t|j)s" + ], + "coverageDirectory": "../coverage", + "testEnvironment": "node" + } } diff --git a/src/LavaClient.ts b/src/LavaClient.ts index 5e2fcc922..d356e3c6b 100644 --- a/src/LavaClient.ts +++ b/src/LavaClient.ts @@ -1,11 +1,27 @@ -import Lavamusic from './structures/Lavamusic'; import { ClientOptions, GatewayIntentBits } from 'discord.js'; +import child from 'node:child_process'; + +import { DiscordDashboard } from './api'; import config from './config'; -import { DiscordDashboard } from "./api"; -import child from "node:child_process"; -const { GuildMembers, MessageContent, GuildVoiceStates, GuildMessages, Guilds, GuildMessageTyping } = GatewayIntentBits; +import Lavamusic from './structures/Lavamusic'; + +const { + GuildMembers, + MessageContent, + GuildVoiceStates, + GuildMessages, + Guilds, + GuildMessageTyping, +} = GatewayIntentBits; const clientOptions: ClientOptions = { - intents: [Guilds, GuildMessages, MessageContent, GuildVoiceStates, GuildMembers, GuildMessageTyping], + intents: [ + Guilds, + GuildMessages, + MessageContent, + GuildVoiceStates, + GuildMembers, + GuildMessageTyping, + ], allowedMentions: { parse: ['users', 'roles'], repliedUser: false, @@ -29,7 +45,6 @@ if (config.dashboard.enable) { }); } - /** * Project: lavamusic * Author: Blacky diff --git a/src/api/controllers/guilds/GuildControllers.ts b/src/api/controllers/guilds/GuildControllers.ts index e782ae764..8bce7cd81 100644 --- a/src/api/controllers/guilds/GuildControllers.ts +++ b/src/api/controllers/guilds/GuildControllers.ts @@ -1,16 +1,16 @@ -import { Request, Response } from "express"; -import { getMutualGuildsService } from "../../services/guilds/GuildServices"; +import { Request, Response } from 'express'; +import { getMutualGuildsService } from '../../services/guilds/GuildServices'; -export async function getGuildController(req: Request, res: Response) { +export async function getGuildController(req: Request, res: Response): Promise { try { const user = req.user as any; const data = await getMutualGuildsService(user.id); - res.send({ - data: data + res.send({ + data: data, }); } catch (error) { console.log(error); - res.sendStatus(400).send({ error: "Bad Request" }); + res.sendStatus(400).send({ error: 'Bad Request' }); } -} \ No newline at end of file +} diff --git a/src/api/index.ts b/src/api/index.ts index 03a8c539b..76caa37c4 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,18 +1,20 @@ -import express, { Express, Request, Response, NextFunction } from 'express'; -import passport from "passport"; -import Logger from '../structures/Logger'; -import config from '../config'; +/* eslint-disable import/no-extraneous-dependencies */ +import mongoStore from 'connect-mongo'; import cors from 'cors'; +import express, { Express, Request, Response } from 'express'; import session from 'express-session'; -import DiscordPassportStrategy from './strategy/discord'; +import passport from 'passport'; + import MainRouter from './routes/MainRouter'; -import mongoStore from 'connect-mongo'; +import DiscordPassportStrategy from './strategy/discord'; +import config from '../config'; +import Logger from '../structures/Logger'; export class DiscordDashboard { private app: Express; public logger: Logger = new Logger(); public config = config; - private readonly discordStrategy: DiscordPassportStrategy + private readonly discordStrategy: DiscordPassportStrategy; public routes: MainRouter; constructor() { this.discordStrategy = new DiscordPassportStrategy(); @@ -20,44 +22,48 @@ export class DiscordDashboard { this.app.use(express.json()); this.app.use(express.urlencoded({ extended: true })); this.app.use(this.errorHandler.bind(this)); - this.app.use(cors({ - origin: config.dashboard.website, - credentials: true - })); - this.app.use(session({ - secret: config.dashboard.sessionSecret, - resave: false, - saveUninitialized: false, - cookie: { - secure: false, - httpOnly: false, - maxAge: 1000 * 60 * 60 * 24 * 7 - }, - store: mongoStore.create({ - mongoUrl: config.database, - collectionName: 'sessions', - dbName: 'lavamusic' + this.app.use( + cors({ + origin: config.dashboard.website, + credentials: true, + }) + ); + this.app.use( + session({ + secret: config.dashboard.sessionSecret, + resave: false, + saveUninitialized: false, + cookie: { + secure: false, + httpOnly: false, + maxAge: 1000 * 60 * 60 * 24 * 7, + }, + store: mongoStore.create({ + mongoUrl: config.database, + collectionName: 'sessions', + dbName: 'lavamusic', + }), }) - })); + ); this.app.use(passport.initialize()); this.app.use(passport.session()); this.createRoutes(); } - public get App() { + public get App(): Express { return this.app; } - public get Logger() { + public get Logger(): Logger { return this.logger; } - public createRoutes() { + public createRoutes(): void { this.routes = new MainRouter(); this.app.use('/api', this.routes.router); } - private errorHandler(err: Error, req: Request, res: Response, next: NextFunction) { + private errorHandler(err: Error, req: Request, res: Response): void { this.logger.error(err.stack); res.status(500).json({ error: err.message }); } - public async start() { + public async start(): Promise { try { this.app.listen(this.config.dashboard.port, () => { this.logger.info(`[API] listening on port ${this.config.dashboard.port}`); @@ -66,4 +72,4 @@ export class DiscordDashboard { this.logger.error(err); } } -} \ No newline at end of file +} diff --git a/src/api/middlewares/Middlewares.ts b/src/api/middlewares/Middlewares.ts index 429e9cff9..86f0291b1 100644 --- a/src/api/middlewares/Middlewares.ts +++ b/src/api/middlewares/Middlewares.ts @@ -1,6 +1,6 @@ -import { Request, Response, NextFunction } from 'express'; +import { NextFunction, Request, Response } from 'express'; -export const IsAuth = (req: Request, res: Response, next: NextFunction) => { +export const IsAuth = (req: Request, res: Response, next: NextFunction): void => { if (req.user) { next(); } else { diff --git a/src/api/routes/MainRouter.ts b/src/api/routes/MainRouter.ts index 77e8fb1c6..c2cde9cf9 100644 --- a/src/api/routes/MainRouter.ts +++ b/src/api/routes/MainRouter.ts @@ -1,7 +1,8 @@ -import express, { Router } from "express"; -import AuthRouter from "./auth/AuthRouter"; -import GuildsRouter from "./guilds/GuildsRouter"; -import GuildRouter from "./guilds/GuildRouter"; +import express, { Router } from 'express'; + +import AuthRouter from './auth/AuthRouter'; +import GuildRouter from './guilds/GuildRouter'; +import GuildsRouter from './guilds/GuildsRouter'; export default class MainRouter { public router: Router; @@ -10,10 +11,9 @@ export default class MainRouter { this.router = express.Router(); this.initializeRoutes(); } - private initializeRoutes() { - this.router.use("/auth", AuthRouter); - this.router.use("/guilds", GuildsRouter); - this.router.use("/guild", GuildRouter); + private initializeRoutes(): void { + this.router.use('/auth', AuthRouter); + this.router.use('/guilds', GuildsRouter); + this.router.use('/guild', GuildRouter); } } - diff --git a/src/api/routes/auth/AuthRouter.ts b/src/api/routes/auth/AuthRouter.ts index 29b6296a3..04ffd66d5 100644 --- a/src/api/routes/auth/AuthRouter.ts +++ b/src/api/routes/auth/AuthRouter.ts @@ -1,6 +1,8 @@ -import { Router, Request, Response } from "express"; -import passport from "passport"; -import config from "../../../config"; +/* eslint-disable @typescript-eslint/unbound-method */ +import { Request, Response, Router } from 'express'; +import passport from 'passport'; + +import config from '../../../config'; class AuthRouter { public router: Router; @@ -8,31 +10,33 @@ class AuthRouter { this.router = Router(); this.initializeRoutes(); } - private initializeRoutes() { - this.router.get("/", this.getHello); - this.router.get("/login", passport.authenticate("discord"), (req, res) => { + private initializeRoutes(): void { + this.router.get('/', this.getHello); + this.router.get('/login', passport.authenticate('discord'), (req, res) => { res.sendStatus(200); }); - this.router.get("/logout", (req, res, next) => { - req.logout(function (err) { - if (err) { return next(err); } + this.router.get('/logout', (req, res, next) => { + req.logout(function (err: any) { + if (err) { + return next(err); + } res.redirect(`${config.dashboard.website}/`); }); }); - this.router.get("/redirect", passport.authenticate("discord"), (req, res) => { + this.router.get('/redirect', passport.authenticate('discord'), (req, res) => { res.redirect(`${config.dashboard.website}/dashboard`); }); - this.router.get("/me", this.getLogin); + this.router.get('/me', this.getLogin); } - private getHello(req: Request, res: Response) { - res.json({ message: "lavamusic api v1 made by devblacky" }); + private getHello(req: Request, res: Response): void { + res.json({ message: 'lavamusic api v1 made by devblacky' }); } - private async getLogin(req: Request, res: Response) { - return req.user ? res.send(req.user) : res.sendStatus(401).send({ error: "Unauthorized" }); + private async getLogin(req: Request, res: Response): Promise { + return req.user ? res.send(req.user) : res.sendStatus(401).send({ error: 'Unauthorized' }); } } const authRouter = new AuthRouter(); -export default authRouter.router; \ No newline at end of file +export default authRouter.router; diff --git a/src/api/routes/guilds/GuildRouter.ts b/src/api/routes/guilds/GuildRouter.ts index f57c88b70..c737d6247 100644 --- a/src/api/routes/guilds/GuildRouter.ts +++ b/src/api/routes/guilds/GuildRouter.ts @@ -1,8 +1,9 @@ -import { Router, Request, Response } from "express"; -import { IsAuth } from "../../middlewares/Middlewares"; -import { getGuild, getGuildMembers } from "../../services/guilds/GuildServices"; -import ServerData from "../../../database/server"; +/* eslint-disable @typescript-eslint/unbound-method */ +import { Request, Response, Router } from 'express'; +import ServerData from '../../../database/server'; +import { IsAuth } from '../../middlewares/Middlewares'; +import { getGuild, getGuildMembers } from '../../services/guilds/GuildServices'; class GuildRouter { public router: Router; @@ -10,25 +11,25 @@ class GuildRouter { this.router = Router(); this.initializeRoutes(); } - private initializeRoutes() { - this.router.get("/:id", IsAuth, this.getGuild); - this.router.get("/:id/members", IsAuth, this.getGuildsMembers); - this.router.put("/:id/prefix", IsAuth, this.updateGuildPrefix); + private initializeRoutes(): void { + this.router.get('/:id', IsAuth, this.getGuild); + this.router.get('/:id/members', IsAuth, this.getGuildsMembers); + this.router.put('/:id/prefix', IsAuth, this.updateGuildPrefix); } - private async getGuild(req: Request, res: Response) { + private async getGuild(req: Request, res: Response): Promise { const guild = await getGuild(req.params.id); return res.send(guild); } - private async getGuildsMembers(req: Request, res: Response) { + private async getGuildsMembers(req: Request, res: Response): Promise { const guild = await getGuildMembers(req.params.id); return res.send(guild); } - private async updateGuildPrefix(req: Request, res: Response) { + private async updateGuildPrefix(req: Request, res: Response): Promise { await ServerData.setPrefix(req.params.id, req.body.prefix); return res.sendStatus(200); } } const guildRouter = new GuildRouter(); -export default guildRouter.router; \ No newline at end of file +export default guildRouter.router; diff --git a/src/api/routes/guilds/GuildsRouter.ts b/src/api/routes/guilds/GuildsRouter.ts index 48e5e8038..7a75bd2c4 100644 --- a/src/api/routes/guilds/GuildsRouter.ts +++ b/src/api/routes/guilds/GuildsRouter.ts @@ -1,7 +1,7 @@ -import { Router, Request, Response } from "express"; -import { IsAuth } from "../../middlewares/Middlewares"; -import { getGuildController } from "../../controllers/guilds/GuildControllers"; +import { Request, Response, Router } from 'express'; +import { getGuildController } from '../../controllers/guilds/GuildControllers'; +import { IsAuth } from '../../middlewares/Middlewares'; class GuildsRouter { public router: Router; @@ -10,9 +10,9 @@ class GuildsRouter { this.initializeRoutes(); } private initializeRoutes() { - this.router.get("/", IsAuth, getGuildController); + this.router.get('/', IsAuth, getGuildController); } } const guildsRouter = new GuildsRouter(); -export default guildsRouter.router; \ No newline at end of file +export default guildsRouter.router; diff --git a/src/api/services/guilds/GuildServices.ts b/src/api/services/guilds/GuildServices.ts index f096d2131..fc405f6ac 100644 --- a/src/api/services/guilds/GuildServices.ts +++ b/src/api/services/guilds/GuildServices.ts @@ -1,60 +1,69 @@ -import { DISCORD_API_URL } from "../../types/types"; -import config from "../../../config"; -import { PrismaClient } from "@prisma/client"; -import { fetch } from "undici"; +import { PrismaClient } from '@prisma/client'; +import { fetch } from 'undici'; +import config from '../../../config'; +import { DISCORD_API_URL } from '../../types/types'; const prisma = new PrismaClient(); -export async function getBotGuildsService() { +export async function getBotGuildsService(): Promise { return await fetchRequest(`${DISCORD_API_URL}/users/@me/guilds`, `Bot ${config.token}`); } -export async function getUserGuildsService(id: string) { +export async function getUserGuildsService(id: string): Promise { const user = await prisma.user.findFirst({ where: { - id: id - } + id: id, + }, }); return await fetchRequest(`${DISCORD_API_URL}/users/@me/guilds`, `Bearer ${user.accessToken}`); } -export async function getMutualGuildsService(id: string) { - const botGuilds = await getBotGuildsService(); +export async function getMutualGuildsService(id: string): Promise { + const botGuilds = await getBotGuildsService(); const userGuilds = await getUserGuildsService(id); - const adminUserGuilds = userGuilds.filter(({ permissions }) => (parseInt(permissions) & 0x8) === 0x8); - return adminUserGuilds.filter((guild) => { - return botGuilds.some((botGuild) => botGuild.id === guild.id); + const adminUserGuilds = userGuilds.filter( + ({ permissions }) => (parseInt(permissions) & 0x8) === 0x8 + ); + return adminUserGuilds.filter(guild => { + return botGuilds.some(botGuild => botGuild.id === guild.id); }); } -export async function getGuild(guildId: string) { +export async function getGuild(guildId: string): Promise { return await fetchRequest(`${DISCORD_API_URL}/guilds/${guildId}`, `Bot ${config.token}`); } -export async function getGuildChannels(guildId: string) { - return await fetchRequest(`${DISCORD_API_URL}/guilds/${guildId}/channels`, `Bot ${config.token}`); +export async function getGuildChannels(guildId: string): Promise { + return await fetchRequest( + `${DISCORD_API_URL}/guilds/${guildId}/channels`, + `Bot ${config.token}` + ); } -export async function getGuildRoles(guildId: string) { +export async function getGuildRoles(guildId: string): Promise { return await fetchRequest(`${DISCORD_API_URL}/guilds/${guildId}/roles`, `Bot ${config.token}`); } -export async function getGuildMembers(guildId: string) { - return await fetchRequest(`${DISCORD_API_URL}/guilds/${guildId}/members`, `Bot ${config.token}`); +export async function getGuildMembers(guildId: string): Promise { + return await fetchRequest( + `${DISCORD_API_URL}/guilds/${guildId}/members`, + `Bot ${config.token}` + ); } -export async function getGuildMember(guildId: string, userId: string) { - return await fetchRequest(`${DISCORD_API_URL}/guilds/${guildId}/members/${userId}`, `Bot ${config.token}`); +export async function getGuildMember(guildId: string, userId: string): Promise { + return await fetchRequest( + `${DISCORD_API_URL}/guilds/${guildId}/members/${userId}`, + `Bot ${config.token}` + ); } -export async function fetchRequest(url: string, auth): Promise { +export async function fetchRequest(url: string, auth: string): Promise { const response = await fetch(url, { - method: "GET", + method: 'GET', headers: { - Authorization: auth - } + Authorization: auth, + }, }); return await response.json(); } - - diff --git a/src/api/strategy/discord.ts b/src/api/strategy/discord.ts index 01d53993c..3d364d9df 100644 --- a/src/api/strategy/discord.ts +++ b/src/api/strategy/discord.ts @@ -1,9 +1,10 @@ -import { Strategy as DiscordStrategy, Profile } from "passport-discord"; -import passport from "passport"; -import config from "../../config"; -import { VerifyCallback } from "passport-oauth2"; -import { PrismaClient } from "@prisma/client"; +import { PrismaClient } from '@prisma/client'; +import passport from 'passport'; +import { Strategy as DiscordStrategy, Profile } from 'passport-discord'; +// eslint-disable-next-line import/no-extraneous-dependencies +import { VerifyCallback } from 'passport-oauth2'; +import config from '../../config'; export default class DiscordPassportStrategy { private prisma = new PrismaClient(); @@ -11,7 +12,7 @@ export default class DiscordPassportStrategy { this.initializeStrategy(); } - initializeStrategy() { + initializeStrategy(): void { passport.serializeUser((user: any, done) => { done(null, user.id); }); @@ -19,8 +20,8 @@ export default class DiscordPassportStrategy { try { const user = await this.prisma.user.findFirst({ where: { - id: id - } + id: id, + }, }); return user ? done(null, user) : done(null, null); } catch (error) { @@ -28,15 +29,25 @@ export default class DiscordPassportStrategy { done(error, null); } }); - passport.use(new DiscordStrategy({ - clientID: config.clientId, - clientSecret: config.clientSecret, - callbackURL: config.dashboard.redirectUri, - scope: ["identify", "guilds"], - }, this.verifyCallback.bind(this))); + passport.use( + new DiscordStrategy( + { + clientID: config.clientId, + clientSecret: config.clientSecret, + callbackURL: config.dashboard.redirectUri, + scope: ['identify', 'guilds'], + }, + this.verifyCallback.bind(this) + ) + ); } - async verifyCallback(accessToken: string, refreshToken: string, profile: Profile, done: VerifyCallback) { + async verifyCallback( + accessToken: string, + refreshToken: string, + profile: Profile, + done: VerifyCallback + ): Promise { const { id: userId, username, discriminator, avatar } = profile; let existingUser = await this.prisma.user.findFirst({ where: { @@ -65,8 +76,8 @@ export default class DiscordPassportStrategy { discriminator: discriminator, avatar: avatar, accessToken: accessToken, - refreshToken: refreshToken - } + refreshToken: refreshToken, + }, }); return done(null, newUser); } @@ -76,4 +87,3 @@ export default class DiscordPassportStrategy { } } } - diff --git a/src/api/types/types.ts b/src/api/types/types.ts index 9f87f4caa..9512a2ae1 100644 --- a/src/api/types/types.ts +++ b/src/api/types/types.ts @@ -1,3 +1 @@ - export const DISCORD_API_URL = 'https://discord.com/api/v10'; - diff --git a/src/commands/config/247.ts b/src/commands/config/247.ts index ff846dd22..588af40d2 100644 --- a/src/commands/config/247.ts +++ b/src/commands/config/247.ts @@ -1,62 +1,75 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; import ServerData from '../../database/server'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class _247 extends Command { - constructor(client: Lavamusic) { - super(client, { - name: '247', - description: { - content: 'set the bot to stay in the vc', - examples: ['247'], - usage: '247', - }, - category: 'config', - aliases: ['stay'], - cooldown: 3, - args: false, - player: { - voice: true, - dj: false, - active: false, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: ['ManageGuild'], - }, - slashCommand: true, - options: [], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const embed = client.embed(); - let player = client.shoukaku.players.get(ctx.guild.id) as any; + constructor(client: Lavamusic) { + super(client, { + name: '247', + description: { + content: 'set the bot to stay in the vc', + examples: ['247'], + usage: '247', + }, + category: 'config', + aliases: ['stay'], + cooldown: 3, + args: false, + player: { + voice: true, + dj: false, + active: false, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: ['ManageGuild'], + }, + slashCommand: true, + options: [], + }); + } + public async run(client: Lavamusic, ctx: Context): Promise { + const embed = client.embed(); + let player = client.shoukaku.players.get(ctx.guild.id) as any; - const data = await client.prisma.stay.findFirst({ - where: { - guildId: ctx.guild.id, - }, - }); - const vc = ctx.member as any; - if (!data) { - await ServerData.set_247(ctx.guild.id, ctx.channel.id, vc.voice.channelId); - if (!player) - player = await client.queue.create(ctx.guild, vc.voice.channel, ctx.channel, client.shoukaku.getNode()); - return ctx.sendMessage({ - embeds: [embed.setDescription(`**247 mode has been enabled**`).setColor(client.color.main)], - }); - } else { - await client.prisma.stay.delete({ - where: { - guildId: ctx.guild.id, - }, - }); - return ctx.sendMessage({ - embeds: [embed.setDescription(`**247 mode has been disabled**`).setColor(client.color.red)], - }); + const data = await client.prisma.stay.findFirst({ + where: { + guildId: ctx.guild.id, + }, + }); + const vc = ctx.member as any; + if (!data) { + await ServerData.set_247(ctx.guild.id, ctx.channel.id, vc.voice.channelId); + if (!player) + player = await client.queue.create( + ctx.guild, + vc.voice.channel, + ctx.channel, + client.shoukaku.getNode() + ); + return await ctx.sendMessage({ + embeds: [ + embed + .setDescription(`**247 mode has been enabled**`) + .setColor(client.color.main), + ], + }); + } else { + await client.prisma.stay.delete({ + where: { + guildId: ctx.guild.id, + }, + }); + return await ctx.sendMessage({ + embeds: [ + embed + .setDescription(`**247 mode has been disabled**`) + .setColor(client.color.red), + ], + }); + } } - } } /** diff --git a/src/commands/config/Dj.ts b/src/commands/config/Dj.ts index d1910d7a2..6583da83c 100644 --- a/src/commands/config/Dj.ts +++ b/src/commands/config/Dj.ts @@ -1,164 +1,174 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; import { ApplicationCommandOptionType } from 'discord.js'; + import ServerData from '../../database/server'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Dj extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'dj', - description: { - content: "Manage the DJ mode and associated roles", - examples: ['dj add @role', 'dj remove @role', 'dj clear', 'dj toggle'], - usage: 'dj', - }, - category: 'general', - aliases: ['dj'], - cooldown: 3, - args: true, - player: { - voice: false, - dj: false, - active: false, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: ['ManageGuild'], - }, - slashCommand: true, - options: [ - { - name: 'add', - description: 'The dj role you want to add', - type: ApplicationCommandOptionType.Subcommand, - options: [ - { - name: 'role', - description: 'The dj role you want to add', - type: ApplicationCommandOptionType.Role, - required: true, + constructor(client: Lavamusic) { + super(client, { + name: 'dj', + description: { + content: 'Manage the DJ mode and associated roles', + examples: ['dj add @role', 'dj remove @role', 'dj clear', 'dj toggle'], + usage: 'dj', }, - ], - }, - { - name: 'remove', - description: 'The dj role you want to remove', - type: ApplicationCommandOptionType.Subcommand, - options: [ - { - name: 'role', - description: 'The dj role you want to remove', - type: ApplicationCommandOptionType.Role, - required: true, + category: 'general', + aliases: ['dj'], + cooldown: 3, + args: true, + player: { + voice: false, + dj: false, + active: false, + djPerm: null, }, - ], - }, - { - name: 'clear', - description: 'Clears all dj roles', - type: ApplicationCommandOptionType.Subcommand, - }, - { - name: 'toggle', - description: 'Toggles the dj role', - type: ApplicationCommandOptionType.Subcommand, - }, - ], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - let subCommand: string | any; - let role: any; - if (ctx.isInteraction) { - subCommand = ctx.interaction.options.data[0].name; - if (subCommand === 'add' || subCommand === 'remove') { - role = ctx.interaction.options.data[0].options[0].role; - } - } else { - subCommand = args[0]; - role = ctx.message.mentions.roles.first() || ctx.guild.roles.cache.get(args[1]); - } - const embed = client.embed().setColor(client.color.main); - let dj = await this.client.prisma.dj.findUnique({ - where: { guildId: ctx.guild.id }, - }); - if (subCommand === 'add') { - if (!role) - return await ctx.sendMessage({ - embeds: [embed.setDescription('Please provide a role to add')], + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: ['ManageGuild'], + }, + slashCommand: true, + options: [ + { + name: 'add', + description: 'The dj role you want to add', + type: ApplicationCommandOptionType.Subcommand, + options: [ + { + name: 'role', + description: 'The dj role you want to add', + type: ApplicationCommandOptionType.Role, + required: true, + }, + ], + }, + { + name: 'remove', + description: 'The dj role you want to remove', + type: ApplicationCommandOptionType.Subcommand, + options: [ + { + name: 'role', + description: 'The dj role you want to remove', + type: ApplicationCommandOptionType.Role, + required: true, + }, + ], + }, + { + name: 'clear', + description: 'Clears all dj roles', + type: ApplicationCommandOptionType.Subcommand, + }, + { + name: 'toggle', + description: 'Toggles the dj role', + type: ApplicationCommandOptionType.Subcommand, + }, + ], }); - const isExRole = await this.client.prisma.roles.findFirst({ - where: { roleId: role.id }, - }); - if (isExRole) - return await ctx.sendMessage({ - embeds: [embed.setDescription(`The dj role <@&${role.id}> is already added`)], + } + public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { + let subCommand: string; + let role: any; + if (ctx.isInteraction) { + subCommand = ctx.interaction.options.data[0].name; + if (subCommand === 'add' || subCommand === 'remove') { + role = ctx.interaction.options.data[0].options[0].role; + } + } else { + subCommand = args[0]; + role = ctx.message.mentions.roles.first() || ctx.guild.roles.cache.get(args[1]); + } + const embed = client.embed().setColor(client.color.main); + let dj = await this.client.prisma.dj.findUnique({ + where: { guildId: ctx.guild.id }, }); + if (subCommand === 'add') { + if (!role) + return await ctx.sendMessage({ + embeds: [embed.setDescription('Please provide a role to add')], + }); + const isExRole = await this.client.prisma.roles.findFirst({ + where: { roleId: role.id }, + }); + if (isExRole) + return await ctx.sendMessage({ + embeds: [embed.setDescription(`The dj role <@&${role.id}> is already added`)], + }); - if (!dj) { - await ServerData.setDj(ctx.guild.id, role.id); - return await ctx.sendMessage({ - embeds: [embed.setDescription(`The dj role <@&${role.id}> has been added`)], - }); - } else { - await ServerData.setDj(ctx.guild.id, role.id); - return await ctx.sendMessage({ - embeds: [embed.setDescription(`The dj role <@&${role.id}> has been added`)], - }); - } - } else if (subCommand === 'remove') { - if (!role) - return await ctx.sendMessage({ - embeds: [embed.setDescription('Please provide a role to remove')], - }); - const isExRole = await this.client.prisma.roles.findFirst({ - where: { roleId: role.id }, - }); - if (!isExRole) - return await ctx.sendMessage({ - embeds: [embed.setDescription(`The dj role <@&${role.id}> is not added`)], - }); - await this.client.prisma.roles.delete({ where: { roleId: role.id } }); - return await ctx.sendMessage({ - embeds: [embed.setDescription(`The dj role <@&${role.id}> has been removed`)], - }); - } else if (subCommand === 'clear') { - if (!dj) - return await ctx.sendMessage({ - embeds: [embed.setDescription('There are no dj roles to clear')], - }); - await ServerData.setDj(ctx.guild.id); - return await ctx.sendMessage({ - embeds: [embed.setDescription(`All dj roles have been removed`)], - }); - } else if (subCommand === 'toggle') { - if (!dj) - return await ctx.sendMessage({ - embeds: [embed.setDescription('There are no dj roles to toggle')], - }); - const data = await this.client.prisma.dj.findUnique({ - where: { guildId: ctx.guild.id }, - }); - if (data) { - await this.client.prisma.dj.update({ - where: { - guildId: ctx.guild.id, - }, - data: { - mode: !data.mode, - }, - }); - return await ctx.sendMessage({ - embeds: [embed.setDescription(`The dj mode has been toggled to ${!data.mode ? 'enabled' : 'disabled'}`)], - }); - } - } else { - return await ctx.sendMessage({ - embeds: [embed.setDescription('Please provide a valid subcommand').addFields({ name: 'Subcommands', value: '`add`, `remove`, `clear`, `toggle`' })], - }); + if (!dj) { + await ServerData.setDj(ctx.guild.id, role.id); + return await ctx.sendMessage({ + embeds: [embed.setDescription(`The dj role <@&${role.id}> has been added`)], + }); + } else { + await ServerData.setDj(ctx.guild.id, role.id); + return await ctx.sendMessage({ + embeds: [embed.setDescription(`The dj role <@&${role.id}> has been added`)], + }); + } + } else if (subCommand === 'remove') { + if (!role) + return await ctx.sendMessage({ + embeds: [embed.setDescription('Please provide a role to remove')], + }); + const isExRole = await this.client.prisma.roles.findFirst({ + where: { roleId: role.id }, + }); + if (!isExRole) + return await ctx.sendMessage({ + embeds: [embed.setDescription(`The dj role <@&${role.id}> is not added`)], + }); + await this.client.prisma.roles.delete({ where: { roleId: role.id } }); + return await ctx.sendMessage({ + embeds: [embed.setDescription(`The dj role <@&${role.id}> has been removed`)], + }); + } else if (subCommand === 'clear') { + if (!dj) + return await ctx.sendMessage({ + embeds: [embed.setDescription('There are no dj roles to clear')], + }); + await ServerData.setDj(ctx.guild.id); + return await ctx.sendMessage({ + embeds: [embed.setDescription(`All dj roles have been removed`)], + }); + } else if (subCommand === 'toggle') { + if (!dj) + return await ctx.sendMessage({ + embeds: [embed.setDescription('There are no dj roles to toggle')], + }); + const data = await this.client.prisma.dj.findUnique({ + where: { guildId: ctx.guild.id }, + }); + if (data) { + await this.client.prisma.dj.update({ + where: { + guildId: ctx.guild.id, + }, + data: { + mode: !data.mode, + }, + }); + return await ctx.sendMessage({ + embeds: [ + embed.setDescription( + `The dj mode has been toggled to ${!data.mode ? 'enabled' : 'disabled'}` + ), + ], + }); + } + } else { + return await ctx.sendMessage({ + embeds: [ + embed.setDescription('Please provide a valid subcommand').addFields({ + name: 'Subcommands', + value: '`add`, `remove`, `clear`, `toggle`', + }), + ], + }); + } } - } } /** diff --git a/src/commands/config/Prefix.ts b/src/commands/config/Prefix.ts index 9e109d82e..b40c7d008 100644 --- a/src/commands/config/Prefix.ts +++ b/src/commands/config/Prefix.ts @@ -1,102 +1,124 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; import ServerData from '../../database/server'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Prefix extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'prefix', - description: { - content: "Shows the bot's prefix", - examples: ['prefix set', 'prefix reset', 'prefix set !'], - usage: 'prefix set, prefix reset, prefix set !', - }, - category: 'general', - aliases: ['prefix'], - cooldown: 3, - args: true, - player: { - voice: false, - dj: false, - active: false, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: ['ManageGuild'], - }, - slashCommand: true, - options: [ - { - name: 'set', - description: 'Sets the prefix', - type: 1, - options: [ - { - name: 'prefix', - description: 'The prefix you want to set', - type: 3, - required: true, + constructor(client: Lavamusic) { + super(client, { + name: 'prefix', + description: { + content: 'Shows the bot\'s prefix', + examples: ['prefix set', 'prefix reset', 'prefix set !'], + usage: 'prefix set, prefix reset, prefix set !', }, - ], - }, - { - name: 'reset', - description: 'Resets the prefix to the default one', - type: 1, - }, - ], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const embed = client.embed().setColor(client.color.main); - let prefix = await ServerData.get(ctx.guild.id); - - let subCommand: string; - let pre: string; - if (ctx.isInteraction) { - subCommand = ctx.interaction.options.data[0].name; - pre = ctx.interaction.options.data[0].options[0]?.value.toString(); - } else { - subCommand = args[0]; - pre = args[1]; + category: 'general', + aliases: ['prefix'], + cooldown: 3, + args: true, + player: { + voice: false, + dj: false, + active: false, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: ['ManageGuild'], + }, + slashCommand: true, + options: [ + { + name: 'set', + description: 'Sets the prefix', + type: 1, + options: [ + { + name: 'prefix', + description: 'The prefix you want to set', + type: 3, + required: true, + }, + ], + }, + { + name: 'reset', + description: 'Resets the prefix to the default one', + type: 1, + }, + ], + }); } - switch (subCommand) { - case 'set': - if (!pre) { - embed.setDescription(`The prefix for this server is \`${prefix ? prefix.prefix : client.config.prefix}\``); - return await ctx.sendMessage({ embeds: [embed] }); - } - if (pre.length > 3) - return await ctx.sendMessage({ - embeds: [embed.setDescription(`The prefix can't be longer than 3 characters`)], - }); + public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { + const embed = client.embed().setColor(client.color.main); + let prefix = await ServerData.get(ctx.guild.id); - if (!prefix) { - await ServerData.setPrefix(ctx.guild.id, pre); - prefix = await ServerData.get(ctx.guild.id); - return await ctx.sendMessage({ - embeds: [embed.setDescription(`The prefix for this server is now \`${prefix.prefix}\``)], - }); + let subCommand: string; + let pre: string; + if (ctx.isInteraction) { + subCommand = ctx.interaction.options.data[0].name; + pre = ctx.interaction.options.data[0].options[0]?.value.toString(); } else { - await ServerData.setPrefix(ctx.guild.id, pre); - prefix = await ServerData.get(ctx.guild.id); - return await ctx.sendMessage({ - embeds: [embed.setDescription(`The prefix for this server is now \`${prefix.prefix}\``)], - }); + subCommand = args[0]; + pre = args[1]; + } + switch (subCommand) { + case 'set': + if (!pre) { + embed.setDescription( + `The prefix for this server is \`${ + prefix ? prefix.prefix : client.config.prefix + }\`` + ); + return await ctx.sendMessage({ embeds: [embed] }); + } + if (pre.length > 3) + return await ctx.sendMessage({ + embeds: [ + embed.setDescription(`The prefix can't be longer than 3 characters`), + ], + }); + + if (!prefix) { + await ServerData.setPrefix(ctx.guild.id, pre); + prefix = await ServerData.get(ctx.guild.id); + return await ctx.sendMessage({ + embeds: [ + embed.setDescription( + `The prefix for this server is now \`${prefix.prefix}\`` + ), + ], + }); + } else { + await ServerData.setPrefix(ctx.guild.id, pre); + prefix = await ServerData.get(ctx.guild.id); + return await ctx.sendMessage({ + embeds: [ + embed.setDescription( + `The prefix for this server is now \`${prefix.prefix}\`` + ), + ], + }); + } + case 'reset': + if (!prefix) + return await ctx.sendMessage({ + embeds: [ + embed.setDescription( + `The prefix for this server is \`${client.config.prefix}\`` + ), + ], + }); + await ServerData.setPrefix(ctx.guild.id, client.config.prefix); + prefix = await ServerData.get(ctx.guild.id); + return await ctx.sendMessage({ + embeds: [ + embed.setDescription( + `The prefix for this server is now \`${client.config.prefix}\`` + ), + ], + }); } - case 'reset': - if (!prefix) - return await ctx.sendMessage({ - embeds: [embed.setDescription(`The prefix for this server is \`${client.config.prefix}\``)], - }); - await ServerData.setPrefix(ctx.guild.id, client.config.prefix); - prefix = await ServerData.get(ctx.guild.id); - return await ctx.sendMessage({ - embeds: [embed.setDescription(`The prefix for this server is now \`${client.config.prefix}\``)], - }); } - } } /** diff --git a/src/commands/config/Setup.ts b/src/commands/config/Setup.ts index f263dabf1..6d78cf6cd 100644 --- a/src/commands/config/Setup.ts +++ b/src/commands/config/Setup.ts @@ -1,7 +1,12 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; -import { ApplicationCommandOptionType, OverwriteType, ChannelType, PermissionFlagsBits } from 'discord.js'; -import { getButtons } from '../../utils/Buttons'; +import { + ApplicationCommandOptionType, + ChannelType, + OverwriteType, + PermissionFlagsBits, +} from 'discord.js'; +import { Command, Context, Lavamusic } from '../../structures/index'; +import { getButtons } from '../../utils/Buttons'; export default class Setup extends Command { constructor(client: Lavamusic) { @@ -47,119 +52,152 @@ export default class Setup extends Command { ], }); } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - + public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { let subCommand: string; if (ctx.isInteraction) { subCommand = ctx.interaction.options.data[0].name; } else { subCommand = args[0]; } - const embed = client.embed() - .setColor(client.color.main) + const embed = client.embed().setColor(client.color.main); switch (subCommand) { - case 'create': + case 'create': { const data = await client.prisma.setup.findFirst({ where: { guildId: ctx.guild.id, }, }); - if (data) return ctx.sendMessage({ - embeds: [{ - description: "The song request channel already exists", - color: client.color.red - }] - }) + if (data) + return await ctx.sendMessage({ + embeds: [ + { + description: 'The song request channel already exists', + color: client.color.red, + }, + ], + }); const textChannel = await ctx.guild.channels.create({ name: `${this.client.user.username}-song-requests`, type: ChannelType.GuildText, - topic: "Song requests for the music bot", + topic: 'Song requests for the music bot', permissionOverwrites: [ { type: OverwriteType.Member, id: this.client.user.id, - allow: [PermissionFlagsBits.ViewChannel, PermissionFlagsBits.SendMessages, PermissionFlagsBits.EmbedLinks, PermissionFlagsBits.ReadMessageHistory] + allow: [ + PermissionFlagsBits.ViewChannel, + PermissionFlagsBits.SendMessages, + PermissionFlagsBits.EmbedLinks, + PermissionFlagsBits.ReadMessageHistory, + ], }, { type: OverwriteType.Role, id: ctx.guild.roles.everyone.id, - allow: [PermissionFlagsBits.ViewChannel, PermissionFlagsBits.SendMessages, PermissionFlagsBits.ReadMessageHistory] - } - ] + allow: [ + PermissionFlagsBits.ViewChannel, + PermissionFlagsBits.SendMessages, + PermissionFlagsBits.ReadMessageHistory, + ], + }, + ], }); const player = this.client.queue.get(ctx.guild.id); const image = this.client.config.links.img; - const desc = player && player.queue && player.current ? `[${player.current.info.title}](${player.current.info.uri})` : 'Nothing playing right now'; + const desc = + player && player.queue && player.current + ? `[${player.current.info.title}](${player.current.info.uri})` + : 'Nothing playing right now'; - embed.setDescription(desc) - .setImage(image) - await textChannel.send({ - embeds: [embed], - components: getButtons() - }).then(async (msg) => { - await client.prisma.setup.create({ - data: { - guildId: ctx.guild.id, - textId: textChannel.id, - messageId: msg.id - } + embed.setDescription(desc).setImage(image); + await textChannel + .send({ + embeds: [embed], + components: getButtons(), + }) + .then(async msg => { + await client.prisma.setup.create({ + data: { + guildId: ctx.guild.id, + textId: textChannel.id, + messageId: msg.id, + }, + }); }); - }); - const embed2 = client.embed() - .setColor(client.color.main) + const embed2 = client.embed().setColor(client.color.main); await ctx.sendMessage({ - embeds: [embed2.setDescription(`The song request channel has been created in ${textChannel}`)] + embeds: [ + embed2.setDescription( + `The song request channel has been created in <#${textChannel.id}>` + ), + ], }); break; - case 'delete': + } + case 'delete': { const data2 = await client.prisma.setup.findFirst({ where: { guildId: ctx.guild.id, }, }); - if (!data2) return ctx.sendMessage({ - embeds: [{ - description: "The song request channel doesn't exist", - color: client.color.red - }] - }) + if (!data2) + return await ctx.sendMessage({ + embeds: [ + { + description: 'The song request channel doesn\'t exist', + color: client.color.red, + }, + ], + }); await client.prisma.setup.delete({ where: { - guildId: ctx.guild.id - } + guildId: ctx.guild.id, + }, }); - await ctx.guild.channels.cache.get(data2.textId).delete().catch(() => { }); + await ctx.guild.channels.cache + .get(data2.textId) + .delete() + .catch(() => {}); await ctx.sendMessage({ - embeds: [{ - description: "The song request channel has been deleted", - color: client.color.main - }] - }) + embeds: [ + { + description: 'The song request channel has been deleted', + color: client.color.main, + }, + ], + }); break; - case 'info': + } + + case 'info': { const data3 = await client.prisma.setup.findFirst({ where: { guildId: ctx.guild.id, }, }); - if (!data3) return ctx.sendMessage({ - embeds: [{ - description: "The song request channel doesn't exist", - color: client.color.red - }] - }) + if (!data3) + return await ctx.sendMessage({ + embeds: [ + { + description: 'The song request channel doesn\'t exist', + color: client.color.red, + }, + ], + }); const channel = ctx.guild.channels.cache.get(data3.textId); - embed.setDescription(`The song request channel is ${channel}`) - .setColor(client.color.main) + embed + .setDescription(`The song request channel is <#${channel.id}>`) + .setColor(client.color.main); await ctx.sendMessage({ - embeds: [embed] - }) + embeds: [embed], + }); break; + } default: break; } } -}; +} /** * Project: lavamusic @@ -169,4 +207,4 @@ export default class Setup extends Command { * This code is the property of Coder and may not be reproduced or * modified without permission. For more information, contact us at * https://discord.gg/ns8CTk9J3e - */ \ No newline at end of file + */ diff --git a/src/commands/dev/Eval.ts b/src/commands/dev/Eval.ts index 8718b30cc..f97d79145 100644 --- a/src/commands/dev/Eval.ts +++ b/src/commands/dev/Eval.ts @@ -1,11 +1,11 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Eval extends Command { constructor(client: Lavamusic) { super(client, { name: 'eval', description: { - content: "Evaluate code", + content: 'Evaluate code', examples: ['eval'], usage: 'eval', }, @@ -29,11 +29,11 @@ export default class Eval extends Command { }); } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { + public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { const code = args.join(' '); try { let evaled = eval(code); - if (typeof evaled !== 'string') evaled = ((await import('util')).inspect(evaled)); + if (typeof evaled !== 'string') evaled = (await import('node:util')).inspect(evaled); ctx.sendMessage(`\`\`\`js\n${evaled}\n\`\`\``); } catch (e) { ctx.sendMessage(`\`\`\`js\n${e}\n\`\`\``); @@ -49,4 +49,4 @@ export default class Eval extends Command { * This code is the property of Coder and may not be reproduced or * modified without permission. For more information, contact us at * https://discord.gg/ns8CTk9J3e - */ \ No newline at end of file + */ diff --git a/src/commands/dev/GuildLeave.ts b/src/commands/dev/GuildLeave.ts index 176343029..c5eae5dc3 100644 --- a/src/commands/dev/GuildLeave.ts +++ b/src/commands/dev/GuildLeave.ts @@ -1,11 +1,11 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class GuildLeave extends Command { constructor(client: Lavamusic) { super(client, { name: 'guildleave', description: { - content: "Leave a guild", + content: 'Leave a guild', examples: ['guildleave'], usage: 'guildleave', }, @@ -29,16 +29,15 @@ export default class GuildLeave extends Command { }); } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { + public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { const guild = this.client.guilds.cache.get(args[0]); - if (!guild) return ctx.sendMessage('Guild not found'); + if (!guild) return await ctx.sendMessage('Guild not found'); try { await guild.leave(); ctx.sendMessage(`Left guild ${guild.name}`); } catch (e) { ctx.sendMessage(`Failed to leave guild ${guild.name}`); } - } } @@ -50,4 +49,4 @@ export default class GuildLeave extends Command { * This code is the property of Coder and may not be reproduced or * modified without permission. For more information, contact us at * https://discord.gg/ns8CTk9J3e - */ \ No newline at end of file + */ diff --git a/src/commands/dev/GuildList.ts b/src/commands/dev/GuildList.ts index b9d96d7db..de73f6793 100644 --- a/src/commands/dev/GuildList.ts +++ b/src/commands/dev/GuildList.ts @@ -1,12 +1,11 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; - +import { Command, Context, Lavamusic } from '../../structures/index'; export default class GuildList extends Command { constructor(client: Lavamusic) { super(client, { name: 'guildlist', description: { - content: "List all guilds the bot is in", + content: 'List all guilds the bot is in', examples: ['guildlist'], usage: 'guildlist', }, @@ -30,20 +29,21 @@ export default class GuildList extends Command { }); } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const guilds = this.client.guilds.cache.map((g, i) => `${g.name} (${g.id})`); + public async run(client: Lavamusic, ctx: Context,): Promise { + const guilds = this.client.guilds.cache.map((g) => `${g.name} (${g.id})`); let chunks = client.utils.chunk(guilds, 10) as any; if (chunks.length === 0) chunks = 1; const pages = []; for (let i = 0; i < chunks.length; i++) { - const embed = this.client.embed() + const embed = this.client + .embed() .setColor(this.client.color.main) .setDescription(chunks[i].join('\n')) .setFooter({ text: `Page ${i + 1} of ${chunks.length}` }); pages.push(embed); } - return client.utils.paginate(ctx, pages); + return await client.utils.paginate(ctx, pages); } } @@ -55,4 +55,4 @@ export default class GuildList extends Command { * This code is the property of Coder and may not be reproduced or * modified without permission. For more information, contact us at * https://discord.gg/ns8CTk9J3e - */ \ No newline at end of file + */ diff --git a/src/commands/filters/8d.ts b/src/commands/filters/8d.ts index 1fe7daedf..3e44a0edf 100644 --- a/src/commands/filters/8d.ts +++ b/src/commands/filters/8d.ts @@ -1,58 +1,58 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class _8d extends Command { - constructor(client: Lavamusic) { - super(client, { - name: '8d', - description: { - content: 'on/off 8d filter', - examples: ['8d'], - usage: '8d', - }, - category: 'filters', - aliases: ['3d'], - cooldown: 3, - args: false, - player: { - voice: false, - dj: true, - active: false, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: [], - }, - slashCommand: true, - options: [], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const player = client.queue.get(ctx.guild.id); - if (!player) return; - if (player.filters.includes('8D')) { - player.player.setRotation(); - player.filters.splice(player.filters.indexOf('8D'), 1); - ctx.sendMessage({ - embeds: [ - { - description: '8D filter has been disabled', - color: client.color.main, - }, - ], - }); - } else { - player.player.setRotation({ rotationHz: 0.2 }); - player.filters.push('8D'); - ctx.sendMessage({ - embeds: [ - { - description: '8D filter has been enabled', - color: client.color.main, - }, - ], - }); + constructor(client: Lavamusic) { + super(client, { + name: '8d', + description: { + content: 'on/off 8d filter', + examples: ['8d'], + usage: '8d', + }, + category: 'filters', + aliases: ['3d'], + cooldown: 3, + args: false, + player: { + voice: false, + dj: true, + active: false, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: [], + }, + slashCommand: true, + options: [], + }); + } + public async run(client: Lavamusic, ctx: Context): Promise { + const player = client.queue.get(ctx.guild.id); + if (!player) return; + if (player.filters.includes('8D')) { + player.player.setRotation(); + player.filters.splice(player.filters.indexOf('8D'), 1); + ctx.sendMessage({ + embeds: [ + { + description: '8D filter has been disabled', + color: client.color.main, + }, + ], + }); + } else { + player.player.setRotation({ rotationHz: 0.2 }); + player.filters.push('8D'); + ctx.sendMessage({ + embeds: [ + { + description: '8D filter has been enabled', + color: client.color.main, + }, + ], + }); + } } - } } diff --git a/src/commands/filters/BassBoost.ts b/src/commands/filters/BassBoost.ts index 67bf6c0cd..6dca2f900 100644 --- a/src/commands/filters/BassBoost.ts +++ b/src/commands/filters/BassBoost.ts @@ -1,62 +1,62 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class BassBoost extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'bassboost', - description: { - content: 'on/off bassboost filter', - examples: ['bassboost'], - usage: 'bassboost', - }, - category: 'filters', - aliases: ['bb'], - cooldown: 3, - args: false, - player: { - voice: false, - dj: true, - active: false, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: ['ManageGuild'], - }, - slashCommand: true, - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const player = client.queue.get(ctx.guild.id); + constructor(client: Lavamusic) { + super(client, { + name: 'bassboost', + description: { + content: 'on/off bassboost filter', + examples: ['bassboost'], + usage: 'bassboost', + }, + category: 'filters', + aliases: ['bb'], + cooldown: 3, + args: false, + player: { + voice: false, + dj: true, + active: false, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: ['ManageGuild'], + }, + slashCommand: true, + }); + } + public async run(client: Lavamusic, ctx: Context): Promise { + const player = client.queue.get(ctx.guild.id); - if (player.filters.includes('bassboost')) { - player.player.setEqualizer([]); - player.filters.splice(player.filters.indexOf('bassboost'), 1); - ctx.sendMessage({ - embeds: [ - { - description: 'Bassboost filter has been disabled', - color: client.color.main, - }, - ], - }); - } else { - player.player.setEqualizer([ - { band: 0, gain: 0.34 }, - { band: 1, gain: 0.34 }, - { band: 2, gain: 0.34 }, - { band: 3, gain: 0.34 }, - ]); - player.filters.push('bassboost'); - ctx.sendMessage({ - embeds: [ - { - description: 'Bassboost filter has been enabled', - color: client.color.main, - }, - ], - }); + if (player.filters.includes('bassboost')) { + player.player.setEqualizer([]); + player.filters.splice(player.filters.indexOf('bassboost'), 1); + ctx.sendMessage({ + embeds: [ + { + description: 'Bassboost filter has been disabled', + color: client.color.main, + }, + ], + }); + } else { + player.player.setEqualizer([ + { band: 0, gain: 0.34 }, + { band: 1, gain: 0.34 }, + { band: 2, gain: 0.34 }, + { band: 3, gain: 0.34 }, + ]); + player.filters.push('bassboost'); + ctx.sendMessage({ + embeds: [ + { + description: 'Bassboost filter has been enabled', + color: client.color.main, + }, + ], + }); + } } - } } diff --git a/src/commands/filters/Distorsion.ts b/src/commands/filters/Distorsion.ts index 54b67d7cf..779f7e66b 100644 --- a/src/commands/filters/Distorsion.ts +++ b/src/commands/filters/Distorsion.ts @@ -1,66 +1,66 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Distorsion extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'distorsion', - description: { - content: 'on/off distorsion filter', - examples: ['distorsion'], - usage: 'distorsion', - }, - category: 'filters', - aliases: ['distorsion'], - cooldown: 3, - args: false, - player: { - voice: false, - dj: true, - active: false, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: ['ManageGuild'], - }, - slashCommand: true, - options: [], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const player = client.queue.get(ctx.guild.id); - if (player.filters.includes('distorsion')) { - player.player.setDistortion({}); - player.filters.splice(player.filters.indexOf('distorsion'), 1); - ctx.sendMessage({ - embeds: [ - { - description: 'Distorsion filter has been disabled', - color: client.color.main, - }, - ], - }); - } else { - player.player.setDistortion({ - sinOffset: 0, - sinScale: 1, - cosOffset: 0, - cosScale: 1, - tanOffset: 0, - tanScale: 1, - offset: 0, - scale: 1, - }); - player.filters.push('distorsion'); - ctx.sendMessage({ - embeds: [ - { - description: 'Distorsion filter has been enabled', - color: client.color.main, - }, - ], - }); + constructor(client: Lavamusic) { + super(client, { + name: 'distorsion', + description: { + content: 'on/off distorsion filter', + examples: ['distorsion'], + usage: 'distorsion', + }, + category: 'filters', + aliases: ['distorsion'], + cooldown: 3, + args: false, + player: { + voice: false, + dj: true, + active: false, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: ['ManageGuild'], + }, + slashCommand: true, + options: [], + }); + } + public async run(client: Lavamusic, ctx: Context): Promise { + const player = client.queue.get(ctx.guild.id); + if (player.filters.includes('distorsion')) { + player.player.setDistortion({}); + player.filters.splice(player.filters.indexOf('distorsion'), 1); + ctx.sendMessage({ + embeds: [ + { + description: 'Distorsion filter has been disabled', + color: client.color.main, + }, + ], + }); + } else { + player.player.setDistortion({ + sinOffset: 0, + sinScale: 1, + cosOffset: 0, + cosScale: 1, + tanOffset: 0, + tanScale: 1, + offset: 0, + scale: 1, + }); + player.filters.push('distorsion'); + ctx.sendMessage({ + embeds: [ + { + description: 'Distorsion filter has been enabled', + color: client.color.main, + }, + ], + }); + } } - } } diff --git a/src/commands/filters/Karaoke.ts b/src/commands/filters/Karaoke.ts index a4736a849..f5f58e429 100644 --- a/src/commands/filters/Karaoke.ts +++ b/src/commands/filters/Karaoke.ts @@ -1,63 +1,63 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Karaoke extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'karaoke', - description: { - content: 'on/off the karaoke filter', - examples: ['karaoke'], - usage: 'karaoke', - }, - category: 'filters', - aliases: ['kk'], - cooldown: 3, - args: false, - player: { - voice: false, - dj: true, - active: false, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: ['ManageGuild'], - }, - slashCommand: true, - options: [], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const player = client.queue.get(ctx.guild.id); + constructor(client: Lavamusic) { + super(client, { + name: 'karaoke', + description: { + content: 'on/off the karaoke filter', + examples: ['karaoke'], + usage: 'karaoke', + }, + category: 'filters', + aliases: ['kk'], + cooldown: 3, + args: false, + player: { + voice: false, + dj: true, + active: false, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: ['ManageGuild'], + }, + slashCommand: true, + options: [], + }); + } + public async run(client: Lavamusic, ctx: Context): Promise { + const player = client.queue.get(ctx.guild.id); - if (player.filters.includes('karaoke')) { - player.player.setKaraoke(); - player.filters.splice(player.filters.indexOf('karaoke'), 1); - ctx.sendMessage({ - embeds: [ - { - description: 'Karaoke filter has been disabled', - color: client.color.main, - }, - ], - }); - } else { - player.player.setKaraoke({ - level: 1, - monoLevel: 1, - filterBand: 220, - filterWidth: 100, - }); - player.filters.push('karaoke'); - ctx.sendMessage({ - embeds: [ - { - description: 'Karaoke filter has been enabled', - color: client.color.main, - }, - ], - }); + if (player.filters.includes('karaoke')) { + player.player.setKaraoke(); + player.filters.splice(player.filters.indexOf('karaoke'), 1); + ctx.sendMessage({ + embeds: [ + { + description: 'Karaoke filter has been disabled', + color: client.color.main, + }, + ], + }); + } else { + player.player.setKaraoke({ + level: 1, + monoLevel: 1, + filterBand: 220, + filterWidth: 100, + }); + player.filters.push('karaoke'); + ctx.sendMessage({ + embeds: [ + { + description: 'Karaoke filter has been enabled', + color: client.color.main, + }, + ], + }); + } } - } } diff --git a/src/commands/filters/NightCore.ts b/src/commands/filters/NightCore.ts index 255fdb25c..7b5211764 100644 --- a/src/commands/filters/NightCore.ts +++ b/src/commands/filters/NightCore.ts @@ -1,57 +1,57 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class NightCore extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'nightcore', - description: { - content: 'on/off nightcore filter', - examples: ['nightcore'], - usage: 'nightcore', - }, - category: 'filters', - aliases: ['nc'], - cooldown: 3, - args: false, - player: { - voice: true, - dj: true, - active: true, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: [], - }, - slashCommand: true, - options: [], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const player = client.queue.get(ctx.guild.id); - if (player.filters.includes('nightcore')) { - player.player.setTimescale(); - player.filters.splice(player.filters.indexOf('nightcore'), 1); - ctx.sendMessage({ - embeds: [ - { - description: 'Nightcore filter has been disabled', - color: client.color.main, - }, - ], - }); - } else { - player.player.setTimescale({ speed: 1.165, pitch: 1.125, rate: 1.05 }); - player.filters.push('nightcore'); - ctx.sendMessage({ - embeds: [ - { - description: 'Nightcore filter has been enabled', - color: client.color.main, - }, - ], - }); + constructor(client: Lavamusic) { + super(client, { + name: 'nightcore', + description: { + content: 'on/off nightcore filter', + examples: ['nightcore'], + usage: 'nightcore', + }, + category: 'filters', + aliases: ['nc'], + cooldown: 3, + args: false, + player: { + voice: true, + dj: true, + active: true, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: [], + }, + slashCommand: true, + options: [], + }); + } + public async run(client: Lavamusic, ctx: Context): Promise { + const player = client.queue.get(ctx.guild.id); + if (player.filters.includes('nightcore')) { + player.player.setTimescale(); + player.filters.splice(player.filters.indexOf('nightcore'), 1); + ctx.sendMessage({ + embeds: [ + { + description: 'Nightcore filter has been disabled', + color: client.color.main, + }, + ], + }); + } else { + player.player.setTimescale({ speed: 1.165, pitch: 1.125, rate: 1.05 }); + player.filters.push('nightcore'); + ctx.sendMessage({ + embeds: [ + { + description: 'Nightcore filter has been enabled', + color: client.color.main, + }, + ], + }); + } } - } } diff --git a/src/commands/filters/Pitch.ts b/src/commands/filters/Pitch.ts index 3a2c96001..7cd460d86 100644 --- a/src/commands/filters/Pitch.ts +++ b/src/commands/filters/Pitch.ts @@ -1,72 +1,73 @@ import { ApplicationCommandOptionType } from 'discord.js'; -import { Command, Lavamusic, Context } from '../../structures/index'; + +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Pitch extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'pitch', - description: { - content: 'on/off the pitch filter', - examples: ['pitch 1'], - usage: 'pitch ', - }, - category: 'filters', - aliases: ['ph'], - cooldown: 3, - args: true, - player: { - voice: false, - dj: true, - active: false, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: ['ManageGuild'], - }, - slashCommand: true, - options: [ - { - name: 'number', - description: 'The number you want to set the pitch to', - type: ApplicationCommandOptionType.Integer, - required: true, - }, - ], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const player = client.queue.get(ctx.guild.id); + constructor(client: Lavamusic) { + super(client, { + name: 'pitch', + description: { + content: 'on/off the pitch filter', + examples: ['pitch 1'], + usage: 'pitch ', + }, + category: 'filters', + aliases: ['ph'], + cooldown: 3, + args: true, + player: { + voice: false, + dj: true, + active: false, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: ['ManageGuild'], + }, + slashCommand: true, + options: [ + { + name: 'number', + description: 'The number you want to set the pitch to', + type: ApplicationCommandOptionType.Integer, + required: true, + }, + ], + }); + } + public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { + const player = client.queue.get(ctx.guild.id); - const number = Number(args[0]); - if (isNaN(number)) - return ctx.sendMessage({ - embeds: [ - { - description: 'Please provide a valid number', - color: client.color.red, - }, - ], - }); - if (number > 5 || number < 1) - return ctx.sendMessage({ - embeds: [ - { - description: 'Please provide a number between 1 and 5', - color: client.color.red, - }, - ], - }); - player.player.setTimescale({ pitch: number, rate: 1, speed: 1 }); + const number = Number(args[0]); + if (isNaN(number)) + return await ctx.sendMessage({ + embeds: [ + { + description: 'Please provide a valid number', + color: client.color.red, + }, + ], + }); + if (number > 5 || number < 1) + return await ctx.sendMessage({ + embeds: [ + { + description: 'Please provide a number between 1 and 5', + color: client.color.red, + }, + ], + }); + player.player.setTimescale({ pitch: number, rate: 1, speed: 1 }); - return ctx.sendMessage({ - embeds: [ - { - description: `Pitch has been set to ${number}`, - color: client.color.main, - }, - ], - }); - } + return await ctx.sendMessage({ + embeds: [ + { + description: `Pitch has been set to ${number}`, + color: client.color.main, + }, + ], + }); + } } diff --git a/src/commands/filters/Reset.ts b/src/commands/filters/Reset.ts index c4a2f7f81..2f034556a 100644 --- a/src/commands/filters/Reset.ts +++ b/src/commands/filters/Reset.ts @@ -1,45 +1,45 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Reset extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'reset', - description: { - content: 'Resets the active filters', - examples: ['reset'], - usage: 'reset', - }, - category: 'filters', - aliases: ['reset'], - cooldown: 3, - args: false, - player: { - voice: false, - dj: true, - active: false, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: ['ManageGuild'], - }, - slashCommand: true, - options: [], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const player = client.queue.get(ctx.guild.id); + constructor(client: Lavamusic) { + super(client, { + name: 'reset', + description: { + content: 'Resets the active filters', + examples: ['reset'], + usage: 'reset', + }, + category: 'filters', + aliases: ['reset'], + cooldown: 3, + args: false, + player: { + voice: false, + dj: true, + active: false, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: ['ManageGuild'], + }, + slashCommand: true, + options: [], + }); + } + public async run(client: Lavamusic, ctx: Context): Promise { + const player = client.queue.get(ctx.guild.id); - player.player.clearFilters(); - player.filters = []; - return ctx.sendMessage({ - embeds: [ - { - description: 'Filters have been reset', - color: client.color.main, - }, - ], - }); - } + player.player.clearFilters(); + player.filters = []; + return await ctx.sendMessage({ + embeds: [ + { + description: 'Filters have been reset', + color: client.color.main, + }, + ], + }); + } } diff --git a/src/commands/filters/Rotation.ts b/src/commands/filters/Rotation.ts index c54db2591..7608336ba 100644 --- a/src/commands/filters/Rotation.ts +++ b/src/commands/filters/Rotation.ts @@ -1,58 +1,58 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Rotation extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'rotation', - description: { - content: 'on/off rotation filter', - examples: ['rotation'], - usage: 'rotation', - }, - category: 'filters', - aliases: ['rt'], - cooldown: 3, - args: false, - player: { - voice: false, - dj: true, - active: false, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: ['ManageGuild'], - }, - slashCommand: true, - options: [], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const player = client.queue.get(ctx.guild.id); + constructor(client: Lavamusic) { + super(client, { + name: 'rotation', + description: { + content: 'on/off rotation filter', + examples: ['rotation'], + usage: 'rotation', + }, + category: 'filters', + aliases: ['rt'], + cooldown: 3, + args: false, + player: { + voice: false, + dj: true, + active: false, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: ['ManageGuild'], + }, + slashCommand: true, + options: [], + }); + } + public async run(client: Lavamusic, ctx: Context): Promise { + const player = client.queue.get(ctx.guild.id); - if (player.filters.includes('rotation')) { - player.player.setRotation(); - player.filters.splice(player.filters.indexOf('rotation'), 1); - ctx.sendMessage({ - embeds: [ - { - description: 'rotation filter has been disabled', - color: client.color.main, - }, - ], - }); - } else { - player.player.setRotation({ rotationHz: 0 }); - player.filters.push('rotation'); - ctx.sendMessage({ - embeds: [ - { - description: 'rotation filter has been enabled', - color: client.color.main, - }, - ], - }); + if (player.filters.includes('rotation')) { + player.player.setRotation(); + player.filters.splice(player.filters.indexOf('rotation'), 1); + ctx.sendMessage({ + embeds: [ + { + description: 'rotation filter has been disabled', + color: client.color.main, + }, + ], + }); + } else { + player.player.setRotation({ rotationHz: 0 }); + player.filters.push('rotation'); + ctx.sendMessage({ + embeds: [ + { + description: 'rotation filter has been enabled', + color: client.color.main, + }, + ], + }); + } } - } } diff --git a/src/commands/filters/Speed.ts b/src/commands/filters/Speed.ts index e0e4ede97..03a1f7aec 100644 --- a/src/commands/filters/Speed.ts +++ b/src/commands/filters/Speed.ts @@ -1,74 +1,75 @@ import { ApplicationCommandOptionType } from 'discord.js'; -import { Command, Lavamusic, Context } from '../../structures/index'; + +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Speed extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'speed', - description: { - content: 'Sets the speed of the song', - examples: ['speed 1.5'], - usage: 'speed ', - }, - category: 'filters', - aliases: ['speed'], - cooldown: 3, - args: true, - player: { - voice: false, - dj: true, - active: false, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: ['ManageGuild'], - }, - slashCommand: true, - options: [ - { - name: 'speed', - description: 'The speed you want to set', - type: ApplicationCommandOptionType.Integer, - required: true, - }, - ], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const player = client.queue.get(ctx.guild.id); - const speed = Number(args[0]); + constructor(client: Lavamusic) { + super(client, { + name: 'speed', + description: { + content: 'Sets the speed of the song', + examples: ['speed 1.5'], + usage: 'speed ', + }, + category: 'filters', + aliases: ['speed'], + cooldown: 3, + args: true, + player: { + voice: false, + dj: true, + active: false, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: ['ManageGuild'], + }, + slashCommand: true, + options: [ + { + name: 'speed', + description: 'The speed you want to set', + type: ApplicationCommandOptionType.Integer, + required: true, + }, + ], + }); + } + public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { + const player = client.queue.get(ctx.guild.id); + const speed = Number(args[0]); - if (isNaN(speed)) - return ctx.sendMessage({ - embeds: [ - { - description: 'Please provide a valid number', - color: client.color.red, - }, - ], - }); + if (isNaN(speed)) + return await ctx.sendMessage({ + embeds: [ + { + description: 'Please provide a valid number', + color: client.color.red, + }, + ], + }); - if (speed < 0.5 || speed > 5) - return ctx.sendMessage({ - embeds: [ - { - description: 'Please provide a number between 0.5 and 5', - color: client.color.red, - }, - ], - }); + if (speed < 0.5 || speed > 5) + return await ctx.sendMessage({ + embeds: [ + { + description: 'Please provide a number between 0.5 and 5', + color: client.color.red, + }, + ], + }); - player.player.setTimescale({ speed: speed }); + player.player.setTimescale({ speed: speed }); - return ctx.sendMessage({ - embeds: [ - { - description: `Speed has been set to ${speed}`, - color: client.color.main, - }, - ], - }); - } + return await ctx.sendMessage({ + embeds: [ + { + description: `Speed has been set to ${speed}`, + color: client.color.main, + }, + ], + }); + } } diff --git a/src/commands/filters/Tremolo.ts b/src/commands/filters/Tremolo.ts index 5c9aaf6f6..7abe4e812 100644 --- a/src/commands/filters/Tremolo.ts +++ b/src/commands/filters/Tremolo.ts @@ -1,58 +1,58 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Tremolo extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'tremolo', - description: { - content: 'on/off the tremolo filter', - examples: ['tremolo'], - usage: 'tremolo', - }, - category: 'filters', - aliases: ['tremolo'], - cooldown: 3, - args: false, - player: { - voice: false, - dj: true, - active: false, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: ['ManageGuild'], - }, - slashCommand: true, - options: [], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const player = client.queue.get(ctx.guild.id); + constructor(client: Lavamusic) { + super(client, { + name: 'tremolo', + description: { + content: 'on/off the tremolo filter', + examples: ['tremolo'], + usage: 'tremolo', + }, + category: 'filters', + aliases: ['tremolo'], + cooldown: 3, + args: false, + player: { + voice: false, + dj: true, + active: false, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: ['ManageGuild'], + }, + slashCommand: true, + options: [], + }); + } + public async run(client: Lavamusic, ctx: Context): Promise { + const player = client.queue.get(ctx.guild.id); - if (player.filters.includes('tremolo')) { - player.player.setTremolo(); - player.filters.splice(player.filters.indexOf('tremolo'), 1); - ctx.sendMessage({ - embeds: [ - { - description: 'tremolo filter has been disabled', - color: client.color.main, - }, - ], - }); - } else { - player.player.setTremolo({ depth: 0.75, frequency: 4 }); - player.filters.push('tremolo'); - ctx.sendMessage({ - embeds: [ - { - description: 'tremolo filter has been enabled', - color: client.color.main, - }, - ], - }); + if (player.filters.includes('tremolo')) { + player.player.setTremolo(); + player.filters.splice(player.filters.indexOf('tremolo'), 1); + ctx.sendMessage({ + embeds: [ + { + description: 'tremolo filter has been disabled', + color: client.color.main, + }, + ], + }); + } else { + player.player.setTremolo({ depth: 0.75, frequency: 4 }); + player.filters.push('tremolo'); + ctx.sendMessage({ + embeds: [ + { + description: 'tremolo filter has been enabled', + color: client.color.main, + }, + ], + }); + } } - } } diff --git a/src/commands/filters/Vibrato.ts b/src/commands/filters/Vibrato.ts index 88c509546..3924fe7b6 100644 --- a/src/commands/filters/Vibrato.ts +++ b/src/commands/filters/Vibrato.ts @@ -1,57 +1,57 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Vibrato extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'vibrato', - description: { - content: 'on/off vibrato filter', - examples: ['vibrato'], - usage: 'vibrato', - }, - category: 'filters', - aliases: ['vb'], - cooldown: 3, - args: false, - player: { - voice: false, - dj: true, - active: false, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: [], - }, - slashCommand: true, - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const player = client.queue.get(ctx.guild.id); + constructor(client: Lavamusic) { + super(client, { + name: 'vibrato', + description: { + content: 'on/off vibrato filter', + examples: ['vibrato'], + usage: 'vibrato', + }, + category: 'filters', + aliases: ['vb'], + cooldown: 3, + args: false, + player: { + voice: false, + dj: true, + active: false, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: [], + }, + slashCommand: true, + }); + } + public async run(client: Lavamusic, ctx: Context): Promise { + const player = client.queue.get(ctx.guild.id); - if (player.filters.includes('vibrato')) { - player.player.setVibrato(); - player.filters.splice(player.filters.indexOf('vibrato'), 1); - ctx.sendMessage({ - embeds: [ - { - description: 'Vibrato filter has been disabled', - color: client.color.main, - }, - ], - }); - } else { - player.player.setVibrato({ depth: 0.75, frequency: 4 }); - player.filters.push('vibrato'); - ctx.sendMessage({ - embeds: [ - { - description: 'Vibrato filter has been enabled', - color: client.color.main, - }, - ], - }); + if (player.filters.includes('vibrato')) { + player.player.setVibrato(); + player.filters.splice(player.filters.indexOf('vibrato'), 1); + ctx.sendMessage({ + embeds: [ + { + description: 'Vibrato filter has been disabled', + color: client.color.main, + }, + ], + }); + } else { + player.player.setVibrato({ depth: 0.75, frequency: 4 }); + player.filters.push('vibrato'); + ctx.sendMessage({ + embeds: [ + { + description: 'Vibrato filter has been enabled', + color: client.color.main, + }, + ], + }); + } } - } } diff --git a/src/commands/filters/lowPass.ts b/src/commands/filters/lowPass.ts index 37f563a44..1bf0b4c7b 100644 --- a/src/commands/filters/lowPass.ts +++ b/src/commands/filters/lowPass.ts @@ -1,57 +1,57 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class lowPass extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'lowpass', - description: { - content: 'on/off lowpass filter', - examples: ['lowpass'], - usage: 'lowpass ', - }, - category: 'filters', - aliases: ['lp'], - cooldown: 3, - args: false, - player: { - voice: false, - dj: true, - active: false, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: ['ManageGuild'], - }, - slashCommand: false, - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const player = client.queue.get(ctx.guild.id); + constructor(client: Lavamusic) { + super(client, { + name: 'lowpass', + description: { + content: 'on/off lowpass filter', + examples: ['lowpass'], + usage: 'lowpass ', + }, + category: 'filters', + aliases: ['lp'], + cooldown: 3, + args: false, + player: { + voice: false, + dj: true, + active: false, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: ['ManageGuild'], + }, + slashCommand: false, + }); + } + public async run(client: Lavamusic, ctx: Context): Promise { + const player = client.queue.get(ctx.guild.id); - if (player.filters.includes('lowpass')) { - player.player.setLowPass({}); - player.filters.splice(player.filters.indexOf('lowpass'), 1); - ctx.sendMessage({ - embeds: [ - { - description: 'Lowpass filter has been disabled', - color: client.color.main, - }, - ], - }); - } else { - player.player.setLowPass({ smoothing: 20 }); - player.filters.push('lowpass'); - ctx.sendMessage({ - embeds: [ - { - description: 'Lowpass filter has been enabled', - color: client.color.main, - }, - ], - }); + if (player.filters.includes('lowpass')) { + player.player.setLowPass({}); + player.filters.splice(player.filters.indexOf('lowpass'), 1); + ctx.sendMessage({ + embeds: [ + { + description: 'Lowpass filter has been disabled', + color: client.color.main, + }, + ], + }); + } else { + player.player.setLowPass({ smoothing: 20 }); + player.filters.push('lowpass'); + ctx.sendMessage({ + embeds: [ + { + description: 'Lowpass filter has been enabled', + color: client.color.main, + }, + ], + }); + } } - } } diff --git a/src/commands/info/About.ts b/src/commands/info/About.ts index 0167f9d10..72dba31f0 100644 --- a/src/commands/info/About.ts +++ b/src/commands/info/About.ts @@ -1,83 +1,88 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from 'discord.js'; +import { Command, Context, Lavamusic } from '../../structures/index'; + export default class About extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'about', - description: { - content: 'Shows information about the bot', - examples: ['about'], - usage: 'about', - }, - category: 'info', - aliases: ['ab'], - cooldown: 3, - args: false, - player: { - voice: false, - dj: false, - active: false, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: [], - }, - slashCommand: true, - options: [], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const row = new ActionRowBuilder().addComponents( - new ButtonBuilder() - .setLabel('Invite Lavamusic') - .setStyle(ButtonStyle.Link) - .setURL( - `https://discord.com/api/oauth2/authorize?client_id=875635121770889257&permissions=8&scope=bot%20applications.commands`, - ), - new ButtonBuilder().setLabel('Support Server').setStyle(ButtonStyle.Link).setURL('https://discord.gg/ns8CTk9J3e'), - ); + constructor(client: Lavamusic) { + super(client, { + name: 'about', + description: { + content: 'Shows information about the bot', + examples: ['about'], + usage: 'about', + }, + category: 'info', + aliases: ['ab'], + cooldown: 3, + args: false, + player: { + voice: false, + dj: false, + active: false, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: [], + }, + slashCommand: true, + options: [], + }); + } + public async run(client: Lavamusic, ctx: Context): Promise { + const row = new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setLabel('Invite Lavamusic') + .setStyle(ButtonStyle.Link) + .setURL( + `https://discord.com/api/oauth2/authorize?client_id=875635121770889257&permissions=8&scope=bot%20applications.commands` + ), + new ButtonBuilder() + .setLabel('Support Server') + .setStyle(ButtonStyle.Link) + .setURL('https://discord.gg/ns8CTk9J3e') + ); - const embed = this.client - .embed() - .setAuthor({ - name: 'LavaMusic', - iconURL: 'https://media.discordapp.net/attachments/876035356460462090/888434725235097610/20210820_124325.png', - }) - .setThumbnail( - 'https://media.discordapp.net/attachments/876035356460462090/888434725235097610/20210820_124325.png', - ) - .setColor(this.client.color.main) - .addFields([ - { - name: 'Creator', - value: '[Blacky#9125](https://github.com/brblacky)', - inline: true, - }, - { - name: 'Repository', - value: '[Here](https://github.com/brblacky/lavamusic)', - inline: true, - }, - { - name: 'Support', - value: '[Here](https://discord.gg/ns8CTk9J3e)', - inline: true, - }, - { - name: '\u200b', - value: `He really wanted to make his first open source project ever for more coding experience. In this project, he was challenged to make a project with less bugs. Hope you enjoy using LavaMusic!`, - inline: true, - }, - ]); - return await ctx.sendMessage({ - content: '', - embeds: [embed], - components: [row], - }); - } + const embed = this.client + .embed() + .setAuthor({ + name: 'LavaMusic', + iconURL: + 'https://media.discordapp.net/attachments/876035356460462090/888434725235097610/20210820_124325.png', + }) + .setThumbnail( + 'https://media.discordapp.net/attachments/876035356460462090/888434725235097610/20210820_124325.png' + ) + .setColor(this.client.color.main) + .addFields([ + { + name: 'Creator', + value: '[Blacky#9125](https://github.com/brblacky)', + inline: true, + }, + { + name: 'Repository', + value: '[Here](https://github.com/brblacky/lavamusic)', + inline: true, + }, + { + name: 'Support', + value: '[Here](https://discord.gg/ns8CTk9J3e)', + inline: true, + }, + { + name: '\u200b', + value: `He really wanted to make his first open source project ever for more coding experience. In this project, he was challenged to make a project with less bugs. Hope you enjoy using LavaMusic!`, + inline: true, + }, + ]); + return await ctx.sendMessage({ + content: '', + embeds: [embed], + components: [row], + }); + } } /** diff --git a/src/commands/info/Help.ts b/src/commands/info/Help.ts index 619bf7716..f8f321745 100644 --- a/src/commands/info/Help.ts +++ b/src/commands/info/Help.ts @@ -1,97 +1,108 @@ -import { Lavamusic, Context, Command } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Help extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'help', - description: { - content: 'Shows the help menu', - examples: ['help'], - usage: 'help', - }, - category: 'info', - aliases: ['h'], - cooldown: 3, - args: false, - player: { - voice: false, - dj: false, - active: false, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: [], - }, - slashCommand: true, - options: [ - { - name: 'command', - description: 'The command you want to get info on', - type: 3, - required: false, - }, - ], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const embed = this.client.embed(); - let prefix = (await this.client.prisma.guild.findUnique({ - where: { - guildId: ctx.guild.id, - }, - })) as any; - if (!prefix) { - prefix = this.client.config.prefix; - } else { - prefix = prefix.prefix; + constructor(client: Lavamusic) { + super(client, { + name: 'help', + description: { + content: 'Shows the help menu', + examples: ['help'], + usage: 'help', + }, + category: 'info', + aliases: ['h'], + cooldown: 3, + args: false, + player: { + voice: false, + dj: false, + active: false, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: [], + }, + slashCommand: true, + options: [ + { + name: 'command', + description: 'The command you want to get info on', + type: 3, + required: false, + }, + ], + }); } - const commands = this.client.commands.filter((cmd) => cmd.category !== 'dev'); - const categories = commands - .map((cmd) => cmd.category) - .filter((value, index, self) => self.indexOf(value) === index); + public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { + const embed = this.client.embed(); + let prefix = (await this.client.prisma.guild.findUnique({ + where: { + guildId: ctx.guild.id, + }, + })) as any; + if (!prefix) { + prefix = this.client.config.prefix; + } else { + prefix = prefix.prefix; + } + const commands = this.client.commands.filter(cmd => cmd.category !== 'dev'); + const categories = commands + .map(cmd => cmd.category) + .filter((value, index, self) => self.indexOf(value) === index); - if (!args[0]) { - const fildes = []; - categories.forEach((category) => { - fildes.push({ - name: category, - value: commands - .filter((cmd) => cmd.category === category) - .map((cmd) => `\`${cmd.name}\``) - .join(', '), - inline: false, - }); - }); - const helpEmbed = embed - .setColor(this.client.color.main) - .setTitle('Help Menu') - .setDescription( - `Hey there! I'm ${this.client.user.username}, a music bot made with [Lavamusic](https://github.com/brblacky/lavamusic) and Discord. You can use \`${prefix}help \` to get more info on a command.`, - ) - .setFooter({ - text: `Use ${prefix}help for more info on a command`, - }); - fildes.forEach((field) => helpEmbed.addFields(field)); - ctx.sendMessage({ embeds: [helpEmbed] }); - } else { - const command = this.client.commands.get(args[0].toLowerCase()); - if (!command) - return ctx.sendMessage({ - embeds: [client.embed().setColor(client.color.red).setDescription(`Command \`${args[0]}\` not found`)], - }); - const embed = this.client.embed(); - const helpEmbed = embed.setColor(this.client.color.main).setTitle(`Help Menu - ${command.name}`) - .setDescription(`**Description:** ${command.description.content} + if (!args[0]) { + const fildes = []; + categories.forEach(category => { + fildes.push({ + name: category, + value: commands + .filter(cmd => cmd.category === category) + .map(cmd => `\`${cmd.name}\``) + .join(', '), + inline: false, + }); + }); + const helpEmbed = embed + .setColor(this.client.color.main) + .setTitle('Help Menu') + .setDescription( + `Hey there! I'm ${this.client.user.username}, a music bot made with [Lavamusic](https://github.com/brblacky/lavamusic) and Discord. You can use \`${prefix}help \` to get more info on a command.` + ) + .setFooter({ + text: `Use ${prefix}help for more info on a command`, + }); + fildes.forEach(field => helpEmbed.addFields(field)); + ctx.sendMessage({ embeds: [helpEmbed] }); + } else { + const command = this.client.commands.get(args[0].toLowerCase()); + if (!command) + return await ctx.sendMessage({ + embeds: [ + client + .embed() + .setColor(client.color.red) + .setDescription(`Command \`${args[0]}\` not found`), + ], + }); + const embed = this.client.embed(); + const helpEmbed = embed + .setColor(this.client.color.main) + .setTitle(`Help Menu - ${command.name}`).setDescription(`**Description:** ${ + command.description.content + } **Usage:** ${prefix}${command.description.usage} -**Examples:** ${command.description.examples.map((example) => `${prefix}${example}`).join(', ')} -**Aliases:** ${command.aliases.map((alias) => `\`${alias}\``).join(', ')} +**Examples:** ${command.description.examples.map(example => `${prefix}${example}`).join(', ')} +**Aliases:** ${command.aliases.map(alias => `\`${alias}\``).join(', ')} **Category:** ${command.category} **Cooldown:** ${command.cooldown} seconds -**Permissions:** ${command.permissions.user.length > 0 ? command.permissions.user.map((perm) => `\`${perm}\``).join(', ') : 'None' - } -**Bot Permissions:** ${command.permissions.client.map((perm) => `\`${perm}\``).join(', ')} +**Permissions:** ${ + command.permissions.user.length > 0 + ? command.permissions.user.map(perm => `\`${perm}\``).join(', ') + : 'None' + } +**Bot Permissions:** ${command.permissions.client.map(perm => `\`${perm}\``).join(', ')} **Developer Only:** ${command.permissions.dev ? 'Yes' : 'No'} **Slash Command:** ${command.slashCommand ? 'Yes' : 'No'} **Args:** ${command.args ? 'Yes' : 'No'} @@ -99,9 +110,9 @@ export default class Help extends Command { **DJ:** ${command.player.dj ? 'Yes' : 'No'} **DJ Permissions:** ${command.player.djPerm ? command.player.djPerm : 'None'} **Voice:** ${command.player.voice ? 'Yes' : 'No'}`); - ctx.sendMessage({ embeds: [helpEmbed] }); + ctx.sendMessage({ embeds: [helpEmbed] }); + } } - } } /** diff --git a/src/commands/info/Info.ts b/src/commands/info/Info.ts index 6a25744f8..bf921bfb6 100644 --- a/src/commands/info/Info.ts +++ b/src/commands/info/Info.ts @@ -1,71 +1,72 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; -import os from 'os'; import { version } from 'discord.js'; +import os from 'node:os'; + +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Info extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'info', - description: { - content: 'Ingormation about the bot', - examples: ['info'], - usage: 'info', - }, - category: 'info', - aliases: ['botinfo', 'bi'], - cooldown: 3, - args: false, - player: { - voice: false, - dj: false, - active: false, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: [], - }, - slashCommand: true, - options: [], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const osType = os.type(); - const osRelease = os.release(); - const osUptime = os.uptime(); - const osHostname = os.hostname(); - const cpuArch = os.arch(); - const cpuCores = os.cpus().length; - const totalMem = os.totalmem(); - const freeMem = os.freemem(); - const usedMem = totalMem - freeMem; - const nodeVersion = process.version; - const discordJsVersion = version; - const botGuilds = client.guilds.cache.size; - const botChannels = client.channels.cache.size; - const botUsers = client.users.cache.size; - const botCommands = client.commands.size; + constructor(client: Lavamusic) { + super(client, { + name: 'info', + description: { + content: 'Ingormation about the bot', + examples: ['info'], + usage: 'info', + }, + category: 'info', + aliases: ['botinfo', 'bi'], + cooldown: 3, + args: false, + player: { + voice: false, + dj: false, + active: false, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: [], + }, + slashCommand: true, + options: [], + }); + } + public async run(client: Lavamusic, ctx: Context): Promise { + const osType = os.type(); + const osRelease = os.release(); + const osUptime = os.uptime(); + const osHostname = os.hostname(); + const cpuArch = os.arch(); + const cpuCores = os.cpus().length; + const totalMem = os.totalmem(); + const freeMem = os.freemem(); + const usedMem = totalMem - freeMem; + const nodeVersion = process.version; + const discordJsVersion = version; + const botGuilds = client.guilds.cache.size; + const botChannels = client.channels.cache.size; + const botUsers = client.users.cache.size; + const botCommands = client.commands.size; - const botInfo = `Bot Information: + const botInfo = `Bot Information: - **Operating System**: ${osType} ${osRelease} - **Uptime**: ${client.utils.formatTime(osUptime)} - **Hostname**: ${osHostname} - **CPU Architecture**: ${cpuArch} (${cpuCores} cores) -- **Memory Usage**: ${client.utils.formatBytes(usedMem)} / ${client.utils.formatBytes(totalMem)} (${Math.round( - (usedMem / totalMem) * 100, - )}%) +- **Memory Usage**: ${client.utils.formatBytes(usedMem)} / ${client.utils.formatBytes( + totalMem + )} (${Math.round((usedMem / totalMem) * 100)}%) - **Node Version**: ${nodeVersion} - **Discord Version**: ${discordJsVersion} - **Connected to** ${botGuilds} guilds, ${botChannels} channels, and ${botUsers} users - **Total Commands**: ${botCommands} `; - const embed = this.client.embed(); - return ctx.sendMessage({ - embeds: [embed.setColor(this.client.color.main).setDescription(botInfo)], - }); - } + const embed = this.client.embed(); + return await ctx.sendMessage({ + embeds: [embed.setColor(this.client.color.main).setDescription(botInfo)], + }); + } } /** diff --git a/src/commands/info/Invite.ts b/src/commands/info/Invite.ts index 7bbb0d2f4..955142350 100644 --- a/src/commands/info/Invite.ts +++ b/src/commands/info/Invite.ts @@ -1,61 +1,69 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from 'discord.js'; +import { Command, Context, Lavamusic } from '../../structures/index'; + export default class Invite extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'invite', - description: { - content: "Sends the bot's invite link", - examples: ['invite'], - usage: 'invite', - }, - category: 'info', - aliases: ['inv'], - cooldown: 3, - args: false, - player: { - voice: false, - dj: false, - active: false, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: [], - }, - slashCommand: true, - options: [], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const clientId = process.env.CLIENT_ID; - if (!clientId) { - console.error('Client ID not found in environment variables, cannot generate invite link.'); - return ctx.sendMessage('Sorry, my invite link is not available at this time. Please tell the bot developer to check their console.') + constructor(client: Lavamusic) { + super(client, { + name: 'invite', + description: { + content: 'Sends the bot\'s invite link', + examples: ['invite'], + usage: 'invite', + }, + category: 'info', + aliases: ['inv'], + cooldown: 3, + args: false, + player: { + voice: false, + dj: false, + active: false, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: [], + }, + slashCommand: true, + options: [], + }); } + public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { + const clientId = process.env.CLIENT_ID; + if (!clientId) { + console.error( + 'Client ID not found in environment variables, cannot generate invite link.' + ); + return await ctx.sendMessage( + 'Sorry, my invite link is not available at this time. Please tell the bot developer to check their console.' + ); + } - const embed = this.client.embed(); - const row = new ActionRowBuilder().addComponents( - new ButtonBuilder() - .setLabel('Invite') - .setStyle(ButtonStyle.Link) - .setURL( - `https://discord.com/api/oauth2/authorize?client_id=${clientId}&permissions=8&scope=bot%20applications.commands`, - ), - new ButtonBuilder().setLabel('My Server').setStyle(ButtonStyle.Link).setURL('https://discord.gg/STXurwnZD5'), - ); + const embed = this.client.embed(); + const row = new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setLabel('Invite') + .setStyle(ButtonStyle.Link) + .setURL( + `https://discord.com/api/oauth2/authorize?client_id=${clientId}&permissions=8&scope=bot%20applications.commands` + ), + new ButtonBuilder() + .setLabel('My Server') + .setStyle(ButtonStyle.Link) + .setURL('https://discord.gg/STXurwnZD5') + ); - return ctx.sendMessage({ - embeds: [ - embed - .setColor(this.client.color.main) - .setDescription( - `You can invite me by clicking the button below. Any bugs or outages? Join the support server!`, - ), - ], - components: [row], - }); - } + return await ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.main) + .setDescription( + `You can invite me by clicking the button below. Any bugs or outages? Join the support server!` + ), + ], + components: [row], + }); + } } diff --git a/src/commands/info/LavaLink.ts b/src/commands/info/LavaLink.ts index 32aa8f072..5eb3d5ed0 100644 --- a/src/commands/info/LavaLink.ts +++ b/src/commands/info/LavaLink.ts @@ -1,4 +1,4 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class LavaLink extends Command { constructor(client: Lavamusic) { @@ -27,26 +27,43 @@ export default class LavaLink extends Command { slashCommand: true, }); } - public async run(client: Lavamusic, ctx: Context): Promise { + public async run(client: Lavamusic, ctx: Context): Promise { const embed = this.client.embed(); - embed.setTitle("Lavalink Stats") - embed.setColor(this.client.color.main) - embed.setThumbnail(this.client.user.avatarURL({})) - embed.setTimestamp() - client.shoukaku.nodes.forEach((node) => { + embed.setTitle('Lavalink Stats'); + embed.setColor(this.client.color.main); + embed.setThumbnail(this.client.user.avatarURL({})); + embed.setTimestamp(); + client.shoukaku.nodes.forEach(node => { try { - embed.addFields({ name: "Name", value: `${node.name} (${node.stats ? "đŸŸĸ" : "🔴"})` }) - embed.addFields({ name: "Player", value: `${node.stats.players}` }) - embed.addFields({ name: "Playing Players", value: `${node.stats.playingPlayers}` }) - embed.addFields({ name: "Uptime", value: `${client.utils.formatTime(node.stats.uptime)}` }) - embed.addFields({ name: "Cores", value: `${node.stats.cpu.cores + " Core(s)"}` }) - embed.addFields({ name: "Memory Usage", value: `${client.utils.formatBytes(node.stats.memory.used)}/${client.utils.formatBytes(node.stats.memory.reservable)}` }) - embed.addFields({ name: "System Load", value: `${(Math.round(node.stats.cpu.systemLoad * 100) / 100).toFixed(2)}%` }) - embed.addFields({ name: "Lavalink Load", value: `${(Math.round(node.stats.cpu.lavalinkLoad * 100) / 100).toFixed(2)}%` }) + embed.addFields({ + name: 'Name', + value: `${node.name} (${node.stats ? 'đŸŸĸ' : '🔴'})`, + }); + embed.addFields({ name: 'Player', value: `${node.stats.players}` }); + embed.addFields({ name: 'Playing Players', value: `${node.stats.playingPlayers}` }); + embed.addFields({ + name: 'Uptime', + value: `${client.utils.formatTime(node.stats.uptime)}`, + }); + embed.addFields({ name: 'Cores', value: `${node.stats.cpu.cores + ' Core(s)'}` }); + embed.addFields({ + name: 'Memory Usage', + value: `${client.utils.formatBytes( + node.stats.memory.used + )}/${client.utils.formatBytes(node.stats.memory.reservable)}`, + }); + embed.addFields({ + name: 'System Load', + value: `${(Math.round(node.stats.cpu.systemLoad * 100) / 100).toFixed(2)}%`, + }); + embed.addFields({ + name: 'Lavalink Load', + value: `${(Math.round(node.stats.cpu.lavalinkLoad * 100) / 100).toFixed(2)}%`, + }); } catch (e) { console.log(e); } }); return await ctx.sendMessage({ embeds: [embed] }); } -} \ No newline at end of file +} diff --git a/src/commands/info/Ping.ts b/src/commands/info/Ping.ts index 3ebfd591d..1a63e1fb6 100644 --- a/src/commands/info/Ping.ts +++ b/src/commands/info/Ping.ts @@ -1,59 +1,61 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Ping extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'ping', - description: { - content: "Shows the bot's ping", - examples: ['ping'], - usage: 'ping', - }, - category: 'general', - aliases: ['pong'], - cooldown: 3, - args: false, - player: { - voice: false, - dj: false, - active: false, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: [], - }, - slashCommand: true, - options: [], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const msg = await ctx.sendDeferMessage('Pinging...'); + constructor(client: Lavamusic) { + super(client, { + name: 'ping', + description: { + content: 'Shows the bot\'s ping', + examples: ['ping'], + usage: 'ping', + }, + category: 'general', + aliases: ['pong'], + cooldown: 3, + args: false, + player: { + voice: false, + dj: false, + active: false, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: [], + }, + slashCommand: true, + options: [], + }); + } + public async run(client: Lavamusic, ctx: Context): Promise { + const msg = await ctx.sendDeferMessage('Pinging...'); - const embed = client - .embed() - .setAuthor({ name: 'Pong', iconURL: this.client.user.displayAvatarURL() }) - .setColor(this.client.color.main) - .addFields([ - { - name: 'Bot Latency', - value: `\`\`\`ini\n[ ${msg.createdTimestamp - ctx.createdTimestamp}ms ]\n\`\`\``, - inline: true, - }, - { - name: 'API Latency', - value: `\`\`\`ini\n[ ${Math.round(ctx.client.ws.ping)}ms ]\n\`\`\``, - inline: true, - }, - ]) - .setFooter({ - text: `Requested by ${ctx.author.tag}`, - iconURL: ctx.author.avatarURL({}), - }) - .setTimestamp(); - return await ctx.editMessage({ content: '', embeds: [embed] }); - } + const embed = client + .embed() + .setAuthor({ name: 'Pong', iconURL: this.client.user.displayAvatarURL() }) + .setColor(this.client.color.main) + .addFields([ + { + name: 'Bot Latency', + value: `\`\`\`ini\n[ ${ + msg.createdTimestamp - ctx.createdTimestamp + }ms ]\n\`\`\``, + inline: true, + }, + { + name: 'API Latency', + value: `\`\`\`ini\n[ ${Math.round(ctx.client.ws.ping)}ms ]\n\`\`\``, + inline: true, + }, + ]) + .setFooter({ + text: `Requested by ${ctx.author.tag}`, + iconURL: ctx.author.avatarURL({}), + }) + .setTimestamp(); + return await ctx.editMessage({ content: '', embeds: [embed] }); + } } /** diff --git a/src/commands/music/Autoplay.ts b/src/commands/music/Autoplay.ts index d0087c4e5..b1a5ae5d0 100644 --- a/src/commands/music/Autoplay.ts +++ b/src/commands/music/Autoplay.ts @@ -1,47 +1,47 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Autoplay extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'autoplay', - description: { - content: 'Toggles autoplay', - examples: ['autoplay'], - usage: 'autoplay', - }, - category: 'music', - aliases: ['ap'], - cooldown: 3, - args: false, - player: { - voice: true, - dj: true, - active: true, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: [], - }, - slashCommand: true, - options: [], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const player = client.queue.get(ctx.guild.id); - const embed = this.client.embed(); + constructor(client: Lavamusic) { + super(client, { + name: 'autoplay', + description: { + content: 'Toggles autoplay', + examples: ['autoplay'], + usage: 'autoplay', + }, + category: 'music', + aliases: ['ap'], + cooldown: 3, + args: false, + player: { + voice: true, + dj: true, + active: true, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: [], + }, + slashCommand: true, + options: [], + }); + } + public async run(client: Lavamusic, ctx: Context): Promise { + const player = client.queue.get(ctx.guild.id); + const embed = this.client.embed(); - const autoplay = player.autoplay; - if (!autoplay) { - embed.setDescription(`Autoplay has been enabled`).setColor(client.color.main); - player.setAutoplay(true); - } else { - embed.setDescription(`Autoplay has been disabled`).setColor(client.color.main); - player.setAutoplay(false); + const autoplay = player.autoplay; + if (!autoplay) { + embed.setDescription(`Autoplay has been enabled`).setColor(client.color.main); + player.setAutoplay(true); + } else { + embed.setDescription(`Autoplay has been disabled`).setColor(client.color.main); + player.setAutoplay(false); + } + ctx.sendMessage({ embeds: [embed] }); } - ctx.sendMessage({ embeds: [embed] }); - } } /** diff --git a/src/commands/music/ClearQueue.ts b/src/commands/music/ClearQueue.ts index fb9b71686..8359bbb0b 100644 --- a/src/commands/music/ClearQueue.ts +++ b/src/commands/music/ClearQueue.ts @@ -1,46 +1,50 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class ClearQueue extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'clearqueue', - description: { - content: 'Clears the queue', - examples: ['clearqueue'], - usage: 'clearqueue', - }, - category: 'music', - aliases: ['cq'], - cooldown: 3, - args: false, - player: { - voice: true, - dj: true, - active: true, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: [], - }, - slashCommand: true, - options: [], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const player = client.queue.get(ctx.guild.id); - const embed = this.client.embed(); - if (!player.queue.length) - return ctx.sendMessage({ - embeds: [embed.setColor(this.client.color.red).setDescription('There are no songs in the queue.')], - }); - player.queue = []; + constructor(client: Lavamusic) { + super(client, { + name: 'clearqueue', + description: { + content: 'Clears the queue', + examples: ['clearqueue'], + usage: 'clearqueue', + }, + category: 'music', + aliases: ['cq'], + cooldown: 3, + args: false, + player: { + voice: true, + dj: true, + active: true, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: [], + }, + slashCommand: true, + options: [], + }); + } + public async run(client: Lavamusic, ctx: Context): Promise { + const player = client.queue.get(ctx.guild.id); + const embed = this.client.embed(); + if (!player.queue.length) + return await ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.red) + .setDescription('There are no songs in the queue.'), + ], + }); + player.queue = []; - return ctx.sendMessage({ - embeds: [embed.setColor(this.client.color.main).setDescription(`Cleared the queue`)], - }); - } + return await ctx.sendMessage({ + embeds: [embed.setColor(this.client.color.main).setDescription(`Cleared the queue`)], + }); + } } /** diff --git a/src/commands/music/Grab.ts b/src/commands/music/Grab.ts index 29e3c7fb6..1b023b434 100644 --- a/src/commands/music/Grab.ts +++ b/src/commands/music/Grab.ts @@ -1,57 +1,64 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Grab extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'grab', - description: { - content: 'Grabs the current playing song', - examples: ['grab'], - usage: 'grab', - }, - category: 'music', - aliases: [], - cooldown: 3, - args: false, - player: { - voice: false, - dj: false, - active: true, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: [], - }, - slashCommand: true, - options: [], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const embed = client.embed().setColor(client.color.main); - let player = client.queue.get(ctx.guild.id); - let song = player.current; + constructor(client: Lavamusic) { + super(client, { + name: 'grab', + description: { + content: 'Grabs the current playing song', + examples: ['grab'], + usage: 'grab', + }, + category: 'music', + aliases: [], + cooldown: 3, + args: false, + player: { + voice: false, + dj: false, + active: true, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: [], + }, + slashCommand: true, + options: [], + }); + } + public async run(client: Lavamusic, ctx: Context): Promise { + const embed = client.embed().setColor(client.color.main); + let player = client.queue.get(ctx.guild.id); + let song = player.current; - try { - const dm = client - .embed() - .setTitle(`**${song.info.title}**`) - .setURL(song.info.uri) - .setThumbnail(song.info.thumbnail) - .setDescription( - `**Duration:** ${song.info.isStream ? 'LIVE' : client.utils.formatTime(song.info.length) - }\n**Requested by:** ${song.info.requester}\n**Link:** [Click here](${song.info.uri})`, - ) - .setColor(client.color.main); - await ctx.author.send({ embeds: [dm] }); - return ctx.sendMessage({ - embeds: [embed.setDescription(`**I sent you a DM.**`).setColor(client.color.green)], - }); - } catch (e) { - return ctx.sendMessage({ - embeds: [embed.setDescription(`**I couldn't send you a DM.**`).setColor(client.color.red)], - }); + try { + const dm = client + .embed() + .setTitle(`**${song.info.title}**`) + .setURL(song.info.uri) + .setThumbnail(song.info.thumbnail) + .setDescription( + `**Duration:** ${ + song.info.isStream ? 'LIVE' : client.utils.formatTime(song.info.length) + }\n**Requested by:** ${song.info.requester}\n**Link:** [Click here](${ + song.info.uri + })` + ) + .setColor(client.color.main); + await ctx.author.send({ embeds: [dm] }); + return await ctx.sendMessage({ + embeds: [embed.setDescription(`**I sent you a DM.**`).setColor(client.color.green)], + }); + } catch (e) { + return await ctx.sendMessage({ + embeds: [ + embed + .setDescription(`**I couldn't send you a DM.**`) + .setColor(client.color.red), + ], + }); + } } - } } diff --git a/src/commands/music/Join.ts b/src/commands/music/Join.ts index c7d61b8f6..e503a3c6e 100644 --- a/src/commands/music/Join.ts +++ b/src/commands/music/Join.ts @@ -1,54 +1,63 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Join extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'join', - description: { - content: 'Joins the voice channel', - examples: ['join'], - usage: 'join', - }, - category: 'music', - aliases: ['j'], - cooldown: 3, - args: false, - player: { - voice: true, - dj: false, - active: false, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: [], - }, - slashCommand: true, - options: [], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - let player = client.queue.get(ctx.guild.id); - const embed = this.client.embed(); - if (!player) { - const vc = ctx.member as any; - player = await client.queue.create(ctx.guild, vc.voice.channel, ctx.channel, client.shoukaku.getNode()); - return ctx.sendMessage({ - embeds: [ - embed.setColor(this.client.color.main).setDescription(`Joined <#${player.player.connection.channelId}>`), - ], - }); - } else { - return ctx.sendMessage({ - embeds: [ - embed - .setColor(this.client.color.main) - .setDescription(`I'm already connected to <#${player.player.connection.channelId}>`), - ], - }); + constructor(client: Lavamusic) { + super(client, { + name: 'join', + description: { + content: 'Joins the voice channel', + examples: ['join'], + usage: 'join', + }, + category: 'music', + aliases: ['j'], + cooldown: 3, + args: false, + player: { + voice: true, + dj: false, + active: false, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: [], + }, + slashCommand: true, + options: [], + }); + } + public async run(client: Lavamusic, ctx: Context): Promise { + let player = client.queue.get(ctx.guild.id); + const embed = this.client.embed(); + if (!player) { + const vc = ctx.member as any; + player = await client.queue.create( + ctx.guild, + vc.voice.channel, + ctx.channel, + client.shoukaku.getNode() + ); + return await ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.main) + .setDescription(`Joined <#${player.player.connection.channelId}>`), + ], + }); + } else { + return await ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.main) + .setDescription( + `I'm already connected to <#${player.player.connection.channelId}>` + ), + ], + }); + } } - } } /** diff --git a/src/commands/music/Leave.ts b/src/commands/music/Leave.ts index f2637c7de..f878b1f90 100644 --- a/src/commands/music/Leave.ts +++ b/src/commands/music/Leave.ts @@ -1,49 +1,55 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Leave extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'leave', - description: { - content: 'Leaves the voice channel', - examples: ['leave'], - usage: 'leave', - }, - category: 'music', - aliases: ['dc'], - cooldown: 3, - args: false, - player: { - voice: true, - dj: true, - active: false, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: [], - }, - slashCommand: true, - options: [], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const player = client.queue.get(ctx.guild.id); - const embed = this.client.embed(); - if (player) { - ctx.sendMessage({ - embeds: [ - embed.setColor(this.client.color.main).setDescription(`Left <#${player.player.connection.channelId}>`), - ], - }); - player.destroy(); - } else { - ctx.sendMessage({ - embeds: [embed.setColor(this.client.color.red).setDescription(`I'm not in a voice channel`)], - }); + constructor(client: Lavamusic) { + super(client, { + name: 'leave', + description: { + content: 'Leaves the voice channel', + examples: ['leave'], + usage: 'leave', + }, + category: 'music', + aliases: ['dc'], + cooldown: 3, + args: false, + player: { + voice: true, + dj: true, + active: false, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: [], + }, + slashCommand: true, + options: [], + }); + } + public async run(client: Lavamusic, ctx: Context): Promise { + const player = client.queue.get(ctx.guild.id); + const embed = this.client.embed(); + if (player) { + ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.main) + .setDescription(`Left <#${player.player.connection.channelId}>`), + ], + }); + player.destroy(); + } else { + ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.red) + .setDescription(`I'm not in a voice channel`), + ], + }); + } } - } } /** diff --git a/src/commands/music/Loop.ts b/src/commands/music/Loop.ts index 6ddb8d7c3..f7253b0bc 100644 --- a/src/commands/music/Loop.ts +++ b/src/commands/music/Loop.ts @@ -1,55 +1,61 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Loop extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'loop', - description: { - content: 'loop the current song or the queue', - examples: ['loop', 'loop queue', 'loop song'], - usage: 'loop', - }, - category: 'general', - aliases: ['loop'], - cooldown: 3, - args: false, - player: { - voice: true, - dj: false, - active: true, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: [], - }, - slashCommand: true, - options: [], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const embed = client.embed().setColor(client.color.main); - const player = client.queue.get(ctx.guild.id); - - switch (player.loop) { - case 'off': - player.loop = 'repeat'; - return ctx.sendMessage({ - embeds: [embed.setDescription(`**Looping the song**`).setColor(client.color.main)], - }); - case 'repeat': - player.loop = 'queue'; - return ctx.sendMessage({ - embeds: [embed.setDescription(`**Looping the queue**`).setColor(client.color.main)], - }); - case 'queue': - player.loop = 'off'; - return ctx.sendMessage({ - embeds: [embed.setDescription(`**Looping is now off**`).setColor(client.color.main)], + constructor(client: Lavamusic) { + super(client, { + name: 'loop', + description: { + content: 'loop the current song or the queue', + examples: ['loop', 'loop queue', 'loop song'], + usage: 'loop', + }, + category: 'general', + aliases: ['loop'], + cooldown: 3, + args: false, + player: { + voice: true, + dj: false, + active: true, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: [], + }, + slashCommand: true, + options: [], }); } - } + public async run(client: Lavamusic, ctx: Context): Promise { + const embed = client.embed().setColor(client.color.main); + const player = client.queue.get(ctx.guild.id); + + switch (player.loop) { + case 'off': + player.loop = 'repeat'; + return await ctx.sendMessage({ + embeds: [ + embed.setDescription(`**Looping the song**`).setColor(client.color.main), + ], + }); + case 'repeat': + player.loop = 'queue'; + return await ctx.sendMessage({ + embeds: [ + embed.setDescription(`**Looping the queue**`).setColor(client.color.main), + ], + }); + case 'queue': + player.loop = 'off'; + return await ctx.sendMessage({ + embeds: [ + embed.setDescription(`**Looping is now off**`).setColor(client.color.main), + ], + }); + } + } } /** diff --git a/src/commands/music/Nowplaying.ts b/src/commands/music/Nowplaying.ts index 652244610..590b11ab0 100644 --- a/src/commands/music/Nowplaying.ts +++ b/src/commands/music/Nowplaying.ts @@ -1,52 +1,56 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Nowplaying extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'nowplaying', - description: { - content: 'Shows the currently playing song', - examples: ['nowplaying'], - usage: 'nowplaying', - }, - category: 'music', - aliases: ['np'], - cooldown: 3, - args: false, - player: { - voice: true, - dj: false, - active: true, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: [], - }, - slashCommand: true, - options: [], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const player = client.queue.get(ctx.guild.id); + constructor(client: Lavamusic) { + super(client, { + name: 'nowplaying', + description: { + content: 'Shows the currently playing song', + examples: ['nowplaying'], + usage: 'nowplaying', + }, + category: 'music', + aliases: ['np'], + cooldown: 3, + args: false, + player: { + voice: true, + dj: false, + active: true, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: [], + }, + slashCommand: true, + options: [], + }); + } + public async run(client: Lavamusic, ctx: Context): Promise { + const player = client.queue.get(ctx.guild.id); - const track = player.current; - const position = player.player.position; - const duration = track.info.length; - const bar = client.utils.progressBar(position, duration, 20); - const embed1 = this.client - .embed() - .setColor(this.client.color.main) - .setAuthor({ name: 'Now Playing', iconURL: ctx.guild.iconURL({}) }) - .setThumbnail(track.info.thumbnail) - .setDescription(`[${track.info.title}](${track.info.uri}) - Request By: ${track.info.requester}\n\n\`${bar}\``) - .addFields({ - name: '\u200b', - value: `\`${client.utils.formatTime(position)} / ${client.utils.formatTime(duration)}\``, - }); - return ctx.sendMessage({ embeds: [embed1] }); - } + const track = player.current; + const position = player.player.position; + const duration = track.info.length; + const bar = client.utils.progressBar(position, duration, 20); + const embed1 = this.client + .embed() + .setColor(this.client.color.main) + .setAuthor({ name: 'Now Playing', iconURL: ctx.guild.iconURL({}) }) + .setThumbnail(track.info.thumbnail) + .setDescription( + `[${track.info.title}](${track.info.uri}) - Request By: ${track.info.requester}\n\n\`${bar}\`` + ) + .addFields({ + name: '\u200b', + value: `\`${client.utils.formatTime(position)} / ${client.utils.formatTime( + duration + )}\``, + }); + return await ctx.sendMessage({ embeds: [embed1] }); + } } /** diff --git a/src/commands/music/Pause.ts b/src/commands/music/Pause.ts index 407873cf9..818b4f1a7 100644 --- a/src/commands/music/Pause.ts +++ b/src/commands/music/Pause.ts @@ -1,47 +1,51 @@ -import { Lavamusic, Context, Command } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Pause extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'pause', - description: { - content: 'Pauses the current song', - examples: ['pause'], - usage: 'pause', - }, - category: 'music', - aliases: [], - cooldown: 3, - args: false, - player: { - voice: true, - dj: false, - active: true, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: [], - }, - slashCommand: true, - options: [], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const player = client.queue.get(ctx.guild.id); - const embed = this.client.embed(); - if (!player.paused) { - player.pause(); - return ctx.sendMessage({ - embeds: [embed.setColor(this.client.color.main).setDescription(`Paused the song`)], - }); - } else { - return ctx.sendMessage({ - embeds: [embed.setColor(this.client.color.red).setDescription(`The song is already paused`)], - }); + constructor(client: Lavamusic) { + super(client, { + name: 'pause', + description: { + content: 'Pauses the current song', + examples: ['pause'], + usage: 'pause', + }, + category: 'music', + aliases: [], + cooldown: 3, + args: false, + player: { + voice: true, + dj: false, + active: true, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: [], + }, + slashCommand: true, + options: [], + }); + } + public async run(client: Lavamusic, ctx: Context): Promise { + const player = client.queue.get(ctx.guild.id); + const embed = this.client.embed(); + if (!player.paused) { + player.pause(); + return await ctx.sendMessage({ + embeds: [embed.setColor(this.client.color.main).setDescription(`Paused the song`)], + }); + } else { + return await ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.red) + .setDescription(`The song is already paused`), + ], + }); + } } - } } /** diff --git a/src/commands/music/Play.ts b/src/commands/music/Play.ts index 0ee5f281a..1acb9a229 100644 --- a/src/commands/music/Play.ts +++ b/src/commands/music/Play.ts @@ -1,136 +1,163 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Play extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'play', - description: { - content: 'Plays a song from YouTube or Spotify', - examples: [ - 'play https://www.youtube.com/watch?v=QH2-TGUlwu4', - 'play https://open.spotify.com/track/6WrI0LAC5M1Rw2MnX2ZvEg', - ], - usage: 'play ', - }, - category: 'music', - aliases: ['p'], - cooldown: 3, - args: true, - player: { - voice: true, - dj: false, - active: false, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks', 'Connect', 'Speak'], - user: [], - }, - slashCommand: true, - options: [ - { - name: 'song', - description: 'The song you want to play', - type: 3, - required: true, - autocomplete: true, - }, - ], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const query = args.join(' '); - let player = client.queue.get(ctx.guild.id); - const vc = ctx.member as any; - if (!player) - player = await client.queue.create(ctx.guild, vc.voice.channel, ctx.channel, client.shoukaku.getNode()); - - const res = await this.client.queue.search(query); - const embed = this.client.embed(); - switch (res.loadType) { - case 'LOAD_FAILED': - ctx.sendMessage({ - embeds: [embed.setColor(this.client.color.red).setDescription('There was an error while searching.')], - }); - break; - case 'NO_MATCHES': - ctx.sendMessage({ - embeds: [embed.setColor(this.client.color.red).setDescription('There were no results found.')], - }); - break; - case 'TRACK_LOADED': - const track = player.buildTrack(res.tracks[0], ctx.author); - if (player.queue.length > client.config.maxQueueSize) - return ctx.sendMessage({ - embeds: [ - embed - .setColor(this.client.color.red) - .setDescription(`The queue is too long. The maximum length is ${client.config.maxQueueSize} songs.`), + constructor(client: Lavamusic) { + super(client, { + name: 'play', + description: { + content: 'Plays a song from YouTube or Spotify', + examples: [ + 'play https://www.youtube.com/watch?v=QH2-TGUlwu4', + 'play https://open.spotify.com/track/6WrI0LAC5M1Rw2MnX2ZvEg', + ], + usage: 'play ', + }, + category: 'music', + aliases: ['p'], + cooldown: 3, + args: true, + player: { + voice: true, + dj: false, + active: false, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks', 'Connect', 'Speak'], + user: [], + }, + slashCommand: true, + options: [ + { + name: 'song', + description: 'The song you want to play', + type: 3, + required: true, + autocomplete: true, + }, ], - }); - player.queue.push(track); - await player.isPlaying(); - ctx.sendMessage({ - embeds: [ - embed - .setColor(this.client.color.main) - .setDescription(`Added [${res.tracks[0].info.title}](${res.tracks[0].info.uri}) to the queue.`), - ], }); - break; - case 'PLAYLIST_LOADED': - if (res.length > client.config.maxPlaylistSize) - return ctx.sendMessage({ - embeds: [ - embed - .setColor(this.client.color.red) - .setDescription( - `The playlist is too long. The maximum length is ${client.config.maxPlaylistSize} songs.`, - ), - ], - }); - for (const track of res.tracks) { - const pl = player.buildTrack(track, ctx.author); - if (player.queue.length > client.config.maxQueueSize) - return ctx.sendMessage({ - embeds: [ - embed - .setColor(this.client.color.red) - .setDescription(`The queue is too long. The maximum length is ${client.config.maxQueueSize} songs.`), - ], - }); - player.queue.push(pl); + } + public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { + const query = args.join(' '); + let player = client.queue.get(ctx.guild.id); + const vc = ctx.member as any; + if (!player) + player = await client.queue.create( + ctx.guild, + vc.voice.channel, + ctx.channel, + client.shoukaku.getNode() + ); + + const res = await this.client.queue.search(query); + const embed = this.client.embed(); + switch (res.loadType) { + case 'LOAD_FAILED': + ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.red) + .setDescription('There was an error while searching.'), + ], + }); + break; + case 'NO_MATCHES': + ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.red) + .setDescription('There were no results found.'), + ], + }); + break; + case 'TRACK_LOADED': { + const track = player.buildTrack(res.tracks[0], ctx.author); + if (player.queue.length > client.config.maxQueueSize) + return await ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.red) + .setDescription( + `The queue is too long. The maximum length is ${client.config.maxQueueSize} songs.` + ), + ], + }); + player.queue.push(track); + await player.isPlaying(); + ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.main) + .setDescription( + `Added [${res.tracks[0].info.title}](${res.tracks[0].info.uri}) to the queue.` + ), + ], + }); + break; + } + case 'PLAYLIST_LOADED': + if (res.length > client.config.maxPlaylistSize) + return await ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.red) + .setDescription( + `The playlist is too long. The maximum length is ${client.config.maxPlaylistSize} songs.` + ), + ], + }); + for (const track of res.tracks) { + const pl = player.buildTrack(track, ctx.author); + if (player.queue.length > client.config.maxQueueSize) + return await ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.red) + .setDescription( + `The queue is too long. The maximum length is ${client.config.maxQueueSize} songs.` + ), + ], + }); + player.queue.push(pl); + } + await player.isPlaying(); + ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.main) + .setDescription(`Added ${res.tracks.length} songs to the queue.`), + ], + }); + break; + case 'SEARCH_RESULT': { + const track1 = player.buildTrack(res.tracks[0], ctx.author); + if (player.queue.length > client.config.maxQueueSize) + return await ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.red) + .setDescription( + `The queue is too long. The maximum length is ${client.config.maxQueueSize} songs.` + ), + ], + }); + player.queue.push(track1); + await player.isPlaying(); + ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.main) + .setDescription( + `Added [${res.tracks[0].info.title}](${res.tracks[0].info.uri}) to the queue.` + ), + ], + }); + break; + } } - await player.isPlaying(); - ctx.sendMessage({ - embeds: [ - embed.setColor(this.client.color.main).setDescription(`Added ${res.tracks.length} songs to the queue.`), - ], - }); - break; - case 'SEARCH_RESULT': - const track1 = player.buildTrack(res.tracks[0], ctx.author); - if (player.queue.length > client.config.maxQueueSize) - return ctx.sendMessage({ - embeds: [ - embed - .setColor(this.client.color.red) - .setDescription(`The queue is too long. The maximum length is ${client.config.maxQueueSize} songs.`), - ], - }); - player.queue.push(track1); - await player.isPlaying(); - ctx.sendMessage({ - embeds: [ - embed - .setColor(this.client.color.main) - .setDescription(`Added [${res.tracks[0].info.title}](${res.tracks[0].info.uri}) to the queue.`), - ], - }); - break; } - } } /** diff --git a/src/commands/music/Queue.ts b/src/commands/music/Queue.ts index 53c4b7a49..df3fc51cf 100644 --- a/src/commands/music/Queue.ts +++ b/src/commands/music/Queue.ts @@ -1,68 +1,74 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Queue extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'queue', - description: { - content: 'Shows the current queue', - examples: ['queue'], - usage: 'queue', - }, - category: 'music', - aliases: ['q'], - cooldown: 3, - args: false, - player: { - voice: true, - dj: false, - active: true, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: [], - }, - slashCommand: true, - options: [], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const player = client.queue.get(ctx.guild.id); - if (player.queue.length === 0) - return ctx.sendMessage({ - embeds: [ - this.client - .embed() - .setColor(this.client.color.main) - .setDescription( - `Now playing: [${player.current.info.title}](${player.current.info.uri}) - Request By: ${player.current?.info.requester - } - Duration: ${player.current.info.isStream ? 'LIVE' : this.client.utils.formatTime(player.current.info.length) - }`, - ), - ], - }); - const queue = player.queue.map( - (track, index) => - `${index + 1}. [${track.info.title}](${track.info.uri}) - Request By: ${track?.info.requester} - Duration: ${track.info.isStream ? 'LIVE' : this.client.utils.formatTime(track.info.length) - }`, - ); - let chunks = client.utils.chunk(queue, 10) as any; - if (chunks.length === 0) chunks = 1; - const pages = []; - for (let i = 0; i < chunks.length; i++) { - const embed = this.client - .embed() - .setColor(this.client.color.main) - .setAuthor({ name: 'Queue', iconURL: ctx.guild.iconURL({}) }) - .setDescription(chunks[i].join('\n')) - .setFooter({ text: `Page ${i + 1} of ${chunks.length}` }); - pages.push(embed); + constructor(client: Lavamusic) { + super(client, { + name: 'queue', + description: { + content: 'Shows the current queue', + examples: ['queue'], + usage: 'queue', + }, + category: 'music', + aliases: ['q'], + cooldown: 3, + args: false, + player: { + voice: true, + dj: false, + active: true, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: [], + }, + slashCommand: true, + options: [], + }); } + public async run(client: Lavamusic, ctx: Context): Promise { + const player = client.queue.get(ctx.guild.id); + if (player.queue.length === 0) + return await ctx.sendMessage({ + embeds: [ + this.client + .embed() + .setColor(this.client.color.main) + .setDescription( + `Now playing: [${player.current.info.title}](${ + player.current.info.uri + }) - Request By: ${player.current?.info.requester} - Duration: ${ + player.current.info.isStream + ? 'LIVE' + : this.client.utils.formatTime(player.current.info.length) + }` + ), + ], + }); + const queue = player.queue.map( + (track, index) => + `${index + 1}. [${track.info.title}](${track.info.uri}) - Request By: ${track?.info + .requester} - Duration: ${ + track.info.isStream ? 'LIVE' : this.client.utils.formatTime(track.info.length) + }` + ); + let chunks = client.utils.chunk(queue, 10) as any; + if (chunks.length === 0) chunks = 1; + const pages = []; + for (let i = 0; i < chunks.length; i++) { + const embed = this.client + .embed() + .setColor(this.client.color.main) + .setAuthor({ name: 'Queue', iconURL: ctx.guild.iconURL({}) }) + .setDescription(chunks[i].join('\n')) + .setFooter({ text: `Page ${i + 1} of ${chunks.length}` }); + pages.push(embed); + } - return client.utils.paginate(ctx, pages); - } + return await client.utils.paginate(ctx, pages); + } } /** diff --git a/src/commands/music/Remove.ts b/src/commands/music/Remove.ts index 7a6633a2e..2a819613b 100644 --- a/src/commands/music/Remove.ts +++ b/src/commands/music/Remove.ts @@ -1,66 +1,84 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Remove extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'remove', - description: { - content: 'Removes a song from the queue', - examples: ['remove 1'], - usage: 'remove ', - }, - category: 'music', - aliases: ['rm'], - cooldown: 3, - args: true, - player: { - voice: true, - dj: true, - active: true, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: [], - }, - slashCommand: true, - options: [ - { - name: 'song', - description: 'The song number', - type: 4, - required: true, - }, - ], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const player = client.queue.get(ctx.guild.id); - const embed = this.client.embed(); - if (!player.queue.length) - return ctx.sendMessage({ - embeds: [embed.setColor(this.client.color.red).setDescription('There are no songs in the queue.')], - }); - if (isNaN(Number(args[0]))) - return ctx.sendMessage({ - embeds: [embed.setColor(this.client.color.red).setDescription('That is not a valid number.')], - }); - if (Number(args[0]) > player.queue.length) - return ctx.sendMessage({ - embeds: [embed.setColor(this.client.color.red).setDescription('That is not a valid number.')], - }); - if (Number(args[0]) < 1) - return ctx.sendMessage({ - embeds: [embed.setColor(this.client.color.red).setDescription('That is not a valid number.')], - }); - player.remove(Number(args[0]) - 1); - return ctx.sendMessage({ - embeds: [ - embed.setColor(this.client.color.main).setDescription(`Removed song number ${Number(args[0])} from the queue`), - ], - }); - } + constructor(client: Lavamusic) { + super(client, { + name: 'remove', + description: { + content: 'Removes a song from the queue', + examples: ['remove 1'], + usage: 'remove ', + }, + category: 'music', + aliases: ['rm'], + cooldown: 3, + args: true, + player: { + voice: true, + dj: true, + active: true, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: [], + }, + slashCommand: true, + options: [ + { + name: 'song', + description: 'The song number', + type: 4, + required: true, + }, + ], + }); + } + public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { + const player = client.queue.get(ctx.guild.id); + const embed = this.client.embed(); + if (!player.queue.length) + return await ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.red) + .setDescription('There are no songs in the queue.'), + ], + }); + if (isNaN(Number(args[0]))) + return await ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.red) + .setDescription('That is not a valid number.'), + ], + }); + if (Number(args[0]) > player.queue.length) + return await ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.red) + .setDescription('That is not a valid number.'), + ], + }); + if (Number(args[0]) < 1) + return await ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.red) + .setDescription('That is not a valid number.'), + ], + }); + player.remove(Number(args[0]) - 1); + return await ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.main) + .setDescription(`Removed song number ${Number(args[0])} from the queue`), + ], + }); + } } /** diff --git a/src/commands/music/Resume.ts b/src/commands/music/Resume.ts index 601f328c2..7df7a639e 100644 --- a/src/commands/music/Resume.ts +++ b/src/commands/music/Resume.ts @@ -1,46 +1,50 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Resume extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'resume', - description: { - content: 'Resumes the current song', - examples: ['resume'], - usage: 'resume', - }, - category: 'music', - aliases: ['r'], - cooldown: 3, - args: false, - player: { - voice: true, - dj: false, - active: true, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: [], - }, - slashCommand: true, - options: [], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const player = client.queue.get(ctx.guild.id); - const embed = this.client.embed(); - if (!player.paused) - return ctx.sendMessage({ - embeds: [embed.setColor(this.client.color.red).setDescription('The player is not paused.')], - }); - player.pause(); + constructor(client: Lavamusic) { + super(client, { + name: 'resume', + description: { + content: 'Resumes the current song', + examples: ['resume'], + usage: 'resume', + }, + category: 'music', + aliases: ['r'], + cooldown: 3, + args: false, + player: { + voice: true, + dj: false, + active: true, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: [], + }, + slashCommand: true, + options: [], + }); + } + public async run(client: Lavamusic, ctx: Context): Promise { + const player = client.queue.get(ctx.guild.id); + const embed = this.client.embed(); + if (!player.paused) + return await ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.red) + .setDescription('The player is not paused.'), + ], + }); + player.pause(); - return ctx.sendMessage({ - embeds: [embed.setColor(this.client.color.main).setDescription(`Resumed the player`)], - }); - } + return await ctx.sendMessage({ + embeds: [embed.setColor(this.client.color.main).setDescription(`Resumed the player`)], + }); + } } /** diff --git a/src/commands/music/Search.ts b/src/commands/music/Search.ts index 00dc9fed9..df9564fdf 100644 --- a/src/commands/music/Search.ts +++ b/src/commands/music/Search.ts @@ -1,112 +1,132 @@ import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from 'discord.js'; -import { Command, Lavamusic, Context } from '../../structures/index'; + import { Song } from '../../structures/Dispatcher'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Search extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'search', - description: { - content: 'Searches for a song', - examples: ['search', 'search '], - usage: 'search', - }, - category: 'music', - aliases: ['search'], - cooldown: 3, - args: true, - player: { - voice: true, - dj: false, - active: false, - djPerm: null, - }, - permissions: { - dev: false, - client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], - user: [], - }, - slashCommand: true, - options: [ - { - name: 'song', - description: 'The song you want to search', - type: 3, - required: true, - }, - ], - }); - } - public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { - const embed = client.embed().setColor(client.color.main); - let player = client.queue.get(ctx.guild.id); - const query = args.join(' '); - if (!player) { - const vc = ctx.member as any; - player = await client.queue.create(ctx.guild, vc.voice.channel, ctx.channel, client.shoukaku.getNode()); + constructor(client: Lavamusic) { + super(client, { + name: 'search', + description: { + content: 'Searches for a song', + examples: ['search', 'search '], + usage: 'search', + }, + category: 'music', + aliases: ['search'], + cooldown: 3, + args: true, + player: { + voice: true, + dj: false, + active: false, + djPerm: null, + }, + permissions: { + dev: false, + client: ['SendMessages', 'ViewChannel', 'EmbedLinks'], + user: [], + }, + slashCommand: true, + options: [ + { + name: 'song', + description: 'The song you want to search', + type: 3, + required: true, + }, + ], + }); } - const res = await this.client.queue.search(query); - if (!res) - return ctx.sendMessage({ - embeds: [embed.setDescription(`**No results found**`).setColor(client.color.red)], - }); - let msg: any; - const row = new ActionRowBuilder().addComponents( - new ButtonBuilder().setCustomId('1').setLabel('1').setStyle(ButtonStyle.Primary), - new ButtonBuilder().setCustomId('2').setLabel('2').setStyle(ButtonStyle.Primary), - new ButtonBuilder().setCustomId('3').setLabel('3').setStyle(ButtonStyle.Primary), - new ButtonBuilder().setCustomId('4').setLabel('4').setStyle(ButtonStyle.Primary), - new ButtonBuilder().setCustomId('5').setLabel('5').setStyle(ButtonStyle.Primary), - ); - switch (res.loadType) { - case 'LOAD_FAILED': - ctx.sendMessage({ - embeds: [embed.setColor(this.client.color.red).setDescription('There was an error while searching.')], + public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { + const embed = client.embed().setColor(client.color.main); + let player = client.queue.get(ctx.guild.id); + const query = args.join(' '); + if (!player) { + const vc = ctx.member as any; + player = await client.queue.create( + ctx.guild, + vc.voice.channel, + ctx.channel, + client.shoukaku.getNode() + ); + } + const res = await this.client.queue.search(query); + if (!res) + return await ctx.sendMessage({ + embeds: [embed.setDescription(`**No results found**`).setColor(client.color.red)], + }); + const row = new ActionRowBuilder().addComponents( + new ButtonBuilder().setCustomId('1').setLabel('1').setStyle(ButtonStyle.Primary), + new ButtonBuilder().setCustomId('2').setLabel('2').setStyle(ButtonStyle.Primary), + new ButtonBuilder().setCustomId('3').setLabel('3').setStyle(ButtonStyle.Primary), + new ButtonBuilder().setCustomId('4').setLabel('4').setStyle(ButtonStyle.Primary), + new ButtonBuilder().setCustomId('5').setLabel('5').setStyle(ButtonStyle.Primary) + ); + switch (res.loadType) { + case 'LOAD_FAILED': + ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.red) + .setDescription('There was an error while searching.'), + ], + }); + break; + case 'NO_MATCHES': + ctx.sendMessage({ + embeds: [ + embed + .setColor(this.client.color.red) + .setDescription('There were no results found.'), + ], + }); + break; + case 'SEARCH_RESULT': { + const tracks = res.tracks.slice(0, 5); + const embeds = tracks.map( + (track: Song, index: number) => + `${index + 1}. [${track.info.title}](${track.info.uri}) - \`${ + track.info.author + }\`` + ); + await ctx.sendMessage({ + embeds: [embed.setDescription(embeds.join('\n'))], + components: [row], + }); + break; + } + } + const collector = ctx.channel.createMessageComponentCollector({ + filter: (f: any) => (f.user.id === ctx.author.id ? true : false && f.deferUpdate()), + max: 1, + time: 60000, + idle: 60000 / 2, }); - break; - case 'NO_MATCHES': - ctx.sendMessage({ - embeds: [embed.setColor(this.client.color.red).setDescription('There were no results found.')], + collector.on('collect', async (int: any) => { + for (let i = 0; i < res.tracks.length; i++) { + if (int.customId === `${i + 1}`) { + let track = res.tracks[i]; + track = player.buildTrack(track, ctx.author); + player.queue.push(track); + player.isPlaying(); + await ctx.editMessage({ + embeds: [ + embed.setDescription( + `Added [${track.info.title}](${track.info.uri}) to the queue` + ), + ], + components: [], + }); + } + } + return int.deferUpdate(); }); - break; - case 'SEARCH_RESULT': - const tracks = res.tracks.slice(0, 5); - const embeds = tracks.map( - (track: Song, index: number) => - `${index + 1}. [${track.info.title}](${track.info.uri}) - \`${track.info.author}\``, - ); - msg = await ctx.sendMessage({ - embeds: [embed.setDescription(embeds.join('\n'))], - components: [row], + + collector.on('end', async () => { + await ctx.editMessage({ components: [] }); }); - break; } - const collector = ctx.channel.createMessageComponentCollector({ - filter: (f: any) => (f.user.id === ctx.author.id ? true : false && f.deferUpdate()), - max: 1, - time: 60000, - idle: 60000 / 2, - }); - collector.on('collect', async (int: any) => { - for (let i = 0; i < res.tracks.length; i++) { - if (int.customId === `${i + 1}`) { - let track = res.tracks[i]; - track = player.buildTrack(track, ctx.author); - player.queue.push(track); - player.isPlaying(); - await ctx.editMessage({ - embeds: [embed.setDescription(`Added [${track.info.title}](${track.info.uri}) to the queue`)], - components: [], - }); - } - } - return await int.deferUpdate(); - }); - - collector.on('end', async () => { - await ctx.editMessage({ components: [] }); - }); - } } /** diff --git a/src/commands/music/Seek.ts b/src/commands/music/Seek.ts index b7cfd85de..c7524aec2 100644 --- a/src/commands/music/Seek.ts +++ b/src/commands/music/Seek.ts @@ -1,55 +1,57 @@ -import { Command, Lavamusic, Context } from '../../structures/index'; +import { Command, Context, Lavamusic } from '../../structures/index'; export default class Seek extends Command { - constructor(client: Lavamusic) { - super(client, { - name: 'seek', - description: { - content: 'Seeks to a certain time in the song', - examples: ['seek 1m, seek 1h 30m'], - usage: 'seek