diff --git a/.env.example b/.env.example
index 307dd77ef..8e9ab5b7a 100644
--- a/.env.example
+++ b/.env.example
@@ -1,25 +1,18 @@
-TOKEN= "" # Your bot token.
-CLIENT_ID= "" # Your bot's client ID (If this value is left blank, bots cannot be invited using /invite or /about commands.).
-DEFAULT_LANGUAGE= "EnglishUS" # Default language for bot
-PREFIX= "!" # Your prefix.
-OWNER_IDS= ["",""] # Your discord id (You can add multiple ids.).
-GUILD_ID= "" # Your server ID (If you want to use the bot for a single server).
-TOPGG= "" # Your Top.gg API key. Obtain this from https://top.gg
-KEEP_ALIVE= "false" # true for keep alive in https://replit.com
-LOG_CHANNEL_ID= "" # If you enter this, you will be able to receive the status of Lavalink nodes and guild join/leave logs through the corresponding channel.
-LOG_COMMANDS_ID= "" # The channel ID where command usage logs will be sent.
-BOT_STATUS= "online" # Your bot status (online, dnd, idle, invisible or offline).
-BOT_ACTIVITY_TYPE= 0 # Activity type is a number from 0 to 5. See more here: https://discord.com/developers/docs/topics/gateway-events#activity-object-activity-types
-BOT_ACTIVITY=" Lavamusic" # Your bot activity.
-DATABASE_URL= "" # Your database url (If you want to use sqlite, then you can leave it blank.).
-AUTO_NODE=" false" # true for auto node. It is given from lavainfo-api (https://lavainfo-api.deno.dev).
-SEARCH_ENGINE= "YouTubeMusic" # Search engine to be used when playing the song. You can use: YouTube, YouTubeMusic, SoundCloud, Spotify, Apple, Deezer, Yandex and JioSaavn
-MAX_PLAYLIST_SIZE= "100" # Max playlist size.
-MAX_QUEUE_SIZE= "100" # Max queue size.
-GENIUS_API= "" # Sign up and get your own api at (https://genius.com/) to fetch your lyrics (CLIENT TOKEN)
-
-# Configuration for multiple Lavalink servers
-LAVALINK_SERVERS = '[
- {"url":"localhost:2333","auth":"youshallnotpass","name":"Local Node","secure":false},
- {"url":"localhost:2333","auth":"youshallnotpass2","name":"Another Node","secure":false}
-]'
+TOKEN="" # Your bot token.
+CLIENT_ID="" # Your bot's client ID (If this value is left blank, bots cannot be invited using /invite or /about commands.).
+DEFAULT_LANGUAGE="EnglishUS" # Default language for bot
+PREFIX="!" # Your prefix.
+OWNER_IDS=["",""] # Your discord id (You can add multiple ids.).
+GUILD_ID="" # Your server ID (If you want to use the bot for a single server).
+TOPGG="" # Your Top.gg API key. Obtain this from https://top.gg
+KEEP_ALIVE="false" # true for keep alive in https://replit.com
+LOG_CHANNEL_ID="" # If you enter this, you will be able to receive the status of Lavalink nodes and guild join/leave logs through the corresponding channel.
+LOG_COMMANDS_ID="" # The channel ID where command usage logs will be sent.
+BOT_STATUS="online" # Your bot status (online, dnd, idle, invisible or offline).
+BOT_ACTIVITY_TYPE=0 # Activity type is a number from 0 to 5. See more here: https://discord.com/developers/docs/topics/gateway-events#activity-object-activity-types
+BOT_ACTIVITY=="Lavamusic" # Your bot activity.
+DATABASE_URL="" # Your database url (If you want to use sqlite, then you can leave it blank.).
+AUTO_NODE=="false" # true for auto node. It is given from lavainfo-api (https://lavainfo-api.deno.dev).
+SEARCH_ENGINE="YouTubeMusic" # Search engine to be used when playing the song. You can use: YouTube, YouTubeMusic, SoundCloud, Spotify, Apple, Deezer, Yandex and JioSaavn
+GENIUS_API="" # Sign up and get your own api at (https://genius.com/) to fetch your lyrics (CLIENT TOKEN)
+NODES=[{"id":"Local Node","host":"localhost","port":2333,"authorization":"youshallnotpass"}]
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml
index 22c14f9f6..fc85263e1 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yaml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yaml
@@ -43,8 +43,7 @@ body:
description: "Specify the version of Node.js that you are using."
placeholder: "e.g., 14.17.0"
validations:
- required: false
-
+ required: true
- type: input
id: java-version
attributes:
@@ -52,7 +51,7 @@ body:
description: "Specify the version of Java that you are using."
placeholder: "e.g., 17"
validations:
- required: false
+ required: true
- type: input
id: app-version
diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml
index 0076e841f..5777c6042 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.yaml
+++ b/.github/ISSUE_TEMPLATE/feature_request.yaml
@@ -61,4 +61,4 @@ body:
description: "Add any other context or screenshots that could help explain your feature request."
placeholder: "Additional context, links, or references"
validations:
- required: false
\ No newline at end of file
+ required: false
diff --git a/.gitignore b/.gitignore
index 6af8d2784..d9f01b479 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,7 +6,7 @@ yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
-
+bun.lockb
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
diff --git a/.hintrc b/.hintrc
new file mode 100644
index 000000000..f45382f88
--- /dev/null
+++ b/.hintrc
@@ -0,0 +1,6 @@
+{
+ "extends": ["development"],
+ "hints": {
+ "typescript-config/consistent-casing": "off"
+ }
+}
diff --git a/Dockerfile b/Dockerfile
index 67a223ae8..c99191f3b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,26 +3,16 @@ FROM node:22 AS builder
WORKDIR /opt/lavamusic/
-# Copy package files and install dependencies
+# Copy only package files and install dependencies
COPY package*.json ./
+RUN npm install --legacy-peer-deps
-# Install necessary tools and update npm
-RUN apt-get update && apt-get install -y openssl git \
- && npm install -g npm@latest
-RUN npm install
-RUN npm config set global --legacy-peer-deps
-
-# Copy source code
+# Copy source code and configuration
COPY . .
-# Copy tsconfig.json
-COPY tsconfig.json ./
-# Copy prisma
-COPY prisma ./prisma
-# Generate Prisma client
-RUN npx prisma db push
-# Build TypeScript
-RUN npm run build
+# Generate Prisma client and build TypeScript
+RUN npx prisma db push && \
+ npm run build
# Stage 2: Create production image
FROM node:22-slim
@@ -32,18 +22,20 @@ ENV NODE_ENV=production
WORKDIR /opt/lavamusic/
# Install necessary tools
-RUN apt-get update && apt-get install -y openssl
+RUN apt-get update && apt-get install -y --no-install-recommends openssl && \
+ rm -rf /var/lib/apt/lists/*
-# Copy compiled code and other necessary files from the builder stage
+# Copy compiled code and necessary files from the builder stage
COPY --from=builder /opt/lavamusic/dist ./dist
-COPY --from=builder /opt/lavamusic/src/utils/LavaLogo.txt ./src/utils/LavaLogo.txt
COPY --from=builder /opt/lavamusic/prisma ./prisma
COPY --from=builder /opt/lavamusic/scripts ./scripts
-COPY --from=builder /opt/lavamusic/package*.json ./
COPY --from=builder /opt/lavamusic/locales ./locales
+# Install production dependencies
+COPY --from=builder /opt/lavamusic/package*.json ./
RUN npm install --omit=dev
+# Generate Prisma client
RUN npx prisma generate
RUN npx prisma db push
@@ -53,12 +45,9 @@ RUN rm -rf /opt/lavamusic/application.yml && \
# Run as non-root user
RUN addgroup --gid 322 --system lavamusic && \
- adduser --uid 322 --system lavamusic
-
-# Change ownership of the folder
-RUN chown -R lavamusic:lavamusic /opt/lavamusic/
+ adduser --uid 322 --system lavamusic && \
+ chown -R lavamusic:lavamusic /opt/lavamusic/
-# Switch to the appropriate user
USER lavamusic
CMD ["node", "dist/index.js"]
diff --git a/Lavalink/example.application.yml b/Lavalink/example.application.yml
index d2ae0f771..7b309cbcd 100644
--- a/Lavalink/example.application.yml
+++ b/Lavalink/example.application.yml
@@ -42,7 +42,7 @@ plugins:
spotify:
clientId: "your client id"
clientSecret: "your client secret"
- spDc: "your sp dc cookie" # the sp dc cookie used for accessing the spotify lyrics api
+ # spDc: "your sp dc cookie" # the sp dc cookie used for accessing the spotify lyrics api
countryCode: "US" # the country code you want to use for filtering the artists top tracks. See https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
playlistLoadLimit: 6 # The number of pages at 100 tracks each
albumLoadLimit: 6 # The number of pages at 50 tracks each
@@ -101,15 +101,15 @@ lavalink:
- dependency: "com.github.appujet:jiosaavn-plugin:0.1.7"
repository: "https://jitpack.io"
- dependency: "com.dunctebot:skybot-lavalink-plugin:1.7.0"
- snapshot: false # set to true if you want to use snapshot builds.
+ snapshot: false # set to true if you want to use snapshot builds
- dependency: "com.github.topi314.lavasearch:lavasearch-plugin:1.0.0"
- snapshot: false # set to true if you want to use snapshot builds.
+ snapshot: false # set to true if you want to use snapshot builds
- dependency: "com.github.topi314.lavasrc:lavasrc-plugin:4.2.0"
- snapshot: false # set to true if you want to use snapshot builds.
+ snapshot: false # set to true if you want to use snapshot builds
- dependency: "com.github.topi314.sponsorblock:sponsorblock-plugin:3.0.1"
- snapshot: false # set to true if you want to use snapshot builds.
- - dependency: "dev.lavalink.youtube:youtube-plugin:1.7.2"
- snapshot: false # set to true if you want to use snapshot builds.
+ snapshot: false # set to true if you want to use snapshot builds
+ - dependency: "dev.lavalink.youtube:youtube-plugin:1.8.0"
+ snapshot: false # set to true if you want to use snapshot builds
pluginsDir: './plugins'
server:
password: "youshallnotpass"
diff --git a/README.md b/README.md
index 2a5ed466f..ff1aa3afc 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@
Lavamusic
- Lavamusic is a Discord music bot that uses Discord.js, Shoukaku, and TypeScript.
+
Lavamusic is a Discord music bot that uses Discord.js, lavalink-client, and TypeScript.
Invite Lavamusic
@@ -32,7 +32,7 @@
- User-friendly and Easy to Use
- Highly Configurable
- Customizable Prefix
-- Multilingual support
+- Multilingual support [Here](/Translation.md)
- Hybrid Command Handling (Slash and Normal Commands)
- Developed using TypeScript and Discord.js v14
- Advanced Music System
@@ -242,4 +242,4 @@ Thanks go to these wonderful people:
[license-shield]: https://img.shields.io/github/license/appujet/lavamusic.svg?style=for-the-badge
[license-url]: https://github.com/appujet/lavamusic/blob/master/LICENSE
[support-server]: https://discord.gg/PMpJnJaHmy
-[support-shield]: https://img.shields.io/discord/942117923001098260.svg?style=for-the-badge&logo=discord&colorB=7289DA
\ No newline at end of file
+[support-shield]: https://img.shields.io/discord/942117923001098260.svg?style=for-the-badge&logo=discord&colorB=7289DA
diff --git a/SECURITY.md b/SECURITY.md
deleted file mode 100644
index 034e84803..000000000
--- a/SECURITY.md
+++ /dev/null
@@ -1,21 +0,0 @@
-# Security Policy
-
-## Supported Versions
-
-Use this section to tell people about which versions of your project are
-currently being supported with security updates.
-
-| Version | Supported |
-| ------- | ------------------ |
-| 5.1.x | :white_check_mark: |
-| 5.0.x | :x: |
-| 4.0.x | :white_check_mark: |
-| < 4.0 | :x: |
-
-## Reporting a Vulnerability
-
-Use this section to tell people how to report a vulnerability.
-
-Tell them where to go, how often they can expect to get an update on a
-reported vulnerability, what to expect if the vulnerability is accepted or
-declined, etc.
diff --git a/Translation.md b/Translation.md
index 6655ed71a..0a2cbdeb3 100644
--- a/Translation.md
+++ b/Translation.md
@@ -6,7 +6,6 @@
2. 📋 Copy the contents of the `EnglishUS.json` file into the new file.
3. 🌐 Translate the strings in the new file to the desired language.
-
### 📚 Available Translations
- [x] English (US) - `EnglishUS.json` (Default)
@@ -42,7 +41,6 @@
- [ ] Ukrainian - `Ukrainian.json` (Not Started)
- [x] Vietnamese - `Vietnamese.json` [by @nhutlamm](https://github.com/nhutlamm) (Ai Translation - Not Accurate)
-
## 📚 How to Use the Translations
1. 📁 Create a new file in the `locales` directory with the name of the language in the format `language_code.json`. For example, `EnglishUS.json` for English, `SpanishES.json` for Spanish, etc.
@@ -51,8 +49,8 @@
3. 🌐 Translate the strings in the new file to the desired language.
-
## Have a language to contribute? 🎉
+
- Fork the repository.
- Add the translation file in the `locales` directory.
- Create a pull request with the changes.
@@ -65,60 +63,61 @@
- **Do not** add any new keys to the translation JSON file.
- **Do not** add any new directories to the repository.
-
-
## 📝 Translation JSON Structure
The translation JSON file should be structured as follows:
```json
{
- "category": {
- "command": {
- "description": "Description of the command.",
- "content": "Command content.",
- "key": "value"
- }
- }
+ "category": {
+ "command": {
+ "description": "Description of the command.",
+ "content": "Command content.",
+ "key": "value"
+ }
+ }
}
```
### Example Translation JSON
**EnglishUS:**
+
```json
{
- "cmd": {
- "ping": {
- "description": "Shows the bot's ping.",
- "content": "Pinging...",
- "bot_latency": "Bot Latency",
- "api_latency": "API Latency",
- "requested_by": "Requested by {author}"
- }
- }
+ "cmd": {
+ "ping": {
+ "description": "Shows the bot's ping.",
+ "content": "Pinging...",
+ "bot_latency": "Bot Latency",
+ "api_latency": "API Latency",
+ "requested_by": "Requested by {author}"
+ }
+ }
}
```
**Hindi:**
+
```json
{
- "cmd": {
- "ping": {
- "description": "बॉट का पिंग दिखाता है।",
- "content": "पिंगिंग...",
- "bot_latency": "पिंगिंग...",
- "api_latency": "एपीआई लेटेंसी",
- "requested_by": "{author} द्वारा अनुरोधित"
- }
- }
+ "cmd": {
+ "ping": {
+ "description": "बॉट का पिंग दिखाता है।",
+ "content": "पिंगिंग...",
+ "bot_latency": "पिंगिंग...",
+ "api_latency": "एपीआई लेटेंसी",
+ "requested_by": "{author} द्वारा अनुरोधित"
+ }
+ }
}
```
### Formatting Tags for i18n NPM
-To ensure `{}` are not removed during translations, use the format tags: `["{", "}"]`.
+To ensure `{}` are not removed during translations, use the format tags: `["{", "}"]`.
## 📚 Resources
+
- [i18n NPM](https://www.npmjs.com/package/i18n)
- [Discord Developer Portal - Locales](https://discord.com/developers/docs/reference#locales)
diff --git a/biome.json b/biome.json
index 0411b661d..47187d652 100644
--- a/biome.json
+++ b/biome.json
@@ -1,89 +1,85 @@
{
- "$schema": "https://biomejs.dev/schemas/1.9.0/schema.json",
- "organizeImports": {
- "enabled": true
- },
- "linter": {
- "enabled": true,
- "rules": {
- "all": true,
- "suspicious": {
- "noConfusingVoidType": "off",
- "noConsole": "off",
- "noConsoleLog": "off",
- "noEmptyBlockStatements": "off",
- "noEvolvingTypes": "off",
- "noExplicitAny": "off",
- "noGlobalIsFinite": "off",
- "noGlobalIsNan": "off",
- "useAwait": "off"
- },
- "style": {
- "noDefaultExport": "off",
- "noInferrableTypes": "off",
- "noNamespaceImport": "off",
- "noNonNullAssertion": "off",
- "noParameterAssign": "off",
- "useBlockStatements": "off",
- "useDefaultSwitchClause": "off",
- "useFilenamingConvention": "off",
- "useNamingConvention": "off",
- "useNumberNamespace": "off",
- "useSingleCaseStatement": "off"
- },
- "complexity": {
- "noBannedTypes": "off",
- "noForEach": "off",
- "noStaticOnlyClass": "off",
- "noExcessiveCognitiveComplexity": {
- "level": "warn",
- "options": {
- "maxAllowedComplexity": 255
- }
- }
- },
- "security": {
- "noGlobalEval": "off"
- },
- "correctness": {
- "noNodejsModules": "off",
- "noVoidTypeReturn": "off"
- },
- "performance": {
- "noBarrelFile": "off",
- "useTopLevelRegex": "off"
- }
- }
- },
- "formatter": {
- "enabled": true,
- "indentWidth": 4,
- "indentStyle": "space",
- "lineEnding": "crlf",
- "lineWidth": 140,
- "formatWithErrors": true
- },
- "json": {
- "linter": {
- "enabled": true
- },
- "formatter": {
- "enabled": true,
- "indentWidth": 2,
- "lineEnding": "crlf",
- "lineWidth": 80
- }
- },
- "javascript": {
- "formatter": {
- "quoteStyle": "double",
- "arrowParentheses": "always",
- "bracketSameLine": true,
- "semicolons": "always"
- }
- },
- "files": {
- "ignoreUnknown": false,
- "ignore": [".vscode", "dist", "locales", "node_modules"]
- }
+ "$schema": "https://biomejs.dev/schemas/1.9.0/schema.json",
+ "vcs": {
+ "enabled": true,
+ "clientKind": "git",
+ "useIgnoreFile": true,
+ "defaultBranch": "main"
+ },
+ "files": {
+ "ignoreUnknown": true,
+ "ignore": ["node_modules/", "dist", "package.json", "tsconfig.json", ".vscode"]
+ },
+ "formatter": {
+ "enabled": true,
+ "indentStyle": "tab",
+ "indentWidth": 2,
+ "lineWidth": 120,
+ "lineEnding": "crlf",
+ "formatWithErrors": true
+ },
+ "organizeImports": {
+ "enabled": true
+ },
+ "linter": {
+ "enabled": true,
+ "rules": {
+ "recommended": false,
+ "all": true,
+ "security": {
+ "noGlobalEval": "off"
+ },
+ "suspicious": {
+ "noExplicitAny": "off",
+ "noAssignInExpressions": "off",
+ "useAwait": "off",
+ "noConfusingVoidType": "off",
+ "noAsyncPromiseExecutor": "off",
+ "noUnsafeDeclarationMerging": "off",
+ "noEmptyInterface": "off",
+ "noThenProperty": "off"
+ },
+ "correctness": {
+ "noNodejsModules": "off",
+ "useImportExtensions": "off",
+ "noUnusedFunctionParameters": "off",
+ "noUnusedVariables": "off"
+ },
+ "style": {
+ "noDefaultExport": "off",
+ "useBlockStatements": "off",
+ "noParameterProperties": "off",
+ "useNamingConvention": "off",
+ "noNonNullAssertion": "off",
+ "useForOf": "off",
+ "useDefaultSwitchClause": "off",
+ "noParameterAssign": "off",
+ "useFilenamingConvention": "off",
+ "useEnumInitializers": "off",
+ "useExplicitLengthCheck": "off",
+ "noNamespaceImport": "off",
+ "noInferrableTypes": "info"
+ },
+ "complexity": {
+ "noForEach": "off",
+ "noExcessiveCognitiveComplexity": "off",
+ "noUselessConstructor": "off",
+ "noBannedTypes": "off"
+ },
+ "performance": {
+ "noBarrelFile": "off",
+ "noDelete": "off",
+ "noReExportAll": "off",
+ "useTopLevelRegex": "off"
+ }
+ }
+ },
+ "javascript": {
+ "formatter": {
+ "quoteStyle": "single",
+ "semicolons": "always",
+ "arrowParentheses": "asNeeded",
+ "bracketSameLine": true
+ }
+ }
}
diff --git a/docker-compose.yml b/docker-compose.yml
index 8d42fdbd1..fc21b8cb0 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -63,14 +63,8 @@ services:
container_name: lavamusic
image: ghcr.io/appujet/lavamusic:main
environment:
- # Your lavalink url
- - LAVALINK_URL=lavalink:2333
- # Your lavalink password
- - LAVALINK_AUTH=youshallnotpass
- # Your lavalink name
- - LAVALINK_NAME=LavaMusic
- # Your lavalink secure (true or false)
- - LAVALINK_SECURE=false
+ # lavalink nodes
+ - NODES=[{"id":"LavaMusic","host":"lavalink","port":2333,"authorization":"youshallnotpass"}]
# database url
# - DATABASE_URL= put your database url here (mongodb or postgres)
# - DATABASE_URL=postgresql://lavamusic:lavamusic@postgres:5432/lavamusic (for postgres)
diff --git a/locales/ChineseCN.json b/locales/ChineseCN.json
index 83ef7e43f..f823bfbc2 100644
--- a/locales/ChineseCN.json
+++ b/locales/ChineseCN.json
@@ -134,6 +134,9 @@
"messages": {
"filter_enabled": "`✅` | 低音增强滤镜已`启用`。\n**请注意,音量过大会损害您的听力!**",
"filter_disabled": "`✅` | 低音增强滤镜已`禁用`。"
+ },
+ "options": {
+ "level": "The bassboost level you want to set"
}
},
"distorsion": {
@@ -494,6 +497,9 @@
"playlist_stolen": "已成功从 {user} 窃取播放列表 `{playlist}`。",
"error_occurred": "窃取播放列表时出错。"
}
+ },
+ "lyrics": {
+ "description": "Get's the lyrics of the currently playing track"
}
},
"buttons": {
@@ -613,7 +619,6 @@
"no_previous_track": "没有上一首曲目。",
"playing_previous": "正在播放上一首曲目。",
"previous_footer": "由 {displayName} 播放上一首曲目",
- "rewind_limit": "您不能将音乐倒回到超过歌曲长度的位置。",
"rewinded": "已倒回音乐。",
"rewind_footer": "由 {displayName} 倒回",
"forward_limit": "您不能将音乐快进到超过歌曲长度的位置。",
@@ -627,4 +632,4 @@
"Leave a guild": "离开服务器",
"List all guilds the bot is in": "列出机器人所在的所有服务器",
"Restart the bot": "重启机器人"
-}
\ No newline at end of file
+}
diff --git a/locales/ChineseTW.json b/locales/ChineseTW.json
index 39e6fb2bb..7b8b9e8d1 100644
--- a/locales/ChineseTW.json
+++ b/locales/ChineseTW.json
@@ -134,6 +134,9 @@
"messages": {
"filter_enabled": "`✅` | 低音增強等化器已`啟用`。\n**請注意,音量過大會損害您的聽力!**",
"filter_disabled": "`✅` | 低音增強等化器已`停用`。"
+ },
+ "options": {
+ "level": "The bassboost level you want to set"
}
},
"distorsion": {
@@ -494,6 +497,9 @@
"playlist_stolen": "已成功從 {user} 竊取播放清單 `{playlist}`。",
"error_occurred": "竊取播放清單時出錯。"
}
+ },
+ "lyrics": {
+ "description": "Get's the lyrics of the currently playing track"
}
},
"buttons": {
@@ -613,7 +619,6 @@
"no_previous_track": "沒有上一首曲目。",
"playing_previous": "正在播放上一首曲目。",
"previous_footer": "由 {displayName} 播放上一首曲目",
- "rewind_limit": "您不能將音樂倒帶到超過歌曲長度的位置。",
"rewinded": "已倒帶音樂。",
"rewind_footer": "由 {displayName} 資訊",
"forward_limit": "您不能將音樂快轉到超過歌曲長度的位置。",
@@ -627,4 +632,4 @@
"Leave a guild": "離開伺服器",
"List all guilds the bot is in": "列出機器人所在的所有伺服器",
"Restart the bot": "重啟機器人"
-}
\ No newline at end of file
+}
diff --git a/locales/EnglishUS.json b/locales/EnglishUS.json
index d671e74eb..d33e950a7 100644
--- a/locales/EnglishUS.json
+++ b/locales/EnglishUS.json
@@ -33,7 +33,7 @@
"options": {
"command": "The command you want to get info on"
},
- "content": "Hey there! I'm {bot}, a music bot made with [Lavamusic](https://github.com/appujet/lavamusic) and Discord. You can use `{prefix}help ` to get more info on a command.",
+ "content": "Hey there! I'm {bot}, a music bot made with [Lavamusic](https://github.com/appujet/lavamusic) and Discord.js. You can use `{prefix}help ` to get more info on a command.",
"title": "Help Menu",
"not_found": "This `{cmdName}` command does not exist.",
"help_cmd": "**Description:** {description}\n**Usage:** {usage}\n**Examples:** {examples}\n**Aliases:** {aliases}\n**Category:** {category}\n**Cooldown:** {cooldown} seconds\n**Permissions:** {premUser}\n**Bot Permissions:** {premBot}\n**Developer Only:** {dev}\n**Slash Command:** {slash}\n**Args:** {args}\n**Player:** {player}\n**DJ:** {dj}\n**DJ Permissions:** {djPerm}\n**Voice:** {voice}",
@@ -41,7 +41,7 @@
},
"botinfo": {
"description": "Information about the bot",
- "content": "Bot Information:\n- **Operating System**: {osInfo}\n- **Uptime**: {osUptime}\n- **Hostname**: {osHostname}\n- **CPU Architecture**: {cpuInfo}\n- **CPU Usage**: {cpuUsed}%\n- **Memory Usage**: {memUsed}MB / {memTotal}GB\n- **Node Version**: {nodeVersion}\n- **Discord Version**: {discordJsVersion}\n- **Connected to** {guilds} guilds, {channels} channels, and {users} users\n- **Total Commands**: {commands}"
+ "content": "Bot Information:\n- **Operating System**: {osInfo}\n- **Uptime**: {osUptime}\n- **Hostname**: {osHostname}\n- **CPU Architecture**: {cpuInfo}\n- **CPU Usage**: {cpuUsed}%\n- **Memory Usage**: {memUsed}MB / {memTotal}GB\n- **Node Version**: {nodeVersion}\n- **Discord.js Version**: {discordJsVersion}\n- **Connected to** {guilds} guilds, {channels} channels, and {users} users\n- **Total Commands**: {commands}"
},
"about": {
"description": "Shows information about the bot",
@@ -110,7 +110,7 @@
"errors": {
"channel_exists": "The song request channel already exists.",
"channel_not_exists": "The song request channel doesn't exist.",
- "channel_delete_fail": "The song request channel has been deleted. If the channel is not deleted normally, please delete it yourself."
+ "channel_delete_fail": "The setup channel has been deleted from the database. Please delete the channel yourself."
},
"messages": {
"channel_created": "The song request channel has been created in <#{channelId}>.",
@@ -132,9 +132,14 @@
},
"bassboost": {
"description": "on/off bassboost filter",
+ "options": {
+ "level": "The bassboost level you want to set"
+ },
"messages": {
- "filter_enabled": "`✅` | Bassboost filter has been `ENABLED`. \n**Be careful, listening too loudly can damage your hearing!**",
- "filter_disabled": "`✅` | Bassboost filter has been `DISABLED`."
+ "high": "`✅` | High bassboost filter has been `ENABLED`.",
+ "low": "`✅` | Low bassboost filter has been `ENABLED`.",
+ "medium": "`✅` | Medium bassboost filter has been `ENABLED`.",
+ "off": "`✅` | Bassboost filter has been `DISABLED`."
}
},
"distorsion": {
@@ -626,7 +631,6 @@
"no_previous_track": "There is no previous track.",
"playing_previous": "Playing the previous track.",
"previous_footer": "Playing the previous track by {displayName}",
- "rewind_limit": "You cannot rewind the music more than the length of the song.",
"rewinded": "Rewinded the music.",
"rewind_footer": "Rewinded by {displayName}",
"forward_limit": "You cannot forward the music more than the length of the song.",
@@ -640,4 +644,4 @@
"Leave a guild": "Leave a guild",
"List all guilds the bot is in": "List all guilds the bot is in",
"Restart the bot": "Restart the bot"
-}
\ No newline at end of file
+}
diff --git a/locales/French.json b/locales/French.json
index cee09e0bc..f07637397 100644
--- a/locales/French.json
+++ b/locales/French.json
@@ -121,6 +121,9 @@
"messages": {
"filter_enabled": "`✅` | Le filtre de basses a été `ACTIVÉ`. \n**Attention, écouter trop fort peut endommager votre audition !**",
"filter_disabled": "`✅` | Le filtre de basses a été `DÉSACTIVÉ`."
+ },
+ "options": {
+ "level": "The bassboost level you want to set"
}
},
"distorsion": {
@@ -494,6 +497,9 @@
"language": "La langue que vous souhaitez définir",
"reset": "Change la langue par défaut"
}
+ },
+ "lyrics": {
+ "description": "Get's the lyrics of the currently playing track"
}
},
"buttons": {
@@ -613,7 +619,6 @@
"no_previous_track": "Il n'y a pas de piste précédente.",
"playing_previous": "Lecture de la piste précédente.",
"previous_footer": "Lecture de la piste précédente par {displayName}",
- "rewind_limit": "Vous ne pouvez pas rembobiner la musique plus que la longueur de la chanson.",
"rewinded": "Rembobinage de la musique.",
"rewind_footer": "Rembobiné par {displayName}",
"forward_limit": "Vous ne pouvez pas avancer la musique plus que la longueur de la chanson.",
@@ -627,4 +632,4 @@
"Leave a guild": "Leave a guild",
"List all guilds the bot is in": "List all guilds the bot is in",
"Restart the bot": "Restart the bot"
-}
\ No newline at end of file
+}
diff --git a/locales/German.json b/locales/German.json
index 9d423d5bb..6fbaba4cf 100644
--- a/locales/German.json
+++ b/locales/German.json
@@ -121,6 +121,9 @@
"messages": {
"filter_enabled": "`✅` | Bassboost-Filter wurde `AKTIVIERT`. \n**Vorsicht, zu lautes Hören kann deine Ohren schädigen!**",
"filter_disabled": "`✅` | Bassboost-Filter wurde `DEAKTIVIERT`."
+ },
+ "options": {
+ "level": "The bassboost level you want to set"
}
},
"distorsion": {
@@ -494,6 +497,9 @@
"language": "Die Sprache, die du einstellen möchtest",
"reset": "Ändere die Sprache zurück zur Standardsprache"
}
+ },
+ "lyrics": {
+ "description": "Get's the lyrics of the currently playing track"
}
},
"buttons": {
@@ -613,7 +619,6 @@
"no_previous_track": "Es gibt keinen vorherigen Track.",
"playing_previous": "Spiele den vorherigen Track ab.",
"previous_footer": "Spiele den vorherigen Track ab von {displayName}",
- "rewind_limit": "Du kannst die Musik nicht mehr als die Länge des Songs zurückspulen.",
"rewinded": "Musik zurückgespult.",
"rewind_footer": "Zurückgespult von {displayName}",
"forward_limit": "Du kannst die Musik nicht mehr als die Länge des Songs vorspulen.",
@@ -627,4 +632,4 @@
"Leave a guild": "Leave a guild",
"List all guilds the bot is in": "List all guilds the bot is in",
"Restart the bot": "Restart the bot"
-}
\ No newline at end of file
+}
diff --git a/locales/Hindi.json b/locales/Hindi.json
index 6585ccb86..0eae2fa7b 100644
--- a/locales/Hindi.json
+++ b/locales/Hindi.json
@@ -134,6 +134,9 @@
"messages": {
"filter_enabled": "`✅` | Bassboost filter `SAKRIYA` kar diya gaya hai. \n**Savdhan rahein, tej awaz mein sunne se aapke kaano ko nuksan pahunch sakta hai!**",
"filter_disabled": "`✅` | Bassboost filter `NIRAKRIYA` kar diya gaya hai."
+ },
+ "options": {
+ "level": "The bassboost level you want to set"
}
},
"distorsion": {
@@ -494,6 +497,9 @@
"playlist_stolen": "{user} se playlist `{playlist}` ko safaltapoorvak chura लिया गया है.",
"error_occurred": "Playlist ko churaate समय एक error aaya."
}
+ },
+ "lyrics": {
+ "description": "Get's the lyrics of the currently playing track"
}
},
"buttons": {
@@ -613,7 +619,6 @@
"no_previous_track": "Koi pichhla track nahin hai.",
"playing_previous": "Pichhla track play कर रहा हूँ.",
"previous_footer": "{displayName} dwara pichhla track play kiya जा रहा है",
- "rewind_limit": "Aap music ko song ki lambai se zyada rewind nahin kar sakte.",
"rewinded": "Music ko rewind कर diya गया है.",
"rewind_footer": "{displayName} dwara rewind kiya गया",
"forward_limit": "Aap music ko song ki lambai se zyada forward nahin kar sakte.",
@@ -627,4 +632,4 @@
"Leave a guild": "Leave a guild",
"List all guilds the bot is in": "List all guilds the bot is in",
"Restart the bot": "Restart the bot"
-}
\ No newline at end of file
+}
diff --git a/locales/Indonesian.json b/locales/Indonesian.json
index 313551799..b741f8492 100644
--- a/locales/Indonesian.json
+++ b/locales/Indonesian.json
@@ -134,6 +134,9 @@
"messages": {
"filter_enabled": "`✅` | Filter bassboost telah `DIAKTIFKAN`. \n**Hati-hati, mendengarkan terlalu keras dapat merusak pendengaran Anda!**",
"filter_disabled": "`✅` | Filter bassboost telah `DINONAKTIFKAN`."
+ },
+ "options": {
+ "level": "The bassboost level you want to set"
}
},
"distorsion": {
@@ -494,6 +497,9 @@
"playlist_stolen": "Berhasil mencuri playlist `{playlist}` dari {user}.",
"error_occurred": "Terjadi kesalahan saat mencuri Playlist."
}
+ },
+ "lyrics": {
+ "description": "Get's the lyrics of the currently playing track"
}
},
"buttons": {
@@ -613,7 +619,6 @@
"no_previous_track": "Tidak ada lagu sebelumnya.",
"playing_previous": "Memutar lagu sebelumnya.",
"previous_footer": "Memutar lagu sebelumnya oleh {displayName}",
- "rewind_limit": "Anda tidak dapat memutar mundur lagu lebih dari panjang lagu.",
"rewinded": "Memutar mundur lagu.",
"rewind_footer": "Diputar mundur oleh {displayName}",
"forward_limit": "Anda tidak dapat memajukan lagu lebih dari panjang lagu.",
@@ -627,4 +632,4 @@
"Leave a guild": "Tinggalkan server",
"List all guilds the bot is in": "Daftar semua server tempat bot berada",
"Restart the bot": "Restart bot"
-}
\ No newline at end of file
+}
diff --git a/locales/Japanese.json b/locales/Japanese.json
index 07de728d6..3c2ef6f15 100644
--- a/locales/Japanese.json
+++ b/locales/Japanese.json
@@ -134,6 +134,9 @@
"messages": {
"filter_enabled": "`✅` | ベースブーストフィルターが`有効`になりました。\n**音量を上げすぎると聴覚に悪影響を与える可能性があるので注意してください!**",
"filter_disabled": "`✅` | ベースブーストフィルターが`無効`になりました。"
+ },
+ "options": {
+ "level": "The bassboost level you want to set"
}
},
"distorsion": {
@@ -494,6 +497,9 @@
"playlist_stolen": "{user} からプレイリスト `{playlist}` を正常に盗みました。",
"error_occurred": "プレイリストの盗難中にエラーが発生しました。"
}
+ },
+ "lyrics": {
+ "description": "Get's the lyrics of the currently playing track"
}
},
"buttons": {
@@ -613,7 +619,6 @@
"no_previous_track": "前のトラックがありません。",
"playing_previous": "前のトラックを再生中です。",
"previous_footer": "{displayName} によって前のトラックを再生中です",
- "rewind_limit": "曲の長さ以上に巻き戻すことはできません。",
"rewinded": "音楽を巻き戻しました。",
"rewind_footer": "{displayName} によって巻き戻されました",
"forward_limit": "曲の長さ以上に早送りすることはできません。",
@@ -627,4 +632,4 @@
"Leave a guild": "ギルドを離れる",
"List all guilds the bot is in": "ボットが所属しているすべてのギルドを一覧表示",
"Restart the bot": "ボットを再起動"
-}
\ No newline at end of file
+}
diff --git a/locales/Korean.json b/locales/Korean.json
index 7f3025359..ca1dd509f 100644
--- a/locales/Korean.json
+++ b/locales/Korean.json
@@ -33,7 +33,7 @@
"options": {
"command": "특정 명령어의 정보를 얻고 싶다면 여기에 입력해주세요"
},
- "content": "안녕하세요! 저는 [Lavamusic](https://github.com/appujet/lavamusic)과 Discord로 만들어진 음악 봇이에요. `{prefix}help <명령어>`를 사용하여 그 명령어의 자세한 정보를 얻을 수 있어요.",
+ "content": "안녕하세요! 저는 [Lavamusic](https://github.com/appujet/lavamusic)와 Discord.js로 만들어진 음악 봇, {bot}이에요. 명령어에 대한 자세한 정보를 얻고 싶다면 `{prefix}help <명령어>`를 사용해보세요.",
"title": "도움말 메뉴",
"not_found": "`{cmdName}` 명령어는 존재하지 않아요.",
"help_cmd": "**설명:** {description}\n**사용 방법:** {usage}\n**예시:** {examples}\n**줄인 명령어:** {aliases}\n**카테고리:** {category}\n**쿨다운:** {cooldown}초\n**필요한 권한:** {premUser}\n**봇에게 필요한 권한:** {premBot}\n**개발자 전용:** {dev}\n**빗금 명령어 사용 가능:** {slash}\n**인수 필요:** {args}\n**노래 재생 중에만 사용 가능:** {player}\n**DJ만 사용 가능:** {dj}\n**DJ에게 필요한 권한:** {djPerm}\n**음성 채널 접속 중에만 사용 가능:** {voice}",
@@ -41,7 +41,7 @@
},
"botinfo": {
"description": "봇에 대한 정보를 표시해요",
- "content": "봇 정보:\n- **운영 체제**: {osInfo}\n- **업타임**: {osUptime}\n- **호스트 이름**: {osHostname}\n- **CPU 아키텍처**: {cpuInfo}\n- **CPU 사용량**: {cpuUsed}%\n- **메모리 사용량**: {memUsed}MB / {memTotal}GB\n- **Node 버전**: {nodeVersion}\n- **Discord 버전**: {discordJsVersion}\n- 서버 {guilds}개, 채널 {channels}개, 유저 {users}명\n- **명령어 수**: {commands}개"
+ "content": "봇 정보:\n- **운영 체제**: {osInfo}\n- **업타임**: {osUptime}\n- **호스트 이름**: {osHostname}\n- **CPU 아키텍처**: {cpuInfo}\n- **CPU 사용량**: {cpuUsed}%\n- **메모리 사용량**: {memUsed}MB / {memTotal}GB\n- **Node 버전**: {nodeVersion}\n- **Discord.js 버전**: {discordJsVersion}\n- 서버 {guilds}개, 채널 {channels}개, 유저 {users}명\n- **명령어 수**: {commands}개"
},
"about": {
"description": "봇에 대한 정보를 확인해요",
@@ -132,9 +132,14 @@
},
"bassboost": {
"description": "베이스부스트 필터를 토글해요",
+ "options": {
+ "level": "설정할 베이스부스트 레벨"
+ },
"messages": {
- "filter_enabled": "`✅` | 베이스부스트 필터가 `활성화되었어요`. \n**조심하세요, 너무 크게 들으면 귀가 나갈 수도 있어요!**",
- "filter_disabled": "`✅` | 베이스부스트 필터가 `비활성화되었어요`."
+ "high": "`✅` | High 베이스부스트 필터가 `활성화되었어요`.",
+ "low": "`✅` | Low 베이스부스트 필터가 `활성화되었어요`.",
+ "medium": "`✅` | Medium 베이스부스트 필터가 `활성화되었어요`.",
+ "off": "`✅` | 베이스부스트 필터가 `비활성화되었어요`."
}
},
"distorsion": {
@@ -264,9 +269,9 @@
"looping_off": "**반복이 꺼졌어요.**"
},
"lyrics": {
- "description": "현재 재생중인 노래의 가사를 가져와요",
- "lyrics_track": "### [{trackTitle}]({trackUrl})의 노래 가사\n**`{lyrics}`**",
- "searching": "`🔍` **{trackTitle}**의 가사 검색 중...",
+ "description": "현재 재생중인 노래의 가사를 확인해요",
+ "lyrics_track": "### [{trackTitle}]({trackUrl}) 노래 가사\n**`{lyrics}`**",
+ "searching": "`🔍` **{trackTitle}** 노래 가사 검색 중...",
"errors": {
"no_results": "가사를 찾지 못했어요.",
"lyrics_error": "가사를 검색하는 도중 오류가 발생했어요."
@@ -551,8 +556,8 @@
"error_searching": "노래를 검색하는 도중 오류가 발생했어요.",
"no_results": "검색결과가 없어요.",
"nothing_playing": "재생 중인 노래 없음",
- "queue_too_long": "대기열에 노래가 너무 많아요. 노래는 최대 {maxQueueSize}개까지만 추가할 수 있어요.",
- "playlist_too_long": "플레이리스트 또는 대기열에 노래가 너무 많아요. 노래는 최대 {maxPlaylistSize}개까지만 추가할 수 있어요.",
+ "queue_too_long": "대기열에 노래가 너무 많아요. 노래는 최대 {maxQueueSize}개까지만 추가할 수 있어요.",
+ "playlist_too_long": "플레이리스트 또는 대기열에 노래가 너무 많아요. 노래는 최대 {maxPlaylistSize}개까지만 추가할 수 있어요.",
"added_to_queue": "대기열에 추가되었어요: [{title}]({uri})",
"added_playlist_to_queue": "[{length}]개의 노래가 추가되었어요."
}
@@ -595,15 +600,15 @@
"cooldown": "`{command}` 명령어를 사용하려면 {time}초동안 기다려야 해요.",
"no_mention_everyone": "이 명령어는 everyone나 here 멘션으로 사용할 수 없어요. 빗금 명령어로 사용해주세요.",
"error": "오류: `{error}`",
- "no_voice_channel_queue": "대기열에 노래를 추가하려면 음성 채널에 접속해주세요.",
+ "no_voice_channel_queue": "대기열에 노래를 추가하려면 음성 채널에 있어야 해요.",
"no_permission_connect_speak": "<#{channel}>에서 연결/말하기 권한이 없어요.",
"different_voice_channel_queue": "노래를 대기열에 추가하려면 <#{channel}> 채널에 있어야 해요.",
"vote_button": "투표하기",
"vote_message": "잠깐! 이 명령어를 사용하려면 top.gg에서 투표해야 해요."
},
"setupButton": {
- "no_voice_channel_button": "이 버튼을 사용하려면 음성 채널에 접속해주세요.",
- "different_voice_channel_button": "이 버튼을 사용하려면 {channel} 채널에 접속해주세요.",
+ "no_voice_channel_button": "이 버튼을 사용하려면 음성 채널에 있어야 해요.",
+ "different_voice_channel_button": "이 버튼을 사용하려면 {channel} 채널에 있어야 해요.",
"now_playing": "재생 중",
"live": "라이브",
"requested_by": "요청자: <@{requester}>",
@@ -620,16 +625,15 @@
"stopped": "노래를 정지했어요.",
"stopped_footer": "{displayName}님에 의해 정지됨",
"nothing_playing": "재생 중인 노래 없음",
- "loop_set": "{loop} 반복으로 설정했어요.",
- "loop_footer": "{displayName}님에 의해 {loop} 반복으로 설정됨",
+ "loop_set": "반복 모드가 {loop}로 변경되었어요.",
+ "loop_footer": "{displayName}님에 의해 반복 모드가 {loop}로 설정됨",
"shuffled": "노래를 섞었어요.",
"no_previous_track": "이전 노래가 없어요.",
"playing_previous": "이전 노래를 재생할게요.",
"previous_footer": "{displayName}님에 의해 이전 노래 재생 중",
- "rewind_limit": "현재 노래 길이보다 더 되감기할 수 없어요.",
"rewinded": "노래를 되감기했어요.",
"rewind_footer": "{displayName}님에 의해 노래 되감기됨",
- "forward_limit": "현재 노래 길이보다 더 빨리감기할 수 없어요.",
+ "forward_limit": "더 이상 빨리감기할 수 없어요.",
"forwarded": "노래를 빨리감기했어요.",
"forward_footer": "{displayName}님에 의해 빨리감기됨",
"button_not_available": "이 버튼은 사용할 수 없어요.",
@@ -640,4 +644,4 @@
"Leave a guild": "서버를 떠나요",
"List all guilds the bot is in": "봇이 들어가 있는 서버를 알려줘요",
"Restart the bot": "봇을 재시작해요"
-}
\ No newline at end of file
+}
diff --git a/locales/Norwegian.json b/locales/Norwegian.json
index dcbf8baf3..d2707dd03 100644
--- a/locales/Norwegian.json
+++ b/locales/Norwegian.json
@@ -134,6 +134,9 @@
"messages": {
"filter_enabled": "`✅` | Bassboost-filteret er `AKTIVERT`. \n**Vær forsiktig, å lytte for høyt kan skade hørselen!**",
"filter_disabled": "`✅` | Bassboost-filteret er `DEAKTIVERT`."
+ },
+ "options": {
+ "level": "The bassboost level you want to set"
}
},
"distorsion": {
@@ -494,6 +497,9 @@
"playlist_stolen": "Stjal spillelisten `{playlist}` fra {user}.",
"error_occurred": "En feil oppstod under stjeling av spillelisten."
}
+ },
+ "lyrics": {
+ "description": "Get's the lyrics of the currently playing track"
}
},
"buttons": {
@@ -613,7 +619,6 @@
"no_previous_track": "Det er ingen forrige spor.",
"playing_previous": "Spiller av forrige spor.",
"previous_footer": "Spiller av forrige spor av {displayName}",
- "rewind_limit": "Du kan ikke spole musikken tilbake mer enn lengden på sangen.",
"rewinded": "Spolet musikken tilbake.",
"rewind_footer": "Spolet tilbake av {displayName}",
"forward_limit": "Du kan ikke spole musikken fremover mer enn lengden på sangen.",
@@ -627,4 +632,4 @@
"Leave a guild": "Forlat en server",
"List all guilds the bot is in": "List opp alle servere boten er på",
"Restart the bot": "Start boten på nytt"
-}
\ No newline at end of file
+}
diff --git a/locales/Polish.json b/locales/Polish.json
index afc79c502..316103047 100644
--- a/locales/Polish.json
+++ b/locales/Polish.json
@@ -134,6 +134,9 @@
"messages": {
"filter_enabled": "`✅` | Filtr wzmocnienia basów został `WŁĄCZONY`. \n**Uwaga, zbyt głośne słuchanie może uszkodzić słuch!**",
"filter_disabled": "`✅` | Filtr wzmocnienia basów został `WYŁĄCZONY`."
+ },
+ "options": {
+ "level": "The bassboost level you want to set"
}
},
"distorsion": {
@@ -494,6 +497,9 @@
"playlist_stolen": "Pomyślnie skradziono playlistę `{playlist}` od {user}.",
"error_occurred": "Wystąpił błąd podczas kradzieży playlisty."
}
+ },
+ "lyrics": {
+ "description": "Get's the lyrics of the currently playing track"
}
},
"buttons": {
@@ -613,7 +619,6 @@
"no_previous_track": "Nie ma żadnego poprzedniego utworu.",
"playing_previous": "Odtwarzanie poprzedniego utworu",
"previous_footer": "Utwór ostatnio odtwarzany przez {displayName}",
- "rewind_limit": "Nie można cofnąć muzyki o więcej niż długość utworu.",
"rewinded": "Cofnięto muzykę.",
"rewind_footer": "Cofnięty przez {displayName}",
"forward_limit": "Nie można przesunąć muzyki do przodu o więcej niż długość utworu.",
@@ -627,4 +632,4 @@
"Leave a guild": "Opusć serwer",
"List all guilds the bot is in": "Lista wszystkich serwerów, w których jest bot",
"Restart the bot": "Uruchom ponownie bota"
-}
\ No newline at end of file
+}
diff --git a/locales/PortuguesePT.json b/locales/PortuguesePT.json
index 55515ed2f..62e0773a4 100644
--- a/locales/PortuguesePT.json
+++ b/locales/PortuguesePT.json
@@ -613,7 +613,6 @@
"no_previous_track": "Não há nenhuma faixa anterior.",
"playing_previous": "A tocar a faixa anterior.",
"previous_footer": "A tocar a faixa anterior por {displayName}",
- "rewind_limit": "Não pode retroceder a música mais do que o comprimento da música.",
"rewinded": "A música foi retrocedida.",
"rewind_footer": "Retrocedido por {displayName}",
"forward_limit": "Não pode avançar a música mais do que o comprimento da música.",
@@ -623,4 +622,4 @@
"no_music_playing": "Nada está a ser reproduzido neste momento."
}
}
-}
\ No newline at end of file
+}
diff --git a/locales/Russian.json b/locales/Russian.json
index 6ed4e962f..2ec622eca 100644
--- a/locales/Russian.json
+++ b/locales/Russian.json
@@ -134,6 +134,9 @@
"messages": {
"filter_enabled": "`✅` | Фильтр усиления басов был `ВКЛЮЧЕН`. \n**Будьте осторожны, слишком громкое прослушивание может повредить слух!**",
"filter_disabled": "`✅` | Фильтр усиления басов был `ОТКЛЮЧЕН`."
+ },
+ "options": {
+ "level": "The bassboost level you want to set"
}
},
"distorsion": {
@@ -494,6 +497,9 @@
"playlist_stolen": "Успешно украден плейлист `{playlist}` у {user}.",
"error_occurred": "Произошла ошибка при краже плейлиста."
}
+ },
+ "lyrics": {
+ "description": "Get's the lyrics of the currently playing track"
}
},
"buttons": {
@@ -613,7 +619,6 @@
"no_previous_track": "Нет предыдущей дорожки.",
"playing_previous": "Проигрывается предыдущая дорожка.",
"previous_footer": "Проигрывается предыдущая дорожка {displayName}",
- "rewind_limit": "Вы не можете перемотать музыку больше, чем длина песни.",
"rewinded": "Музыка перемотана назад.",
"rewind_footer": "Перемотано назад {displayName}",
"forward_limit": "Вы не можете перемотать музыку вперед больше, чем длина песни.",
@@ -627,4 +632,4 @@
"Leave a guild": "Leave a guild",
"List all guilds the bot is in": "List all guilds the bot is in",
"Restart the bot": "Restart the bot"
-}
\ No newline at end of file
+}
diff --git a/locales/SpanishES.json b/locales/SpanishES.json
index c27a668e1..988a1ff5a 100644
--- a/locales/SpanishES.json
+++ b/locales/SpanishES.json
@@ -121,6 +121,9 @@
"messages": {
"filter_enabled": "`✅` | El filtro de refuerzo de graves se ha `ACTIVADO`. \n**¡Ten cuidado, escuchar demasiado alto puede dañar tu oído!**",
"filter_disabled": "`✅` | El filtro de refuerzo de graves se ha `DESACTIVADO`."
+ },
+ "options": {
+ "level": "The bassboost level you want to set"
}
},
"distorsion": {
@@ -494,6 +497,9 @@
"language": "El idioma que quieres establecer",
"reset": "Cambia el idioma de nuevo al idioma predeterminado"
}
+ },
+ "lyrics": {
+ "description": "Get's the lyrics of the currently playing track"
}
},
"buttons": {
@@ -613,7 +619,6 @@
"no_previous_track": "No hay ninguna pista anterior.",
"playing_previous": "Reproduciendo la pista anterior.",
"previous_footer": "Reproduciendo la pista anterior por {displayName}",
- "rewind_limit": "No puedes rebobinar la música más de la duración de la canción.",
"rewinded": "Se ha rebobinado la música.",
"rewind_footer": "Rebobinado por {displayName}",
"forward_limit": "No puedes avanzar la música más de la duración de la canción.",
@@ -627,4 +632,4 @@
"Leave a guild": "Leave a guild",
"List all guilds the bot is in": "List all guilds the bot is in",
"Restart the bot": "Restart the bot"
-}
\ No newline at end of file
+}
diff --git a/locales/Vietnamese.json b/locales/Vietnamese.json
index 92f7d1b08..a1560056b 100644
--- a/locales/Vietnamese.json
+++ b/locales/Vietnamese.json
@@ -134,6 +134,9 @@
"messages": {
"filter_enabled": "`✅` | Bộ lọc Bassboost đã được `BẬT`. \n**Cẩn thận, nghe quá to có thể gây hại cho thính giác của bạn!**",
"filter_disabled": "`✅` | Bộ lọc Bassboost đã được `TẮT`."
+ },
+ "options": {
+ "level": "The bassboost level you want to set"
}
},
"distorsion": {
@@ -494,6 +497,9 @@
"playlist_stolen": "Đã đánh cắp danh sách phát `{playlist}` từ {user} thành công.",
"error_occurred": "Đã xảy ra lỗi khi đánh cắp danh sách phát."
}
+ },
+ "lyrics": {
+ "description": "Get's the lyrics of the currently playing track"
}
},
"buttons": {
@@ -613,7 +619,6 @@
"no_previous_track": "Không có bài hát trước.",
"playing_previous": "Đang phát bài hát trước.",
"previous_footer": "Đang phát bài hát trước bởi {displayName}",
- "rewind_limit": "Bạn không thể quay lại nhạc nhiều hơn độ dài của bài hát.",
"rewinded": "Đã quay lại nhạc.",
"rewind_footer": "Quay lại bởi {displayName}",
"forward_limit": "Bạn không thể tiến tới nhạc nhiều hơn độ dài của bài hát.",
@@ -627,4 +632,4 @@
"Leave a guild": "Rời khỏi một guild",
"List all guilds the bot is in": "Danh sách tất cả guild mà bot đang ở",
"Restart the bot": "Khởi động lại bot"
-}
\ No newline at end of file
+}
diff --git a/package.json b/package.json
index 55f74b00c..7f16de3b0 100644
--- a/package.json
+++ b/package.json
@@ -1,9 +1,8 @@
{
"name": "lavamusic",
- "version": "4.6.7",
- "description": "LavaMusic is a music bot for Discord, written in JavaScript using the Discord.js, Typescript, Shoukaku (Lavalink) library.",
+ "version": "5.0.0-beta",
+ "description": "LavaMusic is a music bot for Discord, written in JavaScript using the Discord.js, Typescript, lavalink-client (Lavalink) library.",
"main": "dist/index.js",
- "type": "module",
"scripts": {
"start": "npm run clean && node .",
"db:push": "npx prisma db push",
@@ -22,7 +21,7 @@
"music",
"bot",
"lavalink",
- "shoukaku",
+ "lavalink-client",
"lavamusic",
"typescript",
"prisma"
@@ -34,11 +33,12 @@
},
"homepage": "https://github.com/appujet/lavamusic#readme",
"devDependencies": {
- "@biomejs/biome": "^1.9.0",
+ "@biomejs/biome": "^1.9.2",
"@types/i18n": "^0.13.12",
- "@types/node": "^22.5.4",
+ "@types/node": "^22.5.5",
"@types/signale": "^1.4.7",
"prisma": "^5.19.1",
+ "tslib": "^2.7.0",
"typescript": "^5.6.2"
},
"dependencies": {
@@ -48,12 +48,12 @@
"dotenv": "^16.4.5",
"genius-lyrics-api": "^3.2.1",
"i18n": "^0.15.1",
+ "lavalink-client": "https://pkg.pr.new/moe-music/lavalink-client@1c1f8f3",
"node-system-stats": "^1.3.0",
- "shoukaku": "^4.1.1",
"signale": "^1.4.0",
"topgg-autoposter": "^2.0.2",
- "tslib": "^2.7.0",
- "undici": "^6.19.8"
+ "undici": "^6.19.8",
+ "zod": "^3.23.8"
},
"signale": {
"displayScope": true,
diff --git a/prisma/example.mongodb.schema.prisma b/prisma/example.mongodb.schema.prisma
index bc9a024ae..f8e3a20dc 100644
--- a/prisma/example.mongodb.schema.prisma
+++ b/prisma/example.mongodb.schema.prisma
@@ -14,96 +14,54 @@ datasource db {
url = env("DATABASE_URL")
}
+model Bot {
+ botId String @unique
+ totalPlaySong Int
+}
+
model Guild {
- guildId String @id @map("_id")
- prefix String
- language String?
- stay Stay?
- dj Dj?
- roles Role[]
- setup Setup?
+ guildId String @id
+ prefix String
+ language String? @default("EnglishUS")
+ stay Stay?
+ dj Dj?
+ roles Role[]
+ setup Setup?
}
model Stay {
- guildId String @id @map("_id")
- textId String
- voiceId String
- Guild Guild @relation(fields: [guildId], references: [guildId])
+ guildId String @id
+ textId String
+ voiceId String
+ Guild Guild @relation(fields: [guildId], references: [guildId])
}
model Dj {
- guildId String @id @map("_id")
- mode Boolean
- Guild Guild @relation(fields: [guildId], references: [guildId])
+ guildId String @id
+ mode Boolean
+ Guild Guild @relation(fields: [guildId], references: [guildId])
}
model Role {
- guildId String @id @map("_id")
- roleId String
- Guild Guild @relation(fields: [guildId], references: [guildId])
+ guildId String
+ roleId String
+ Guild Guild @relation(fields: [guildId], references: [guildId])
- @@unique([guildId, roleId])
+ @@unique([guildId, roleId])
}
model Playlist {
- id String @id @default(cuid()) @map("_id")
- userId String
- name String
- songs Song[]
-
- @@unique([userId, name])
-}
-
-model Song {
- id String @id @map("_id") @default(cuid())
- track String
- playlistId String
- playlist Playlist @relation(fields: [playlistId], references: [id])
+ id String @id @default(uuid())
+ userId String
+ name String
+ tracks String? // Store the array of encoded tracks as a JSON string
- @@unique([track, playlistId])
+ @@unique([userId, name])
}
model Setup {
- guildId String @id @map("_id")
- textId String
- messageId String
- Guild Guild @relation(fields: [guildId], references: [guildId])
-}
-
-model Premium {
- userId String @id @map("_id")
- guildId String
-}
-
-enum Languages {
- EnglishUS
- EnglishGB
- German
- Bulgarian
- ChineseCN
- ChineseTW
- Croatian
- Czech
- Danish
- Dutch
- Finnish
- French
- Greek
- Hindi
- Hungarian
- Italian
- Japanese
- Korean
- Lithuanian
- Norwegian
- Polish
- PortugueseBR
- Romanian
- Russian
- SpanishES
- Swedish
- Thai
- Turkish
- Ukrainian
- Vietnamese
-}
+ guildId String @id
+ textId String
+ messageId String
+ Guild Guild @relation(fields: [guildId], references: [guildId])
+}
\ No newline at end of file
diff --git a/prisma/example.postgresql.schema.prisma b/prisma/example.postgresql.schema.prisma
index 3d131913d..a2f5f8307 100644
--- a/prisma/example.postgresql.schema.prisma
+++ b/prisma/example.postgresql.schema.prisma
@@ -14,14 +14,19 @@ datasource db {
url = env("DATABASE_URL")
}
+model Bot {
+ botId String @unique
+ totalPlaySong Int
+}
+
model Guild {
- guildId String @id
- prefix String
- language String?
- stay Stay?
- dj Dj?
- roles Role[]
- setup Setup?
+ guildId String @id
+ prefix String
+ language String? @default("EnglishUS")
+ stay Stay?
+ dj Dj?
+ roles Role[]
+ setup Setup?
}
model Stay {
@@ -46,64 +51,17 @@ model Role {
}
model Playlist {
- id String @id @default(uuid())
- userId String
- name String
- songs Song[]
+ id String @id @default(uuid())
+ userId String
+ name String
+ tracks String? // Store the array of encoded tracks as a JSON string
@@unique([userId, name])
}
-model Song {
- id String @id @default(uuid())
- track String
- playlistId String
- playlist Playlist @relation(fields: [playlistId], references: [id])
-
- @@unique([track, playlistId])
-}
-
model Setup {
guildId String @id
textId String
messageId String
Guild Guild @relation(fields: [guildId], references: [guildId])
-}
-
-model Premium {
- userId String @id
- guildId String
-}
-
-enum Languages {
- EnglishUS
- EnglishGB
- German
- Bulgarian
- ChineseCN
- ChineseTW
- Croatian
- Czech
- Danish
- Dutch
- Finnish
- French
- Greek
- Hindi
- Hungarian
- Italian
- Japanese
- Korean
- Lithuanian
- Norwegian
- Polish
- PortugueseBR
- Romanian
- Russian
- SpanishES
- Swedish
- Thai
- Turkish
- Ukrainian
- Vietnamese
-}
+}
\ No newline at end of file
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index ad4099269..2187ca2dd 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -51,23 +51,14 @@ model Role {
}
model Playlist {
- id String @id @default(uuid())
- userId String
- name String
- songs Song[]
+ id String @id @default(uuid())
+ userId String
+ name String
+ tracks String? // Store the array of encoded tracks as a JSON string
@@unique([userId, name])
}
-model Song {
- id String @id @default(uuid())
- track String
- playlistId String
- playlist Playlist @relation(fields: [playlistId], references: [id])
-
- @@unique([track, playlistId])
-}
-
model Setup {
guildId String @id
textId String
diff --git a/process.json b/process.json
index bda8eaceb..62bcfb731 100644
--- a/process.json
+++ b/process.json
@@ -1,10 +1,10 @@
{
- "apps": [
- {
- "name": "lavamusic",
- "script": "dist/index.js",
- "node_args": ["--enable-source-maps"],
- "restart_delay": 10000
- }
- ]
+ "apps": [
+ {
+ "name": "lavamusic",
+ "script": "dist/index.js",
+ "node_args": ["--enable-source-maps"],
+ "restart_delay": 10000
+ }
+ ]
}
diff --git a/run.bat b/run.bat
index 5b7f8f7b8..a2fe91338 100644
--- a/run.bat
+++ b/run.bat
@@ -1,19 +1,2 @@
@echo off
-setlocal enabledelayedexpansion
-
-:: Check if pnpm is installed
-
-where pnpm >nul 2>nul
-if %errorlevel% equ 0 (
- set package_manager=pnpm
-) else (
- set package_manager=npm
-)
-
-:: Check if node_modules exists
-if not exist node_modules (
- %package_manager% install
-)
-
-:: start the project
-%package_manager% run start
\ No newline at end of file
+npm run start
diff --git a/scripts/clean.js b/scripts/clean.js
index 4ce4104c4..11693396a 100644
--- a/scripts/clean.js
+++ b/scripts/clean.js
@@ -1,17 +1,28 @@
-import { existsSync } from "node:fs";
-import { rm } from "node:fs/promises";
-import { resolve } from "node:path";
+const fs = require('node:fs');
+const { rm } = require('node:fs').promises;
+const path = require('node:path');
async function clean() {
- try {
- const path = resolve("dist");
- if (existsSync(path)) {
- await rm(path, { recursive: true, force: true });
- }
- } catch (error) {
- console.error("Error while cleaning dist folder:", error);
- process.exit(1);
- }
+ try {
+ const distPath = path.resolve('dist');
+ if (fs.existsSync(distPath)) {
+ await rm(distPath, { recursive: true, force: true });
+ }
+ } catch (error) {
+ console.error('Error while cleaning dist folder:', error);
+ process.exit(1);
+ }
}
clean();
+
+/**
+ * Project: lavamusic
+ * Author: Appu
+ * Main Contributor: LucasB25
+ * Company: Coders
+ * Copyright (c) 2024. All rights reserved.
+ * 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
+ */
diff --git a/scripts/restart.js b/scripts/restart.js
new file mode 100644
index 000000000..9460fcaf3
--- /dev/null
+++ b/scripts/restart.js
@@ -0,0 +1,26 @@
+const { exec } = require('node:child_process');
+
+async function startLavamusic() {
+ exec('npm start', (error, stdout, stderr) => {
+ if (error) {
+ console.error(`Error starting Lavamusic: ${error}`);
+ return;
+ }
+ if (stderr) {
+ console.error(`Error starting Lavamusic: ${stderr}`);
+ }
+ });
+}
+
+setTimeout(startLavamusic, 5000);
+
+/**
+ * Project: lavamusic
+ * Author: Appu
+ * Main Contributor: LucasB25
+ * Company: Coders
+ * Copyright (c) 2024. All rights reserved.
+ * 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
+ */
diff --git a/scripts/restart.ts b/scripts/restart.ts
deleted file mode 100644
index f2ba2a50f..000000000
--- a/scripts/restart.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { exec } from "node:child_process";
-
-async function startLavamusic(): Promise {
- exec("npm start", (error, stderr) => {
- if (error) {
- console.error(`Error starting Lavamusic: ${error.message}`);
- return;
- }
- if (stderr) {
- console.error(`Error output: ${stderr}`);
- }
- });
-}
-
-setTimeout(startLavamusic, 5000);
diff --git a/src/LavaClient.ts b/src/LavaClient.ts
index 2c1663f04..867e73264 100644
--- a/src/LavaClient.ts
+++ b/src/LavaClient.ts
@@ -1,16 +1,16 @@
-import { type ClientOptions, GatewayIntentBits } from "discord.js";
-import config from "./config.js";
-import Lavamusic from "./structures/Lavamusic.js";
+import { type ClientOptions, GatewayIntentBits } from 'discord.js';
+import { env } from './env';
+import Lavamusic from './structures/Lavamusic';
const { GuildMembers, MessageContent, GuildVoiceStates, GuildMessages, Guilds, GuildMessageTyping } = GatewayIntentBits;
const clientOptions: ClientOptions = {
- intents: [Guilds, GuildMessages, MessageContent, GuildVoiceStates, GuildMembers, GuildMessageTyping],
- allowedMentions: { parse: ["users", "roles"], repliedUser: false },
+ intents: [Guilds, GuildMessages, MessageContent, GuildVoiceStates, GuildMembers, GuildMessageTyping],
+ allowedMentions: { parse: ['users', 'roles'], repliedUser: false },
};
const client = new Lavamusic(clientOptions);
-client.start(config.token);
+client.start(env.TOKEN);
/**
* Project: lavamusic
diff --git a/src/commands/config/247.ts b/src/commands/config/247.ts
index 25e8d5f31..1bbe2f759 100644
--- a/src/commands/config/247.ts
+++ b/src/commands/config/247.ts
@@ -1,72 +1,75 @@
-import type { GuildMember } from "discord.js";
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import type { GuildMember } from 'discord.js';
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class _247 extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "247",
- description: {
- content: "cmd.247.description",
- examples: ["247"],
- usage: "247",
- },
- category: "config",
- aliases: ["stay"],
- cooldown: 3,
- args: false,
- vote: true,
- player: {
- voice: true,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: ["ManageGuild"],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: '247',
+ description: {
+ content: 'cmd.247.description',
+ examples: ['247'],
+ usage: '247',
+ },
+ category: 'config',
+ aliases: ['stay'],
+ cooldown: 3,
+ args: false,
+ vote: true,
+ player: {
+ voice: true,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: ['ManageGuild'],
+ },
+ slashCommand: true,
+ options: [],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context): Promise {
- const embed = this.client.embed();
- let player = client.shoukaku.players.get(ctx.guild!.id) as any;
- try {
- const data = await client.db.get_247(ctx.guild!.id);
- const member = ctx.member as GuildMember;
- if (!member.voice.channel) {
- return await ctx.sendMessage({
- embeds: [embed.setDescription(ctx.locale("cmd.247.errors.not_in_voice")).setColor(client.color.red)],
- });
- }
- if (data) {
- await client.db.delete_247(ctx.guild!.id);
- return await ctx.sendMessage({
- embeds: [embed.setDescription(ctx.locale("cmd.247.messages.disabled")).setColor(client.color.red)],
- });
- }
- await client.db.set_247(ctx.guild!.id, ctx.channel.id, member.voice.channel.id);
- if (!player) {
- player = await client.queue.create(
- ctx.guild,
- member.voice.channel,
- ctx.channel,
- client.shoukaku.options.nodeResolver(client.shoukaku.nodes),
- );
- }
- return await ctx.sendMessage({
- embeds: [embed.setDescription(ctx.locale("cmd.247.messages.enabled")).setColor(this.client.color.main)],
- });
- } catch (error) {
- console.error("Error in 247 command:", error);
- return await ctx.sendMessage({
- embeds: [embed.setDescription(ctx.locale("cmd.247.errors.generic")).setColor(client.color.red)],
- });
- }
- }
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const embed = this.client.embed();
+ let player = client.manager.getPlayer(ctx.guild!.id);
+ try {
+ const data = await client.db.get_247(ctx.guild!.id);
+ const member = ctx.member as GuildMember;
+ if (!member.voice.channel) {
+ return await ctx.sendMessage({
+ embeds: [embed.setDescription(ctx.locale('cmd.247.errors.not_in_voice')).setColor(client.color.red)],
+ });
+ }
+ if (data) {
+ await client.db.delete_247(ctx.guild!.id);
+ return await ctx.sendMessage({
+ embeds: [embed.setDescription(ctx.locale('cmd.247.messages.disabled')).setColor(client.color.red)],
+ });
+ }
+ await client.db.set_247(ctx.guild!.id, ctx.channel!.id, member.voice.channel.id);
+ if (!player) {
+ player = client.manager.createPlayer({
+ guildId: ctx.guild!.id,
+ voiceChannelId: member.voice.channel.id,
+ textChannelId: ctx.channel!.id,
+ selfMute: false,
+ selfDeaf: true,
+ vcRegion: member.voice.channel.rtcRegion!,
+ });
+ }
+ if (!player.connected) await player.connect();
+ return await ctx.sendMessage({
+ embeds: [embed.setDescription(ctx.locale('cmd.247.messages.enabled')).setColor(this.client.color.main)],
+ });
+ } catch (error) {
+ console.error('Error in 247 command:', error);
+ return await ctx.sendMessage({
+ embeds: [embed.setDescription(ctx.locale('cmd.247.errors.generic')).setColor(client.color.red)],
+ });
+ }
+ }
}
/**
diff --git a/src/commands/config/Dj.ts b/src/commands/config/Dj.ts
index 2cafdaf6e..afbcbb944 100644
--- a/src/commands/config/Dj.ts
+++ b/src/commands/config/Dj.ts
@@ -1,185 +1,189 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Dj extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "dj",
- description: {
- content: "cmd.dj.description",
- examples: ["dj add @role", "dj remove @role", "dj clear", "dj toggle"],
- usage: "dj",
- },
- category: "general",
- aliases: ["dj"],
- cooldown: 3,
- args: true,
- vote: true,
- player: {
- voice: false,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: ["ManageGuild"],
- },
- slashCommand: true,
- options: [
- {
- name: "add",
- description: "cmd.dj.options.add",
- type: 1,
- options: [
- {
- name: "role",
- description: "cmd.dj.options.role",
- type: 8,
- required: true,
- },
- ],
- },
- {
- name: "remove",
- description: "cmd.dj.options.remove",
- type: 1,
- options: [
- {
- name: "role",
- description: "cmd.dj.options.role",
- type: 8,
- required: true,
- },
- ],
- },
- {
- name: "clear",
- description: "cmd.dj.options.clear",
- type: 1,
- },
- {
- name: "toggle",
- description: "cmd.dj.options.toggle",
- type: 1,
- },
- ],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'dj',
+ description: {
+ content: 'cmd.dj.description',
+ examples: ['dj add @role', 'dj remove @role', 'dj clear', 'dj toggle'],
+ usage: 'dj',
+ },
+ category: 'general',
+ aliases: ['dj'],
+ cooldown: 3,
+ args: true,
+ vote: true,
+ player: {
+ voice: false,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: ['ManageGuild'],
+ },
+ slashCommand: true,
+ options: [
+ {
+ name: 'add',
+ description: 'cmd.dj.options.add',
+ type: 1,
+ options: [
+ {
+ name: 'role',
+ description: 'cmd.dj.options.role',
+ type: 8,
+ required: true,
+ },
+ ],
+ },
+ {
+ name: 'remove',
+ description: 'cmd.dj.options.remove',
+ type: 1,
+ options: [
+ {
+ name: 'role',
+ description: 'cmd.dj.options.role',
+ type: 8,
+ required: true,
+ },
+ ],
+ },
+ {
+ name: 'clear',
+ description: 'cmd.dj.options.clear',
+ type: 1,
+ },
+ {
+ name: 'toggle',
+ description: 'cmd.dj.options.toggle',
+ type: 1,
+ },
+ ],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
- const embed = this.client.embed().setColor(this.client.color.main);
- const dj = await client.db.getDj(ctx.guild!.id);
- let subCommand: string;
- let role: any;
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ const embed = this.client.embed().setColor(this.client.color.main);
+ const dj = await client.db.getDj(ctx.guild!.id);
+ let subCommand: string | undefined;
+ let role: any | undefined;
- 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]);
- }
+ if (ctx.isInteraction) {
+ subCommand = ctx.options.getSubCommand();
+ if (subCommand === 'add' || subCommand === 'remove') {
+ role = ctx.options.getRole('role');
+ }
+ } else {
+ subCommand = args[0];
+ role = ctx.message?.mentions.roles.first() || ctx.guild?.roles.cache.get(args[1]);
+ }
- switch (subCommand) {
- case "add":
- if (!role) {
- return ctx.sendMessage({
- embeds: [embed.setDescription(ctx.locale("cmd.dj.errors.provide_role"))],
- });
- }
- if (await client.db.getRoles(ctx.guild!.id).then((r) => r.some((re) => re.roleId === role.id))) {
- return ctx.sendMessage({
- embeds: [
- embed.setDescription(
- ctx.locale("cmd.dj.messages.role_exists", {
- roleId: role.id,
- }),
- ),
- ],
- });
- }
- await client.db.addRole(ctx.guild!.id, role.id);
- await client.db.setDj(ctx.guild!.id, true);
- return ctx.sendMessage({
- embeds: [
- embed.setDescription(
- ctx.locale("cmd.dj.messages.role_added", {
- roleId: role.id,
- }),
- ),
- ],
- });
+ switch (subCommand) {
+ case 'add': {
+ if (!role) {
+ return ctx.sendMessage({
+ embeds: [embed.setDescription(ctx.locale('cmd.dj.errors.provide_role'))],
+ });
+ }
+ if (await client.db.getRoles(ctx.guild!.id).then(r => r.some(re => re.roleId === role.id))) {
+ return ctx.sendMessage({
+ embeds: [
+ embed.setDescription(
+ ctx.locale('cmd.dj.messages.role_exists', {
+ roleId: role.id,
+ }),
+ ),
+ ],
+ });
+ }
+ await client.db.addRole(ctx.guild!.id, role.id);
+ await client.db.setDj(ctx.guild!.id, true);
+ return ctx.sendMessage({
+ embeds: [
+ embed.setDescription(
+ ctx.locale('cmd.dj.messages.role_added', {
+ roleId: role.id,
+ }),
+ ),
+ ],
+ });
+ }
- case "remove":
- if (!role) {
- return ctx.sendMessage({
- embeds: [embed.setDescription(ctx.locale("cmd.dj.errors.provide_role"))],
- });
- }
- if (!(await client.db.getRoles(ctx.guild!.id).then((r) => r.some((re) => re.roleId === role.id)))) {
- return ctx.sendMessage({
- embeds: [
- embed.setDescription(
- ctx.locale("cmd.dj.messages.role_not_found", {
- roleId: role.id,
- }),
- ),
- ],
- });
- }
- await client.db.removeRole(ctx.guild!.id, role.id);
- return ctx.sendMessage({
- embeds: [
- embed.setDescription(
- ctx.locale("cmd.dj.messages.role_removed", {
- roleId: role.id,
- }),
- ),
- ],
- });
+ case 'remove': {
+ if (!role) {
+ return ctx.sendMessage({
+ embeds: [embed.setDescription(ctx.locale('cmd.dj.errors.provide_role'))],
+ });
+ }
+ if (!(await client.db.getRoles(ctx.guild!.id).then(r => r.some(re => re.roleId === role.id)))) {
+ return ctx.sendMessage({
+ embeds: [
+ embed.setDescription(
+ ctx.locale('cmd.dj.messages.role_not_found', {
+ roleId: role.id,
+ }),
+ ),
+ ],
+ });
+ }
+ await client.db.removeRole(ctx.guild!.id, role.id);
+ return ctx.sendMessage({
+ embeds: [
+ embed.setDescription(
+ ctx.locale('cmd.dj.messages.role_removed', {
+ roleId: role.id,
+ }),
+ ),
+ ],
+ });
+ }
- case "clear":
- if (!dj) {
- return ctx.sendMessage({
- embeds: [embed.setDescription(ctx.locale("cmd.dj.errors.no_roles"))],
- });
- }
- await client.db.clearRoles(ctx.guild!.id);
- return ctx.sendMessage({
- embeds: [embed.setDescription(ctx.locale("cmd.dj.messages.all_roles_cleared"))],
- });
+ case 'clear': {
+ if (!dj) {
+ return ctx.sendMessage({
+ embeds: [embed.setDescription(ctx.locale('cmd.dj.errors.no_roles'))],
+ });
+ }
+ await client.db.clearRoles(ctx.guild!.id);
+ return ctx.sendMessage({
+ embeds: [embed.setDescription(ctx.locale('cmd.dj.messages.all_roles_cleared'))],
+ });
+ }
- case "toggle":
- if (!dj) {
- return ctx.sendMessage({
- embeds: [embed.setDescription(ctx.locale("cmd.dj.errors.no_roles"))],
- });
- }
- await client.db.setDj(ctx.guild!.id, !dj.mode);
- return ctx.sendMessage({
- embeds: [
- embed.setDescription(
- ctx.locale("cmd.dj.messages.toggle", {
- status: dj.mode ? "disabled" : "enabled",
- }),
- ),
- ],
- });
+ case 'toggle': {
+ if (!dj) {
+ return ctx.sendMessage({
+ embeds: [embed.setDescription(ctx.locale('cmd.dj.errors.no_roles'))],
+ });
+ }
+ await client.db.setDj(ctx.guild!.id, !dj.mode);
+ return ctx.sendMessage({
+ embeds: [
+ embed.setDescription(
+ ctx.locale('cmd.dj.messages.toggle', {
+ status: dj.mode ? 'disabled' : 'enabled',
+ }),
+ ),
+ ],
+ });
+ }
- default:
- return ctx.sendMessage({
- embeds: [
- embed.setDescription(ctx.locale("cmd.dj.errors.invalid_subcommand")).addFields({
- name: ctx.locale("cmd.dj.subcommands"),
- value: "`add`, `remove`, `clear`, `toggle`",
- }),
- ],
- });
- }
- }
+ default:
+ return ctx.sendMessage({
+ embeds: [
+ embed.setDescription(ctx.locale('cmd.dj.errors.invalid_subcommand')).addFields({
+ name: ctx.locale('cmd.dj.subcommands'),
+ value: '`add`, `remove`, `clear`, `toggle`',
+ }),
+ ],
+ });
+ }
+ }
}
/**
diff --git a/src/commands/config/Language.ts b/src/commands/config/Language.ts
index 050160751..f19f553bd 100644
--- a/src/commands/config/Language.ts
+++ b/src/commands/config/Language.ts
@@ -1,147 +1,158 @@
-import type { AutocompleteInteraction } from "discord.js";
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
-import { Language, LocaleFlags } from "../../types.js";
+import type { AutocompleteInteraction } from 'discord.js';
+import { Command, type Context, type Lavamusic } from '../../structures/index';
+import { Language, LocaleFlags } from '../../types';
export default class LanguageCommand extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "language",
- description: {
- content: "cmd.language.description",
- examples: ["language set `EnglishUS`", "language reset"],
- usage: "language",
- },
- category: "config",
- aliases: ["lang"],
- cooldown: 3,
- args: true,
- vote: false,
- player: {
- voice: false,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: ["ManageGuild"],
- },
- slashCommand: true,
- options: [
- {
- name: "set",
- description: "cmd.language.options.set",
- type: 1,
- options: [
- {
- name: "language",
- description: "cmd.language.options.language",
- type: 3,
- required: true,
- autocomplete: true,
- },
- ],
- },
- {
- name: "reset",
- description: "cmd.language.options.reset",
- type: 1,
- },
- ],
- });
- }
-
- 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.shift();
- }
- if (subCommand === "set") {
- const embed = client.embed().setColor(this.client.color.main);
-
- const locale = await client.db.getLanguage(ctx.guild!.id);
-
- let lang: string;
-
- if (ctx.isInteraction) {
- lang = ctx.interaction.options.data[0].options[0].value as string;
- } else {
- lang = args[0];
- }
-
- if (!Object.values(Language).includes(lang as Language)) {
- const availableLanguages = Object.entries(LocaleFlags)
- .map(([key, value]) => `${value}:\`${key}\``)
- .reduce((acc, curr, index) => {
- if (index % 2 === 0) {
- return acc + curr + (index === Object.entries(LocaleFlags).length - 1 ? "" : " ");
- }
- return `${acc + curr}\n`;
- }, "");
- return ctx.sendMessage({
- embeds: [
- embed.setDescription(
- ctx.locale("cmd.language.invalid_language", {
- languages: availableLanguages,
- }),
- ),
- ],
- });
- }
-
- if (locale && locale === lang) {
- return ctx.sendMessage({
- embeds: [
- embed.setDescription(
- ctx.locale("cmd.language.already_set", {
- language: lang,
- }),
- ),
- ],
- });
- }
-
- await client.db.updateLanguage(ctx.guild!.id, lang);
- ctx.guildLocale = lang;
-
- return ctx.sendMessage({
- embeds: [embed.setDescription(ctx.locale("cmd.language.set", { language: lang }))],
- });
- }
- if (subCommand === "reset") {
- const embed = client.embed().setColor(this.client.color.main);
-
- const locale = await client.db.getLanguage(ctx.guild!.id);
-
- if (!locale) {
- return ctx.sendMessage({
- embeds: [embed.setDescription(ctx.locale("cmd.language.not_set"))],
- });
- }
-
- await client.db.updateLanguage(ctx.guild!.id, Language.EnglishUS);
- ctx.guildLocale = Language.EnglishUS;
-
- return ctx.sendMessage({
- embeds: [embed.setDescription(ctx.locale("cmd.language.reset"))],
- });
- }
- }
-
- public async autocomplete(interaction: AutocompleteInteraction): Promise {
- const focusedValue = interaction.options.getFocused();
-
- const languages = Object.values(Language).map((language) => ({
- name: language,
- value: language,
- }));
-
- const filtered = languages.filter((language) => language.name.toLowerCase().includes(focusedValue.toLowerCase()));
-
- await interaction.respond(filtered.slice(0, 25)).catch(console.error);
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'language',
+ description: {
+ content: 'cmd.language.description',
+ examples: ['language set `EnglishUS`', 'language reset'],
+ usage: 'language',
+ },
+ category: 'config',
+ aliases: ['lang'],
+ cooldown: 3,
+ args: true,
+ vote: false,
+ player: {
+ voice: false,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: ['ManageGuild'],
+ },
+ slashCommand: true,
+ options: [
+ {
+ name: 'set',
+ description: 'cmd.language.options.set',
+ type: 1,
+ options: [
+ {
+ name: 'language',
+ description: 'cmd.language.options.language',
+ type: 3,
+ required: true,
+ autocomplete: true,
+ },
+ ],
+ },
+ {
+ name: 'reset',
+ description: 'cmd.language.options.reset',
+ type: 1,
+ },
+ ],
+ });
+ }
+
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ let subCommand: string | undefined;
+
+ if (ctx.isInteraction) {
+ subCommand = ctx.options.getSubCommand();
+ } else {
+ subCommand = args.shift();
+ }
+ if (subCommand === 'set') {
+ const embed = client.embed().setColor(this.client.color.main);
+
+ const locale = await client.db.getLanguage(ctx.guild!.id);
+
+ let lang: string;
+
+ if (ctx.isInteraction) {
+ lang = ctx.options.get('language')?.value as string;
+ } else {
+ lang = args[0];
+ }
+
+ if (!Object.values(Language).includes(lang as Language)) {
+ const availableLanguages = Object.entries(LocaleFlags)
+ .map(([key, value]) => `${value}:\`${key}\``)
+ .reduce((acc, curr, index) => {
+ if (index % 2 === 0) {
+ return acc + curr + (index === Object.entries(LocaleFlags).length - 1 ? '' : ' ');
+ }
+ return `${acc + curr}\n`;
+ }, '');
+ return ctx.sendMessage({
+ embeds: [
+ embed.setDescription(
+ ctx.locale('cmd.language.invalid_language', {
+ languages: availableLanguages,
+ }),
+ ),
+ ],
+ });
+ }
+
+ if (locale && locale === lang) {
+ return ctx.sendMessage({
+ embeds: [
+ embed.setDescription(
+ ctx.locale('cmd.language.already_set', {
+ language: lang,
+ }),
+ ),
+ ],
+ });
+ }
+
+ await client.db.updateLanguage(ctx.guild!.id, lang);
+ ctx.guildLocale = lang;
+
+ return ctx.sendMessage({
+ embeds: [embed.setDescription(ctx.locale('cmd.language.set', { language: lang }))],
+ });
+ }
+ if (subCommand === 'reset') {
+ const embed = client.embed().setColor(this.client.color.main);
+
+ const locale = await client.db.getLanguage(ctx.guild!.id);
+
+ if (!locale) {
+ return ctx.sendMessage({
+ embeds: [embed.setDescription(ctx.locale('cmd.language.not_set'))],
+ });
+ }
+
+ await client.db.updateLanguage(ctx.guild!.id, Language.EnglishUS);
+ ctx.guildLocale = Language.EnglishUS;
+
+ return ctx.sendMessage({
+ embeds: [embed.setDescription(ctx.locale('cmd.language.reset'))],
+ });
+ }
+ }
+
+ public async autocomplete(interaction: AutocompleteInteraction): Promise {
+ const focusedValue = interaction.options.getFocused();
+
+ const languages = Object.values(Language).map(language => ({
+ name: language,
+ value: language,
+ }));
+
+ const filtered = languages.filter(language => language.name.toLowerCase().includes(focusedValue.toLowerCase()));
+
+ await interaction.respond(filtered.slice(0, 25)).catch(console.error);
+ }
}
+
+/**
+ * Project: lavamusic
+ * Author: Appu
+ * Main Contributor: LucasB25
+ * Company: Coders
+ * Copyright (c) 2024. All rights reserved.
+ * 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
+ */
diff --git a/src/commands/config/Prefix.ts b/src/commands/config/Prefix.ts
index b745b03bd..9970846b6 100644
--- a/src/commands/config/Prefix.ts
+++ b/src/commands/config/Prefix.ts
@@ -1,110 +1,110 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Prefix extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "prefix",
- description: {
- content: "cmd.prefix.description",
- examples: ["prefix set !", "prefix reset"],
- usage: "prefix",
- },
- category: "general",
- aliases: ["pf"],
- cooldown: 3,
- args: true,
- vote: false,
- player: {
- voice: false,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: ["ManageGuild"],
- },
- slashCommand: true,
- options: [
- {
- name: "set",
- description: "cmd.prefix.options.set",
- type: 1,
- options: [
- {
- name: "prefix",
- description: "cmd.prefix.options.prefix",
- type: 3,
- required: true,
- },
- ],
- },
- {
- name: "reset",
- description: "cmd.prefix.options.reset",
- type: 1,
- },
- ],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'prefix',
+ description: {
+ content: 'cmd.prefix.description',
+ examples: ['prefix set !', 'prefix reset'],
+ usage: 'prefix',
+ },
+ category: 'general',
+ aliases: ['pf'],
+ cooldown: 3,
+ args: true,
+ vote: false,
+ player: {
+ voice: false,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: ['ManageGuild'],
+ },
+ slashCommand: true,
+ options: [
+ {
+ name: 'set',
+ description: 'cmd.prefix.options.set',
+ type: 1,
+ options: [
+ {
+ name: 'prefix',
+ description: 'cmd.prefix.options.prefix',
+ type: 3,
+ required: true,
+ },
+ ],
+ },
+ {
+ name: 'reset',
+ description: 'cmd.prefix.options.reset',
+ type: 1,
+ },
+ ],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
- const embed = client.embed().setColor(this.client.color.main);
- const guildId = ctx.guild!.id;
- const guildData = await client.db.get(guildId);
- const isInteraction = ctx.isInteraction;
- let subCommand: string;
- let prefix: string;
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ const embed = client.embed().setColor(this.client.color.main);
+ const guildId = ctx.guild!.id;
+ const guildData = await client.db.get(guildId);
+ const isInteraction = ctx.isInteraction;
+ let subCommand: string | undefined;
+ let prefix: string | undefined;
- if (isInteraction) {
- subCommand = ctx.interaction.options.data[0].name;
- prefix = ctx.interaction.options.data[0].options[0]?.value.toString();
- } else {
- subCommand = args[0] || "";
- prefix = args[1] || "";
- }
+ if (isInteraction) {
+ subCommand = ctx.options.getSubCommand();
+ prefix = ctx.options.get('prefix')?.value?.toString();
+ } else {
+ subCommand = args[0] || '';
+ prefix = args[1] || '';
+ }
- switch (subCommand) {
- case "set": {
- if (!prefix) {
- const currentPrefix = guildData ? guildData.prefix : client.config.prefix;
- embed.setDescription(
- ctx.locale("cmd.prefix.messages.current_prefix", {
- prefix: currentPrefix,
- }),
- );
- return await ctx.sendMessage({ embeds: [embed] });
- }
- if (prefix.length > 3) {
- embed.setDescription(ctx.locale("cmd.prefix.errors.prefix_too_long"));
- return await ctx.sendMessage({ embeds: [embed] });
- }
- await client.db.setPrefix(guildId, prefix);
- embed.setDescription(ctx.locale("cmd.prefix.messages.prefix_set", { prefix }));
- return await ctx.sendMessage({ embeds: [embed] });
- }
- case "reset": {
- const defaultPrefix = client.config.prefix;
- await client.db.setPrefix(guildId, defaultPrefix);
- embed.setDescription(
- ctx.locale("cmd.prefix.messages.prefix_reset", {
- prefix: defaultPrefix,
- }),
- );
- return await ctx.sendMessage({ embeds: [embed] });
- }
- default: {
- const currentPrefix = guildData ? guildData.prefix : client.config.prefix;
- embed.setDescription(
- ctx.locale("cmd.prefix.messages.current_prefix", {
- prefix: currentPrefix,
- }),
- );
- return await ctx.sendMessage({ embeds: [embed] });
- }
- }
- }
+ switch (subCommand) {
+ case 'set': {
+ if (!prefix) {
+ const currentPrefix = guildData ? guildData.prefix : client.env.PREFIX;
+ embed.setDescription(
+ ctx.locale('cmd.prefix.messages.current_prefix', {
+ prefix: currentPrefix,
+ }),
+ );
+ return await ctx.sendMessage({ embeds: [embed] });
+ }
+ if (prefix.length > 3) {
+ embed.setDescription(ctx.locale('cmd.prefix.errors.prefix_too_long'));
+ return await ctx.sendMessage({ embeds: [embed] });
+ }
+ await client.db.setPrefix(guildId, prefix);
+ embed.setDescription(ctx.locale('cmd.prefix.messages.prefix_set', { prefix }));
+ return await ctx.sendMessage({ embeds: [embed] });
+ }
+ case 'reset': {
+ const defaultPrefix = client.env.PREFIX;
+ await client.db.setPrefix(guildId, defaultPrefix);
+ embed.setDescription(
+ ctx.locale('cmd.prefix.messages.prefix_reset', {
+ prefix: defaultPrefix,
+ }),
+ );
+ return await ctx.sendMessage({ embeds: [embed] });
+ }
+ default: {
+ const currentPrefix = guildData ? guildData.prefix : client.env.PREFIX;
+ embed.setDescription(
+ ctx.locale('cmd.prefix.messages.current_prefix', {
+ prefix: currentPrefix,
+ }),
+ );
+ return await ctx.sendMessage({ embeds: [embed] });
+ }
+ }
+ }
}
/**
diff --git a/src/commands/config/Setup.ts b/src/commands/config/Setup.ts
index f261efd97..c381a3c61 100644
--- a/src/commands/config/Setup.ts
+++ b/src/commands/config/Setup.ts
@@ -1,181 +1,183 @@
-import { ChannelType, OverwriteType, PermissionFlagsBits } from "discord.js";
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
-import { getButtons } from "../../utils/Buttons.js";
+import { ChannelType, OverwriteType, PermissionFlagsBits } from 'discord.js';
+import { Command, type Context, type Lavamusic } from '../../structures/index';
+import { getButtons } from '../../utils/Buttons';
export default class Setup extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "setup",
- description: {
- content: "cmd.setup.description",
- examples: ["setup create", "setup delete", "setup info"],
- usage: "setup",
- },
- category: "config",
- aliases: ["set"],
- cooldown: 3,
- args: true,
- vote: true,
- player: {
- voice: false,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks", "ManageChannels"],
- user: ["ManageGuild"],
- },
- slashCommand: true,
- options: [
- {
- name: "create",
- description: "cmd.setup.options.create",
- type: 1,
- },
- {
- name: "delete",
- description: "cmd.setup.options.delete",
- type: 1,
- },
- {
- name: "info",
- description: "cmd.setup.options.info",
- type: 1,
- },
- ],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'setup',
+ description: {
+ content: 'cmd.setup.description',
+ examples: ['setup create', 'setup delete', 'setup info'],
+ usage: 'setup',
+ },
+ category: 'config',
+ aliases: ['set'],
+ cooldown: 3,
+ args: true,
+ vote: true,
+ player: {
+ voice: false,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks', 'ManageChannels'],
+ user: ['ManageGuild'],
+ },
+ slashCommand: true,
+ options: [
+ {
+ name: 'create',
+ description: 'cmd.setup.options.create',
+ type: 1,
+ },
+ {
+ name: 'delete',
+ description: 'cmd.setup.options.delete',
+ type: 1,
+ },
+ {
+ name: 'info',
+ description: 'cmd.setup.options.info',
+ type: 1,
+ },
+ ],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
- const subCommand = ctx.isInteraction ? ctx.interaction.options.data[0].name : args[0];
- const embed = client.embed().setColor(this.client.color.main);
- switch (subCommand) {
- case "create": {
- const data = await client.db.getSetup(ctx.guild!.id);
- if (data?.textId && data.messageId) {
- return await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.setup.errors.channel_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.",
- permissionOverwrites: [
- {
- type: OverwriteType.Member,
- id: this.client.user.id,
- 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,
- ],
- },
- ],
- });
- const player = this.client.queue.get(ctx.guild!.id);
- const image = this.client.config.links.img;
- const desc =
- player?.queue && player.current
- ? `[${player.current.info.title}](${player.current.info.uri})`
- : ctx.locale("player.setupStart.nothing_playing");
- embed.setDescription(desc).setImage(image);
- await textChannel
- .send({
- embeds: [embed],
- components: getButtons(player, client),
- })
- .then((msg) => {
- client.db.setSetup(ctx.guild!.id, textChannel.id, msg.id);
- });
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.setup.messages.channel_created", { channelId: textChannel.id }),
- color: this.client.color.main,
- },
- ],
- });
- break;
- }
- case "delete": {
- const data2 = await client.db.getSetup(ctx.guild!.id);
- if (!data2) {
- return await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.setup.errors.channel_not_exists"),
- color: client.color.red,
- },
- ],
- });
- }
- client.db.deleteSetup(ctx.guild!.id);
- const textChannel = ctx.guild.channels.cache.get(data2.textId);
- if (textChannel) await textChannel.delete().catch(() => {});
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.setup.messages.channel_deleted"),
- color: this.client.color.main,
- },
- ],
- });
- break;
- }
- case "info": {
- const data3 = await client.db.getSetup(ctx.guild!.id);
- if (!data3) {
- return await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.setup.errors.channel_not_exists"),
- color: client.color.red,
- },
- ],
- });
- }
- const channel = ctx.guild.channels.cache.get(data3.textId);
- if (channel) {
- embed.setDescription(
- ctx.locale("cmd.setup.messages.channel_info", {
- channelId: channel.id,
- }),
- );
- await ctx.sendMessage({ embeds: [embed] });
- } else {
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.setup.errors.channel_not_exists"),
- color: client.color.red,
- },
- ],
- });
- }
- break;
- }
- default:
- break;
- }
- }
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ const subCommand = ctx.isInteraction ? ctx.options.getSubCommand() : args[0];
+ const embed = client.embed().setColor(this.client.color.main);
+ switch (subCommand) {
+ case 'create': {
+ const data = await client.db.getSetup(ctx.guild!.id);
+ if (data?.textId && data.messageId) {
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.setup.errors.channel_exists'),
+ color: client.color.red,
+ },
+ ],
+ });
+ }
+ const textChannel = await ctx.guild.channels.create({
+ name: `${client.user?.username}-song-requests`,
+ type: ChannelType.GuildText,
+ topic: 'Song requests for the music bot.',
+ permissionOverwrites: [
+ {
+ type: OverwriteType.Member,
+ id: client.user?.id!,
+ 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,
+ ],
+ },
+ ],
+ });
+ const player = this.client.manager.getPlayer(ctx.guild!.id);
+ const image = this.client.config.links.img;
+ const desc = player?.queue.current
+ ? `[${player.queue.current.info.title}](${player.queue.current.info.uri})`
+ : ctx.locale('player.setupStart.nothing_playing');
+ embed.setDescription(desc).setImage(image);
+ await textChannel
+ .send({
+ embeds: [embed],
+ components: getButtons(player, client),
+ })
+ .then(msg => {
+ client.db.setSetup(ctx.guild!.id, textChannel.id, msg.id);
+ });
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.setup.messages.channel_created', { channelId: textChannel.id }),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ break;
+ }
+ case 'delete': {
+ const data2 = await client.db.getSetup(ctx.guild!.id);
+ if (!data2) {
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.setup.errors.channel_not_exists'),
+ color: client.color.red,
+ },
+ ],
+ });
+ }
+ client.db.deleteSetup(ctx.guild!.id);
+ const textChannel = ctx.guild.channels.cache.get(data2.textId);
+ if (textChannel)
+ await textChannel.delete().catch(() => {
+ null;
+ });
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.setup.messages.channel_deleted'),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ break;
+ }
+ case 'info': {
+ const data3 = await client.db.getSetup(ctx.guild!.id);
+ if (!data3) {
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.setup.errors.channel_not_exists'),
+ color: client.color.red,
+ },
+ ],
+ });
+ }
+ const channel = ctx.guild.channels.cache.get(data3.textId);
+ if (channel) {
+ embed.setDescription(
+ ctx.locale('cmd.setup.messages.channel_info', {
+ channelId: channel.id,
+ }),
+ );
+ await ctx.sendMessage({ embeds: [embed] });
+ } else {
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.setup.errors.channel_not_exists'),
+ color: client.color.red,
+ },
+ ],
+ });
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
}
/**
diff --git a/src/commands/dev/CreateInvite.ts b/src/commands/dev/CreateInvite.ts
index fc0bcdfd1..47b51c2dd 100644
--- a/src/commands/dev/CreateInvite.ts
+++ b/src/commands/dev/CreateInvite.ts
@@ -1,70 +1,77 @@
-import { ChannelType, PermissionFlagsBits, type TextChannel } from "discord.js";
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { ChannelType, PermissionFlagsBits, type TextChannel } from 'discord.js';
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class CreateInvite extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "createinvite",
- description: {
- content: "Create an invite link for a guild",
- examples: ["createinvite 0000000000000000000"],
- usage: "createinvite ",
- },
- category: "dev",
- aliases: ["ci", "gi", "ginvite", "guildinvite"],
- cooldown: 3,
- args: true,
- player: {
- voice: false,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: true,
- client: ["SendMessages", "CreateInstantInvite", "ReadMessageHistory", "EmbedLinks", "ViewChannel"],
- user: [],
- },
- slashCommand: false,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'createinvite',
+ description: {
+ content: 'Create an invite link for a guild',
+ examples: ['createinvite 0000000000000000000'],
+ usage: 'createinvite ',
+ },
+ category: 'dev',
+ aliases: ['ci', 'gi', 'ginvite', 'guildinvite'],
+ cooldown: 3,
+ args: true,
+ player: {
+ voice: false,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: true,
+ client: ['SendMessages', 'CreateInstantInvite', 'ReadMessageHistory', 'EmbedLinks', 'ViewChannel'],
+ user: [],
+ },
+ slashCommand: false,
+ options: [],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
- const guild = client.guilds.cache.get(args[0]);
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ const guild = client.guilds.cache.get(args[0]);
- if (!guild) {
- return await ctx.sendMessage({
- embeds: [this.client.embed().setColor(this.client.color.red).setDescription("Guild not found")],
- });
- }
+ if (!guild) {
+ return await ctx.sendMessage({
+ embeds: [this.client.embed().setColor(this.client.color.red).setDescription('Guild not found')],
+ });
+ }
- const textChannel = guild.channels.cache.find(
- (c) =>
- c.type === ChannelType.GuildText &&
- c
- .permissionsFor(guild.members.me!)
- ?.has(PermissionFlagsBits.CreateInstantInvite | PermissionFlagsBits.SendMessages | PermissionFlagsBits.ViewChannel),
- ) as TextChannel | undefined;
+ const textChannel = guild.channels.cache.find(
+ c =>
+ c.type === ChannelType.GuildText &&
+ c
+ .permissionsFor(guild.members.me!)
+ ?.has(
+ PermissionFlagsBits.CreateInstantInvite |
+ PermissionFlagsBits.SendMessages |
+ PermissionFlagsBits.ViewChannel,
+ ),
+ ) as TextChannel | undefined;
- if (!textChannel) {
- return await ctx.sendMessage({
- embeds: [this.client.embed().setColor(this.client.color.red).setDescription("No suitable channel found")],
- });
- }
+ if (!textChannel) {
+ return await ctx.sendMessage({
+ embeds: [this.client.embed().setColor(this.client.color.red).setDescription('No suitable channel found')],
+ });
+ }
- const invite = await textChannel.createInvite({
- maxAge: 3600,
- maxUses: 0,
- reason: `Requested by developer: ${ctx.author.username}`,
- });
+ const invite = await textChannel.createInvite({
+ maxAge: 3600,
+ maxUses: 0,
+ reason: `Requested by developer: ${ctx.author?.username}`,
+ });
- return await ctx.sendMessage({
- embeds: [
- this.client.embed().setColor(this.client.color.main).setDescription(`Invite link for ${guild.name}: [Link](${invite.url})`),
- ],
- });
- }
+ return await ctx.sendMessage({
+ embeds: [
+ this.client
+ .embed()
+ .setColor(this.client.color.main)
+ .setDescription(`Invite link for ${guild.name}: [Link](${invite.url})`),
+ ],
+ });
+ }
}
/**
diff --git a/src/commands/dev/DeleteInvites.ts b/src/commands/dev/DeleteInvites.ts
index c63e6f72d..1d03df006 100644
--- a/src/commands/dev/DeleteInvites.ts
+++ b/src/commands/dev/DeleteInvites.ts
@@ -1,51 +1,51 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class DestroyInvites extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "destroyinvites",
- description: {
- content: "Destroy all invite links created by the bot in a guild",
- examples: ["destroyinvites 0000000000000000000"],
- usage: "destroyinvites ",
- },
- category: "dev",
- aliases: ["di"],
- cooldown: 3,
- args: true,
- player: {
- voice: false,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: true,
- client: ["SendMessages", "ManageGuild", "ReadMessageHistory", "ViewChannel"],
- user: [],
- },
- slashCommand: false,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'destroyinvites',
+ description: {
+ content: 'Destroy all invite links created by the bot in a guild',
+ examples: ['destroyinvites 0000000000000000000'],
+ usage: 'destroyinvites ',
+ },
+ category: 'dev',
+ aliases: ['di'],
+ cooldown: 3,
+ args: true,
+ player: {
+ voice: false,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: true,
+ client: ['SendMessages', 'ManageGuild', 'ReadMessageHistory', 'ViewChannel'],
+ user: [],
+ },
+ slashCommand: false,
+ options: [],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
- const guild = client.guilds.cache.get(args[0]);
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ const guild = client.guilds.cache.get(args[0]);
- if (!guild) {
- return await ctx.sendMessage("Guild not found.");
- }
+ if (!guild) {
+ return await ctx.sendMessage('Guild not found.');
+ }
- try {
- const botInvites = (await guild.invites.fetch()).filter((invite) => invite.inviter?.id === client.user?.id);
+ try {
+ const botInvites = (await guild.invites.fetch()).filter(invite => invite.inviter?.id === client.user?.id);
- await Promise.all(botInvites.map((invite) => invite.delete()));
+ await Promise.all(botInvites.map(invite => invite.delete()));
- return await ctx.sendMessage(`Destroyed ${botInvites.size} invite(s) created by the bot.`);
- } catch {
- return await ctx.sendMessage("Failed to destroy invites.");
- }
- }
+ return await ctx.sendMessage(`Destroyed ${botInvites.size} invite(s) created by the bot.`);
+ } catch {
+ return await ctx.sendMessage('Failed to destroy invites.');
+ }
+ }
}
/**
diff --git a/src/commands/dev/Deploy.ts b/src/commands/dev/Deploy.ts
index 9203a3397..b8da8c881 100644
--- a/src/commands/dev/Deploy.ts
+++ b/src/commands/dev/Deploy.ts
@@ -1,101 +1,109 @@
-import { ActionRowBuilder, ButtonBuilder, type ButtonInteraction, ButtonStyle, ComponentType, type Message } from "discord.js";
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import {
+ ActionRowBuilder,
+ ButtonBuilder,
+ type ButtonInteraction,
+ ButtonStyle,
+ ComponentType,
+ type Message,
+ type TextChannel,
+} from 'discord.js';
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Deploy extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "deploy",
- description: {
- content: "Deploy commands",
- examples: ["deploy"],
- usage: "deploy",
- },
- category: "dev",
- aliases: ["deploy-commands"],
- cooldown: 3,
- args: false,
- player: {
- voice: false,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: true,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: false,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'deploy',
+ description: {
+ content: 'Deploy commands',
+ examples: ['deploy'],
+ usage: 'deploy',
+ },
+ category: 'dev',
+ aliases: ['deploy-commands'],
+ cooldown: 3,
+ args: false,
+ player: {
+ voice: false,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: true,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: false,
+ options: [],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context, _args: string[]): Promise {
- const row = new ActionRowBuilder().addComponents(
- new ButtonBuilder().setCustomId("deploy-global").setLabel("Global").setStyle(ButtonStyle.Secondary),
- new ButtonBuilder().setCustomId("deploy-guild").setLabel("Guild").setStyle(ButtonStyle.Secondary),
- );
+ public async run(client: Lavamusic, ctx: Context, _args: string[]): Promise {
+ const row = new ActionRowBuilder().addComponents(
+ new ButtonBuilder().setCustomId('deploy-global').setLabel('Global').setStyle(ButtonStyle.Secondary),
+ new ButtonBuilder().setCustomId('deploy-guild').setLabel('Guild').setStyle(ButtonStyle.Secondary),
+ );
- let msg: Message | undefined;
- try {
- msg = await ctx.sendMessage({
- content: "Where do you want to deploy the commands?",
- components: [row],
- });
- } catch (error) {
- console.error("Failed to send the initial message:", error);
- return;
- }
+ let msg: Message | undefined;
+ try {
+ msg = await ctx.sendMessage({
+ content: 'Where do you want to deploy the commands?',
+ components: [row],
+ });
+ } catch (error) {
+ console.error('Failed to send the initial message:', error);
+ return;
+ }
- const filter = (interaction: ButtonInteraction<"cached">) => {
- if (interaction.user.id !== ctx.author.id) {
- interaction
- .reply({
- content: "You can't interact with this message",
- ephemeral: true,
- })
- .catch(console.error);
- return false;
- }
- return true;
- };
+ const filter = (interaction: ButtonInteraction<'cached'>) => {
+ if (interaction.user.id !== ctx.author?.id) {
+ interaction
+ .reply({
+ content: "You can't interact with this message",
+ ephemeral: true,
+ })
+ .catch(console.error);
+ return false;
+ }
+ return true;
+ };
- const collector = ctx.channel.createMessageComponentCollector({
- filter,
- componentType: ComponentType.Button,
- time: 30000,
- });
+ const collector = (ctx.channel as TextChannel).createMessageComponentCollector({
+ filter,
+ componentType: ComponentType.Button,
+ time: 30000,
+ });
- collector.on("collect", async (interaction) => {
- try {
- if (interaction.customId === "deploy-global") {
- await client.deployCommands();
- await ctx.editMessage({
- content: "Commands deployed globally.",
- components: [],
- });
- } else if (interaction.customId === "deploy-guild") {
- await client.deployCommands(interaction.guild!.id);
- await ctx.editMessage({
- content: "Commands deployed in this guild.",
- components: [],
- });
- }
- } catch (error) {
- console.error("Failed to handle interaction:", error);
- }
- });
+ collector.on('collect', async interaction => {
+ try {
+ if (interaction.customId === 'deploy-global') {
+ await client.deployCommands();
+ await ctx.editMessage({
+ content: 'Commands deployed globally.',
+ components: [],
+ });
+ } else if (interaction.customId === 'deploy-guild') {
+ await client.deployCommands(interaction.guild!.id);
+ await ctx.editMessage({
+ content: 'Commands deployed in this guild.',
+ components: [],
+ });
+ }
+ } catch (error) {
+ console.error('Failed to handle interaction:', error);
+ }
+ });
- collector.on("end", async (_collected, reason) => {
- if (reason === "time" && msg) {
- try {
- await msg.delete();
- } catch (error) {
- console.error("Failed to delete the message:", error);
- }
- }
- });
- }
+ collector.on('end', async (_collected, reason) => {
+ if (reason === 'time' && msg) {
+ try {
+ await msg.delete();
+ } catch (error) {
+ console.error('Failed to delete the message:', error);
+ }
+ }
+ });
+ }
}
/**
diff --git a/src/commands/dev/Eval.ts b/src/commands/dev/Eval.ts
index 6f0e890fc..1a5eda618 100644
--- a/src/commands/dev/Eval.ts
+++ b/src/commands/dev/Eval.ts
@@ -1,81 +1,81 @@
-import util from "node:util";
-import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js";
-import { fetch } from "undici";
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import util from 'node:util';
+import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from 'discord.js';
+import { fetch } from 'undici';
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Eval extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "eval",
- description: {
- content: "Evaluate code",
- examples: ["eval"],
- usage: "eval",
- },
- category: "dev",
- aliases: ["ev"],
- cooldown: 3,
- args: true,
- player: {
- voice: false,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: true,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: false,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'eval',
+ description: {
+ content: 'Evaluate code',
+ examples: ['eval'],
+ usage: 'eval',
+ },
+ category: 'dev',
+ aliases: ['ev'],
+ cooldown: 3,
+ args: true,
+ player: {
+ voice: false,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: true,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: false,
+ options: [],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
- const code = args.join(" ");
- try {
- let evaled = eval(code);
- if (evaled === client.config) evaled = "Nice try";
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ const code = args.join(' ');
+ try {
+ let evaled = eval(code);
+ if (evaled === client.config) evaled = 'Nice try';
- if (typeof evaled !== "string") evaled = util.inspect(evaled);
- if (evaled.length > 2000) {
- const response = await fetch("https://hasteb.in/post", {
- method: "POST",
- headers: {
- "Content-Type": "text/plain",
- },
- body: evaled,
- });
- const json: any = await response.json();
- evaled = `https://hasteb.in/${json.key}`;
- return await ctx.sendMessage({
- content: evaled,
- });
- }
+ if (typeof evaled !== 'string') evaled = util.inspect(evaled);
+ if (evaled.length > 2000) {
+ const response = await fetch('https://hasteb.in/post', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'text/plain',
+ },
+ body: evaled,
+ });
+ const json: any = await response.json();
+ evaled = `https://hasteb.in/${json.key}`;
+ return await ctx.sendMessage({
+ content: evaled,
+ });
+ }
- const button = new ButtonBuilder().setStyle(ButtonStyle.Danger).setLabel("Delete").setCustomId("eval-delete");
- const row = new ActionRowBuilder().addComponents(button);
+ const button = new ButtonBuilder().setStyle(ButtonStyle.Danger).setLabel('Delete').setCustomId('eval-delete');
+ const row = new ActionRowBuilder().addComponents(button);
- const msg = await ctx.sendMessage({
- content: `\`\`\`js\n${evaled}\n\`\`\``,
- components: [row],
- });
+ const msg = await ctx.sendMessage({
+ content: `\`\`\`js\n${evaled}\n\`\`\``,
+ components: [row],
+ });
- const filter = (i: any) => i.customId === "eval-delete" && i.user.id === ctx.author.id;
- const collector = msg.createMessageComponentCollector({
- time: 60000,
- filter: filter,
- });
+ const filter = (i: any) => i.customId === 'eval-delete' && i.user.id === ctx.author?.id;
+ const collector = msg.createMessageComponentCollector({
+ time: 60000,
+ filter: filter,
+ });
- collector.on("collect", async (i) => {
- await i.deferUpdate();
- await msg.delete();
- });
- } catch (e) {
- ctx.sendMessage(`\`\`\`js\n${e}\n\`\`\``);
- }
- }
+ collector.on('collect', async i => {
+ await i.deferUpdate();
+ await msg.delete();
+ });
+ } catch (e) {
+ ctx.sendMessage(`\`\`\`js\n${e}\n\`\`\``);
+ }
+ }
}
/**
diff --git a/src/commands/dev/GuildLeave.ts b/src/commands/dev/GuildLeave.ts
index e08c6b65b..f038ca065 100644
--- a/src/commands/dev/GuildLeave.ts
+++ b/src/commands/dev/GuildLeave.ts
@@ -1,75 +1,75 @@
-import { ChannelType, type TextChannel } from "discord.js";
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { ChannelType, type TextChannel } from 'discord.js';
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class GuildLeave extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "guildleave",
- description: {
- content: "Leave a guild",
- examples: ["guildleave "],
- usage: "guildleave ",
- },
- category: "dev",
- aliases: ["gl"],
- cooldown: 3,
- args: true,
- player: {
- voice: false,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: true,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: false,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'guildleave',
+ description: {
+ content: 'Leave a guild',
+ examples: ['guildleave '],
+ usage: 'guildleave ',
+ },
+ category: 'dev',
+ aliases: ['gl'],
+ cooldown: 3,
+ args: true,
+ player: {
+ voice: false,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: true,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: false,
+ options: [],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
- const guildId = args[0];
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ const guildId = args[0];
- const guild = await client.shard
- .broadcastEval(
- (c, { guildId }) => {
- const guild = c.guilds.cache.get(guildId);
- return guild ? { id: guild.id, name: guild.name } : null;
- },
- { context: { guildId } },
- )
- .then((results) => results.find((g) => g !== null));
+ const guild = await client.shard
+ ?.broadcastEval(
+ (c, { guildId }) => {
+ const guild = c.guilds.cache.get(guildId);
+ return guild ? { id: guild.id, name: guild.name } : null;
+ },
+ { context: { guildId } },
+ )
+ .then(results => results.find(g => g !== null));
- if (!guild) {
- return await ctx.sendMessage("Guild not found.");
- }
+ if (!guild) {
+ return await ctx.sendMessage('Guild not found.');
+ }
- try {
- await client.shard.broadcastEval(
- async (c, { guildId }) => {
- const guild = c.guilds.cache.get(guildId);
- if (guild) {
- await guild.leave();
- }
- },
- { context: { guildId } },
- );
- await ctx.sendMessage(`Left guild ${guild.name}`);
- } catch {
- await ctx.sendMessage(`Failed to leave guild ${guild.name}`);
- }
+ try {
+ await client.shard?.broadcastEval(
+ async (c, { guildId }) => {
+ const guild = c.guilds.cache.get(guildId);
+ if (guild) {
+ await guild.leave();
+ }
+ },
+ { context: { guildId } },
+ );
+ await ctx.sendMessage(`Left guild ${guild.name}`);
+ } catch {
+ await ctx.sendMessage(`Failed to leave guild ${guild.name}`);
+ }
- const logChannelId = process.env.LOG_CHANNEL_ID;
- if (logChannelId) {
- const logChannel = client.channels.cache.get(logChannelId) as TextChannel;
- if (logChannel && logChannel.type === ChannelType.GuildText) {
- await logChannel.send(`Bot has left guild: ${guild.name} (ID: ${guild.id})`);
- }
- }
- }
+ const logChannelId = process.env.LOG_CHANNEL_ID;
+ if (logChannelId) {
+ const logChannel = client.channels.cache.get(logChannelId) as TextChannel;
+ if (logChannel && logChannel.type === ChannelType.GuildText) {
+ await logChannel.send(`Bot has left guild: ${guild.name} (ID: ${guild.id})`);
+ }
+ }
+ }
}
/**
diff --git a/src/commands/dev/GuildList.ts b/src/commands/dev/GuildList.ts
index 7d7373aa3..43ed3e15b 100644
--- a/src/commands/dev/GuildList.ts
+++ b/src/commands/dev/GuildList.ts
@@ -1,49 +1,51 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type 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",
- examples: ["guildlist"],
- usage: "guildlist",
- },
- category: "dev",
- aliases: ["glst"],
- cooldown: 3,
- args: false,
- player: {
- voice: false,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: true,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: false,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'guildlist',
+ description: {
+ content: 'List all guilds the bot is in',
+ examples: ['guildlist'],
+ usage: 'guildlist',
+ },
+ category: 'dev',
+ aliases: ['glst'],
+ cooldown: 3,
+ args: false,
+ player: {
+ voice: false,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: true,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: false,
+ options: [],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context): Promise {
- const guilds = await client.shard.broadcastEval((c) => c.guilds.cache.map((guild) => ({ name: guild.name, id: guild.id })));
- const allGuilds = guilds.reduce((acc, val) => acc.concat(val), []);
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const guilds = await client.shard?.broadcastEval(c =>
+ c.guilds.cache.map(guild => ({ name: guild.name, id: guild.id })),
+ );
+ const allGuilds = guilds?.reduce((acc, val) => acc.concat(val), []);
- const guildList = allGuilds.map((guild) => `- **${guild.name}** - (${guild.id})`);
- const chunks = client.utils.chunk(guildList, 10) || [[]];
- const pages = chunks.map((chunk, index) => {
- return this.client
- .embed()
- .setColor(this.client.color.main)
- .setDescription(chunk.join("\n"))
- .setFooter({ text: `Page ${index + 1} of ${chunks.length}` });
- });
- await client.utils.paginate(client, ctx, pages);
- }
+ const guildList = allGuilds?.map(guild => `- **${guild.name}** - ${guild.id}`);
+ const chunks = client.utils.chunk(guildList!, 10) || [[]];
+ const pages = chunks.map((chunk, index) => {
+ return this.client
+ .embed()
+ .setColor(this.client.color.main)
+ .setDescription(chunk.join('\n'))
+ .setFooter({ text: `Page ${index + 1} of ${chunks.length}` });
+ });
+ await client.utils.paginate(client, ctx, pages);
+ }
}
/**
diff --git a/src/commands/dev/Restart.ts b/src/commands/dev/Restart.ts
index b947d7981..357ef6719 100644
--- a/src/commands/dev/Restart.ts
+++ b/src/commands/dev/Restart.ts
@@ -1,79 +1,82 @@
-import { exec } from "node:child_process";
-import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js";
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { exec } from 'node:child_process';
+import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from 'discord.js';
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Restart extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "restart",
- description: {
- content: "Restart the bot",
- examples: ["restart"],
- usage: "restart",
- },
- category: "dev",
- aliases: ["reboot"],
- cooldown: 3,
- args: false,
- player: {
- voice: false,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: true,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: false,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'restart',
+ description: {
+ content: 'Restart the bot',
+ examples: ['restart'],
+ usage: 'restart',
+ },
+ category: 'dev',
+ aliases: ['reboot'],
+ cooldown: 3,
+ args: false,
+ player: {
+ voice: false,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: true,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: false,
+ options: [],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context): Promise {
- const embed = this.client.embed();
- const button = new ButtonBuilder().setStyle(ButtonStyle.Danger).setLabel("Confirm Restart").setCustomId("confirm-restart");
- const row = new ActionRowBuilder().addComponents(button);
- const restartEmbed = embed
- .setColor(this.client.color.red)
- .setDescription(`**Are you sure you want to restart **\`${client.user.username}\`?`)
- .setTimestamp();
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const embed = this.client.embed();
+ const button = new ButtonBuilder()
+ .setStyle(ButtonStyle.Danger)
+ .setLabel('Confirm Restart')
+ .setCustomId('confirm-restart');
+ const row = new ActionRowBuilder().addComponents(button);
+ const restartEmbed = embed
+ .setColor(this.client.color.red)
+ .setDescription(`**Are you sure you want to restart **\`${client.user?.username}\`?`)
+ .setTimestamp();
- const msg = await ctx.sendMessage({
- embeds: [restartEmbed],
- components: [row],
- });
+ const msg = await ctx.sendMessage({
+ embeds: [restartEmbed],
+ components: [row],
+ });
- const filter = (i: any) => i.customId === "confirm-restart" && i.user.id === ctx.author.id;
- const collector = msg.createMessageComponentCollector({
- time: 30000,
- filter,
- });
+ const filter = (i: any) => i.customId === 'confirm-restart' && i.user.id === ctx.author?.id;
+ const collector = msg.createMessageComponentCollector({
+ time: 30000,
+ filter,
+ });
- collector.on("collect", async (i) => {
- await i.deferUpdate();
+ collector.on('collect', async i => {
+ await i.deferUpdate();
- await msg.edit({
- content: "Restarting the bot...",
- embeds: [],
- components: [],
- });
+ await msg.edit({
+ content: 'Restarting the bot...',
+ embeds: [],
+ components: [],
+ });
- await client.destroy();
- exec("node scripts/restart.ts");
- process.exit(0);
- });
+ await client.destroy();
+ exec('node scripts/restart.js');
+ process.exit(0);
+ });
- collector.on("end", async () => {
- if (collector.collected.size === 0) {
- await msg.edit({
- content: "Restart cancelled.",
- components: [],
- });
- }
- });
- }
+ collector.on('end', async () => {
+ if (collector.collected.size === 0) {
+ await msg.edit({
+ content: 'Restart cancelled.',
+ components: [],
+ });
+ }
+ });
+ }
}
/**
diff --git a/src/commands/filters/8d.ts b/src/commands/filters/8d.ts
index cf10b89d1..8d106a29c 100644
--- a/src/commands/filters/8d.ts
+++ b/src/commands/filters/8d.ts
@@ -1,64 +1,61 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index.js';
export default class _8d extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "8d",
- description: {
- content: "cmd.8d.description",
- examples: ["8d"],
- usage: "8d",
- },
- category: "filters",
- aliases: ["3d"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: true,
- dj: true,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: '8d',
+ description: {
+ content: 'cmd.8d.description',
+ examples: ['8d'],
+ usage: '8d',
+ },
+ category: 'filters',
+ aliases: ['3d'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: true,
+ dj: true,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context): Promise {
- const player = client.queue.get(ctx.guild!.id);
- const filterEnabled = player.filters.includes("8D");
- const rotationConfig = filterEnabled ? {} : { rotationHz: 0.2 };
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const filterEnabled = player.filterManager.filters.rotation;
- await player.player.setRotation(rotationConfig);
-
- if (filterEnabled) {
- player.filters = player.filters.filter((filter) => filter !== "8D");
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.8d.messages.filter_disabled"),
- color: this.client.color.main,
- },
- ],
- });
- } else {
- player.filters.push("8D");
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.8d.messages.filter_enabled"),
- color: this.client.color.main,
- },
- ],
- });
- }
- }
+ if (filterEnabled) {
+ await player.filterManager.toggleRotation();
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.8d.messages.filter_disabled'),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ } else {
+ await player.filterManager.toggleRotation(0.2);
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.8d.messages.filter_enabled'),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ }
+ }
}
/**
diff --git a/src/commands/filters/BassBoost.ts b/src/commands/filters/BassBoost.ts
index 75188421f..fa95cef36 100644
--- a/src/commands/filters/BassBoost.ts
+++ b/src/commands/filters/BassBoost.ts
@@ -1,68 +1,104 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { ApplicationCommandOptionType } from 'discord.js';
+import { EQList } from 'lavalink-client';
+import { Command, type Context, type Lavamusic } from '../../structures/index.js';
export default class BassBoost extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "bassboost",
- description: {
- content: "cmd.bassboost.description",
- examples: ["bassboost"],
- usage: "bassboost",
- },
- category: "filters",
- aliases: ["bb"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: true,
- dj: true,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'bassboost',
+ description: {
+ content: 'cmd.bassboost.description',
+ examples: ['bassboost high', 'bassboost medium', 'bassboost low', 'bassboost off'],
+ usage: 'bassboost [level]',
+ },
+ category: 'filters',
+ aliases: ['bb'],
+ cooldown: 3,
+ args: true,
+ vote: false,
+ player: {
+ voice: true,
+ dj: true,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [
+ {
+ name: 'level',
+ description: 'cmd.bassboost.options.level',
+ type: ApplicationCommandOptionType.String,
+ required: true,
+ choices: [
+ { name: 'high', value: 'high' },
+ { name: 'medium', value: 'medium' },
+ { name: 'low', value: 'low' },
+ { name: 'off', value: 'off' },
+ ],
+ },
+ ],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context): Promise {
- const player = client.queue.get(ctx.guild!.id);
- const filterEnabled = player.filters.includes("bassboost");
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
- if (filterEnabled) {
- await player.player.setEqualizer([]);
- player.filters = player.filters.filter((filter) => filter !== "bassboost");
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.bassboost.messages.filter_disabled"),
- color: this.client.color.main,
- },
- ],
- });
- } else {
- await 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");
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.bassboost.messages.filter_enabled"),
- color: this.client.color.main,
- },
- ],
- });
- }
- }
+ switch (ctx.args[0]?.toLowerCase()) {
+ case 'high': {
+ await player.filterManager.setEQ(EQList.BassboostHigh);
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.bassboost.messages.high'),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ break;
+ }
+ case 'medium': {
+ await player.filterManager.setEQ(EQList.BassboostMedium);
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.bassboost.messages.medium'),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ break;
+ }
+ case 'low': {
+ await player.filterManager.setEQ(EQList.BassboostLow);
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.bassboost.messages.low'),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ break;
+ }
+ case 'off': {
+ await player.filterManager.clearEQ();
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.bassboost.messages.off'),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ break;
+ }
+ }
+ }
}
/**
diff --git a/src/commands/filters/Distorsion.ts b/src/commands/filters/Distorsion.ts
deleted file mode 100644
index 289588984..000000000
--- a/src/commands/filters/Distorsion.ts
+++ /dev/null
@@ -1,81 +0,0 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
-
-export default class Distorsion extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "distorsion",
- description: {
- content: "cmd.distorsion.description",
- examples: ["distorsion"],
- usage: "distorsion",
- },
- category: "filters",
- aliases: ["dt"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: true,
- dj: true,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
-
- public async run(client: Lavamusic, ctx: Context): Promise {
- const player = client.queue.get(ctx.guild!.id);
- const filterEnabled = player.filters.includes("distorsion");
-
- if (filterEnabled) {
- await player.player.setDistortion({});
- player.filters = player.filters.filter((filter) => filter !== "distorsion");
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.distorsion.messages.filter_disabled"),
- color: this.client.color.main,
- },
- ],
- });
- } else {
- await player.player.setDistortion({
- sinOffset: 0,
- sinScale: 1,
- cosOffset: 0,
- cosScale: 1,
- tanOffset: 0,
- tanScale: 1,
- offset: 0,
- scale: 1,
- });
- player.filters.push("distorsion");
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.distorsion.messages.filter_enabled"),
- color: this.client.color.main,
- },
- ],
- });
- }
- }
-}
-
-/**
- * Project: lavamusic
- * Author: Appu
- * Main Contributor: LucasB25
- * Company: Coders
- * Copyright (c) 2024. All rights reserved.
- * 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
- */
diff --git a/src/commands/filters/Karaoke.ts b/src/commands/filters/Karaoke.ts
index c41e3d358..f23ed6367 100644
--- a/src/commands/filters/Karaoke.ts
+++ b/src/commands/filters/Karaoke.ts
@@ -1,68 +1,61 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index.js';
export default class Karaoke extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "karaoke",
- description: {
- content: "cmd.karaoke.description",
- examples: ["karaoke"],
- usage: "karaoke",
- },
- category: "filters",
- aliases: ["kk"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: true,
- dj: true,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'karaoke',
+ description: {
+ content: 'cmd.karaoke.description',
+ examples: ['karaoke'],
+ usage: 'karaoke',
+ },
+ category: 'filters',
+ aliases: ['kk'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: true,
+ dj: true,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context): Promise {
- const player = client.queue.get(ctx.guild!.id);
- const filterEnabled = player.filters.includes("karaoke");
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const filterEnabled = player.filterManager.filters.karaoke;
- if (filterEnabled) {
- await player.player.setKaraoke();
- player.filters = player.filters.filter((filter) => filter !== "karaoke");
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.karaoke.messages.filter_disabled"),
- color: this.client.color.main,
- },
- ],
- });
- } else {
- await player.player.setKaraoke({
- level: 1,
- monoLevel: 1,
- filterBand: 220,
- filterWidth: 100,
- });
- player.filters.push("karaoke");
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.karaoke.messages.filter_enabled"),
- color: this.client.color.main,
- },
- ],
- });
- }
- }
+ if (filterEnabled) {
+ await player.filterManager.toggleKaraoke();
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.karaoke.messages.filter_disabled'),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ } else {
+ await player.filterManager.toggleKaraoke();
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.karaoke.messages.filter_enabled'),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ }
+ }
}
/**
diff --git a/src/commands/filters/LowPass.ts b/src/commands/filters/LowPass.ts
index da33a65e9..1d751a19c 100644
--- a/src/commands/filters/LowPass.ts
+++ b/src/commands/filters/LowPass.ts
@@ -1,63 +1,61 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index.js';
export default class LowPass extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "lowpass",
- description: {
- content: "cmd.lowpass.description",
- examples: ["lowpass"],
- usage: "lowpass ",
- },
- category: "filters",
- aliases: ["lp"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: true,
- dj: true,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'lowpass',
+ description: {
+ content: 'cmd.lowpass.description',
+ examples: ['lowpass'],
+ usage: 'lowpass ',
+ },
+ category: 'filters',
+ aliases: ['lp'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: true,
+ dj: true,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context): Promise {
- const player = client.queue.get(ctx.guild!.id);
- const filterEnabled = player.filters.includes("lowpass");
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const filterEnabled = player.filterManager.filters.lowPass;
- if (filterEnabled) {
- await player.player.setLowPass({ smoothing: 0 });
- player.filters = player.filters.filter((filter) => filter !== "lowpass");
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.lowpass.messages.filter_disabled"),
- color: this.client.color.main,
- },
- ],
- });
- } else {
- await player.player.setLowPass({ smoothing: 20 });
- player.filters.push("lowpass");
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.lowpass.messages.filter_enabled"),
- color: this.client.color.main,
- },
- ],
- });
- }
- }
+ if (filterEnabled) {
+ await player.filterManager.toggleLowPass();
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.lowpass.messages.filter_disabled'),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ } else {
+ await player.filterManager.toggleLowPass(20);
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.lowpass.messages.filter_enabled'),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ }
+ }
}
/**
diff --git a/src/commands/filters/NightCore.ts b/src/commands/filters/NightCore.ts
index 57cbae9d9..043a25f5a 100644
--- a/src/commands/filters/NightCore.ts
+++ b/src/commands/filters/NightCore.ts
@@ -1,63 +1,61 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index.js';
export default class NightCore extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "nightcore",
- description: {
- content: "cmd.nightcore.description",
- examples: ["nightcore"],
- usage: "nightcore",
- },
- category: "filters",
- aliases: ["nc"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: true,
- dj: true,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'nightcore',
+ description: {
+ content: 'cmd.nightcore.description',
+ examples: ['nightcore'],
+ usage: 'nightcore',
+ },
+ category: 'filters',
+ aliases: ['nc'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: true,
+ dj: true,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context): Promise {
- const player = client.queue.get(ctx.guild!.id);
- const filterEnabled = player.filters.includes("nightcore");
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const filterEnabled = player.filterManager.filters.nightcore;
- if (filterEnabled) {
- await player.player.setTimescale({});
- player.filters = player.filters.filter((filter) => filter !== "nightcore");
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.nightcore.messages.filter_disabled"),
- color: this.client.color.main,
- },
- ],
- });
- } else {
- await player.player.setTimescale({ rate: 1.2 });
- player.filters.push("nightcore");
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.nightcore.messages.filter_enabled"),
- color: this.client.color.main,
- },
- ],
- });
- }
- }
+ if (filterEnabled) {
+ await player.filterManager.toggleNightcore();
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.nightcore.messages.filter_disabled'),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ } else {
+ await player.filterManager.toggleNightcore();
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.nightcore.messages.filter_enabled'),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ }
+ }
}
/**
diff --git a/src/commands/filters/Pitch.ts b/src/commands/filters/Pitch.ts
index 5cb2105d4..7098df309 100644
--- a/src/commands/filters/Pitch.ts
+++ b/src/commands/filters/Pitch.ts
@@ -1,72 +1,72 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index.js';
export default class Pitch extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "pitch",
- description: {
- content: "cmd.pitch.description",
- examples: ["pitch 1", "pitch 1.5", "pitch 1,5"],
- usage: "pitch ",
- },
- category: "filters",
- aliases: ["ph"],
- cooldown: 3,
- args: true,
- vote: false,
- player: {
- voice: true,
- dj: true,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [
- {
- name: "pitch",
- description: "cmd.pitch.options.pitch",
- type: 3,
- required: true,
- },
- ],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'pitch',
+ description: {
+ content: 'cmd.pitch.description',
+ examples: ['pitch 1', 'pitch 1.5', 'pitch 1,5'],
+ usage: 'pitch ',
+ },
+ category: 'filters',
+ aliases: ['ph'],
+ cooldown: 3,
+ args: true,
+ vote: false,
+ player: {
+ voice: true,
+ dj: true,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [
+ {
+ name: 'pitch',
+ description: 'cmd.pitch.options.pitch',
+ type: 3,
+ required: true,
+ },
+ ],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
- const player = client.queue.get(ctx.guild!.id);
- const pitchString = args[0].replace(",", ".");
- const isValidNumber = /^[0-9]*\.?[0-9]+$/.test(pitchString);
- const pitch = parseFloat(pitchString);
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const pitchString = args[0].replace(',', '.');
+ const isValidNumber = /^[0-9]*\.?[0-9]+$/.test(pitchString);
+ const pitch = Number.parseFloat(pitchString);
- if (!isValidNumber || isNaN(pitch) || pitch < 0.5 || pitch > 5) {
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.pitch.errors.invalid_number"),
- color: this.client.color.red,
- },
- ],
- });
- return;
- }
+ if (!isValidNumber || Number.isNaN(pitch) || pitch < 0.5 || pitch > 5) {
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.pitch.errors.invalid_number'),
+ color: this.client.color.red,
+ },
+ ],
+ });
+ return;
+ }
- await player.player.setTimescale({ pitch });
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.pitch.messages.pitch_set", {
- pitch,
- }),
- color: this.client.color.main,
- },
- ],
- });
- }
+ await player.filterManager.setPitch(pitch);
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.pitch.messages.pitch_set', {
+ pitch,
+ }),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ }
}
/**
diff --git a/src/commands/filters/Rate.ts b/src/commands/filters/Rate.ts
index f9e1733d3..8c8204178 100644
--- a/src/commands/filters/Rate.ts
+++ b/src/commands/filters/Rate.ts
@@ -1,72 +1,72 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index.js';
export default class Rate extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "rate",
- description: {
- content: "cmd.rate.description",
- examples: ["rate 1", "rate 1.5", "rate 1,5"],
- usage: "rate ",
- },
- category: "filters",
- aliases: ["rt"],
- cooldown: 3,
- args: true,
- vote: false,
- player: {
- voice: true,
- dj: true,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [
- {
- name: "rate",
- description: "cmd.rate.options.rate",
- type: 3,
- required: true,
- },
- ],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'rate',
+ description: {
+ content: 'cmd.rate.description',
+ examples: ['rate 1', 'rate 1.5', 'rate 1,5'],
+ usage: 'rate ',
+ },
+ category: 'filters',
+ aliases: ['rt'],
+ cooldown: 3,
+ args: true,
+ vote: false,
+ player: {
+ voice: true,
+ dj: true,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [
+ {
+ name: 'rate',
+ description: 'cmd.rate.options.rate',
+ type: 3,
+ required: true,
+ },
+ ],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
- const player = client.queue.get(ctx.guild!.id);
- const rateString = args[0].replace(",", ".");
- const isValidNumber = /^[0-9]*\.?[0-9]+$/.test(rateString);
- const rate = parseFloat(rateString);
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const rateString = args[0].replace(',', '.');
+ const isValidNumber = /^[0-9]*\.?[0-9]+$/.test(rateString);
+ const rate = Number.parseFloat(rateString);
- if (!isValidNumber || isNaN(rate) || rate < 0.5 || rate > 5) {
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.rate.errors.invalid_number"),
- color: this.client.color.red,
- },
- ],
- });
- return;
- }
+ if (!isValidNumber || Number.isNaN(rate) || rate < 0.5 || rate > 5) {
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.rate.errors.invalid_number'),
+ color: this.client.color.red,
+ },
+ ],
+ });
+ return;
+ }
- await player.player.setTimescale({ rate });
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.rate.messages.rate_set", {
- rate,
- }),
- color: this.client.color.main,
- },
- ],
- });
- }
+ await player.filterManager.setRate(rate);
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.rate.messages.rate_set', {
+ rate,
+ }),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ }
}
/**
diff --git a/src/commands/filters/Reset.ts b/src/commands/filters/Reset.ts
index cced01703..f527932ac 100644
--- a/src/commands/filters/Reset.ts
+++ b/src/commands/filters/Reset.ts
@@ -1,48 +1,48 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index.js';
export default class Reset extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "reset",
- description: {
- content: "cmd.reset.description",
- examples: ["reset"],
- usage: "reset",
- },
- category: "filters",
- aliases: ["rs"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: true,
- dj: true,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'reset',
+ description: {
+ content: 'cmd.reset.description',
+ examples: ['reset'],
+ usage: 'reset',
+ },
+ category: 'filters',
+ aliases: ['rs'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: true,
+ dj: true,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context): Promise {
- const player = client.queue.get(ctx.guild!.id);
- player.player.clearFilters();
- player.filters = [];
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.reset.messages.filters_reset"),
- color: this.client.color.main,
- },
- ],
- });
- }
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ player.filterManager.resetFilters();
+ player.filterManager.clearEQ();
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.reset.messages.filters_reset'),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ }
}
/**
diff --git a/src/commands/filters/Rotation.ts b/src/commands/filters/Rotation.ts
index 6519a80d1..32cff3e57 100644
--- a/src/commands/filters/Rotation.ts
+++ b/src/commands/filters/Rotation.ts
@@ -1,61 +1,59 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index.js';
export default class Rotation extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "rotation",
- description: {
- content: "cmd.rotation.description",
- examples: ["rotation"],
- usage: "rotation",
- },
- category: "filters",
- aliases: ["rt"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: true,
- dj: true,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'rotation',
+ description: {
+ content: 'cmd.rotation.description',
+ examples: ['rotation'],
+ usage: 'rotation',
+ },
+ category: 'filters',
+ aliases: ['rt'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: true,
+ dj: true,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', '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("rotation")) {
- player.player.setRotation();
- player.filters = player.filters.filter((filter) => filter !== "rotation");
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.rotation.messages.disabled"),
- color: this.client.color.main,
- },
- ],
- });
- } else {
- player.player.setRotation({ rotationHz: 0 });
- player.filters.push("rotation");
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.rotation.messages.enabled"),
- color: this.client.color.main,
- },
- ],
- });
- }
- }
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ if (player.filterManager.filters.rotation) {
+ player.filterManager.toggleRotation();
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.rotation.messages.disabled'),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ } else {
+ player.filterManager.toggleRotation();
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.rotation.messages.enabled'),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ }
+ }
}
/**
diff --git a/src/commands/filters/Speed.ts b/src/commands/filters/Speed.ts
index cc467c539..1c26e0f9a 100644
--- a/src/commands/filters/Speed.ts
+++ b/src/commands/filters/Speed.ts
@@ -1,72 +1,72 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index.js';
export default class Speed extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "speed",
- description: {
- content: "cmd.speed.description",
- examples: ["speed 1.5", "speed 1,5"],
- usage: "speed ",
- },
- category: "filters",
- aliases: ["spd"],
- cooldown: 3,
- args: true,
- vote: false,
- player: {
- voice: true,
- dj: true,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [
- {
- name: "speed",
- description: "cmd.speed.options.speed",
- type: 3,
- required: true,
- },
- ],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'speed',
+ description: {
+ content: 'cmd.speed.description',
+ examples: ['speed 1.5', 'speed 1,5'],
+ usage: 'speed ',
+ },
+ category: 'filters',
+ aliases: ['spd'],
+ cooldown: 3,
+ args: true,
+ vote: false,
+ player: {
+ voice: true,
+ dj: true,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [
+ {
+ name: 'speed',
+ description: 'cmd.speed.options.speed',
+ type: 3,
+ required: true,
+ },
+ ],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
- const player = client.queue.get(ctx.guild!.id);
- const speedString = args[0].replace(",", ".");
- const isValidNumber = /^[0-9]*\.?[0-9]+$/.test(speedString);
- const speed = parseFloat(speedString);
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const speedString = args[0].replace(',', '.');
+ const isValidNumber = /^[0-9]*\.?[0-9]+$/.test(speedString);
+ const speed = Number.parseFloat(speedString);
- if (!isValidNumber || isNaN(speed) || speed < 0.5 || speed > 5) {
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.speed.messages.invalid_number"),
- color: this.client.color.red,
- },
- ],
- });
- return;
- }
+ if (!isValidNumber || Number.isNaN(speed) || speed < 0.5 || speed > 5) {
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.speed.messages.invalid_number'),
+ color: this.client.color.red,
+ },
+ ],
+ });
+ return;
+ }
- player.player.setTimescale({ speed });
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.speed.messages.set_speed", {
- speed,
- }),
- color: this.client.color.main,
- },
- ],
- });
- }
+ player.filterManager.setSpeed(speed);
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.speed.messages.set_speed', {
+ speed,
+ }),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ }
}
/**
diff --git a/src/commands/filters/Tremolo.ts b/src/commands/filters/Tremolo.ts
index 0d31189a8..bb38235d5 100644
--- a/src/commands/filters/Tremolo.ts
+++ b/src/commands/filters/Tremolo.ts
@@ -1,63 +1,61 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index.js';
export default class Tremolo extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "tremolo",
- description: {
- content: "cmd.tremolo.description",
- examples: ["tremolo"],
- usage: "tremolo",
- },
- category: "filters",
- aliases: ["tr"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: true,
- dj: true,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'tremolo',
+ description: {
+ content: 'cmd.tremolo.description',
+ examples: ['tremolo'],
+ usage: 'tremolo',
+ },
+ category: 'filters',
+ aliases: ['tr'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: true,
+ dj: true,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context): Promise {
- const player = client.queue.get(ctx.guild!.id);
- const tremoloEnabled = player.filters.includes("tremolo");
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const tremoloEnabled = player.filterManager.filters.tremolo;
- if (tremoloEnabled) {
- player.player.setTremolo();
- player.filters.splice(player.filters.indexOf("tremolo"), 1);
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.tremolo.messages.disabled"),
- color: this.client.color.main,
- },
- ],
- });
- } else {
- player.player.setTremolo({ depth: 0.75, frequency: 4 });
- player.filters.push("tremolo");
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.tremolo.messages.enabled"),
- color: this.client.color.main,
- },
- ],
- });
- }
- }
+ if (tremoloEnabled) {
+ player.filterManager.toggleTremolo();
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.tremolo.messages.disabled'),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ } else {
+ player.filterManager.toggleTremolo();
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.tremolo.messages.enabled'),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ }
+ }
}
/**
diff --git a/src/commands/filters/Vibrato.ts b/src/commands/filters/Vibrato.ts
index 4dad08598..10eee4423 100644
--- a/src/commands/filters/Vibrato.ts
+++ b/src/commands/filters/Vibrato.ts
@@ -1,63 +1,61 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index.js';
export default class Vibrato extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "vibrato",
- description: {
- content: "cmd.vibrato.description",
- examples: ["vibrato"],
- usage: "vibrato",
- },
- category: "filters",
- aliases: ["vb"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: true,
- dj: true,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'vibrato',
+ description: {
+ content: 'cmd.vibrato.description',
+ examples: ['vibrato'],
+ usage: 'vibrato',
+ },
+ category: 'filters',
+ aliases: ['vb'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: true,
+ dj: true,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context): Promise {
- const player = client.queue.get(ctx.guild!.id);
- const vibratoEnabled = player.filters.includes("vibrato");
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const vibratoEnabled = player.filterManager.filters.vibrato;
- if (vibratoEnabled) {
- player.player.setVibrato();
- player.filters.splice(player.filters.indexOf("vibrato"), 1);
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.vibrato.messages.disabled"),
- color: this.client.color.main,
- },
- ],
- });
- } else {
- player.player.setVibrato({ depth: 0.75, frequency: 4 });
- player.filters.push("vibrato");
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.vibrato.messages.enabled"),
- color: this.client.color.main,
- },
- ],
- });
- }
- }
+ if (vibratoEnabled) {
+ player.filterManager.toggleVibrato();
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.vibrato.messages.disabled'),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ } else {
+ player.filterManager.toggleVibrato();
+ await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.vibrato.messages.enabled'),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ }
+ }
}
/**
diff --git a/src/commands/info/About.ts b/src/commands/info/About.ts
index 7865d9c01..73093e8b6 100644
--- a/src/commands/info/About.ts
+++ b/src/commands/info/About.ts
@@ -1,84 +1,86 @@
-import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js";
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from 'discord.js';
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class About extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "about",
- description: {
- content: "cmd.about.description",
- examples: ["about"],
- usage: "about",
- },
- category: "info",
- aliases: ["ab"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: false,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'about',
+ description: {
+ content: 'cmd.about.description',
+ examples: ['about'],
+ usage: 'about',
+ },
+ category: 'info',
+ aliases: ['ab'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: false,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context): Promise {
- const inviteButton = new ButtonBuilder()
- .setLabel(ctx.locale("buttons.invite"))
- .setStyle(ButtonStyle.Link)
- .setURL(
- `https://discord.com/api/oauth2/authorize?client_id=${client.config.clientId}&permissions=8&scope=bot%20applications.commands`,
- );
- const supportButton = new ButtonBuilder()
- .setLabel(ctx.locale("buttons.support"))
- .setStyle(ButtonStyle.Link)
- .setURL("https://discord.gg/ns8CTk9J3e");
- const row = new ActionRowBuilder().addComponents(inviteButton, supportButton);
- 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: ctx.locale("cmd.about.fields.creator"),
- value: "[appujet](https://github.com/appujet)",
- inline: true,
- },
- {
- name: ctx.locale("cmd.about.fields.repository"),
- value: "[Here](https://github.com/appujet/lavamusic)",
- inline: true,
- },
- {
- name: ctx.locale("cmd.about.fields.support"),
- value: "[Here](https://discord.gg/ns8CTk9J3e)",
- inline: true,
- },
- {
- name: "\u200b",
- value: ctx.locale("cmd.about.fields.description"),
- inline: true,
- },
- );
- await ctx.sendMessage({
- content: "",
- embeds: [embed],
- components: [row],
- });
- }
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const inviteButton = new ButtonBuilder()
+ .setLabel(ctx.locale('buttons.invite'))
+ .setStyle(ButtonStyle.Link)
+ .setURL(
+ `https://discord.com/api/oauth2/authorize?client_id=${client.env.CLIENT_ID}&permissions=8&scope=bot%20applications.commands`,
+ );
+ const supportButton = new ButtonBuilder()
+ .setLabel(ctx.locale('buttons.support'))
+ .setStyle(ButtonStyle.Link)
+ .setURL('https://discord.gg/ns8CTk9J3e');
+ const row = new ActionRowBuilder().addComponents(inviteButton, supportButton);
+ 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: ctx.locale('cmd.about.fields.creator'),
+ value: '[appujet](https://github.com/appujet)',
+ inline: true,
+ },
+ {
+ name: ctx.locale('cmd.about.fields.repository'),
+ value: '[Here](https://github.com/appujet/lavamusic)',
+ inline: true,
+ },
+ {
+ name: ctx.locale('cmd.about.fields.support'),
+ value: '[Here](https://discord.gg/ns8CTk9J3e)',
+ inline: true,
+ },
+ {
+ name: '\u200b',
+ value: ctx.locale('cmd.about.fields.description'),
+ inline: true,
+ },
+ );
+ await ctx.sendMessage({
+ content: '',
+ embeds: [embed],
+ components: [row],
+ });
+ }
}
/**
diff --git a/src/commands/info/Botinfo.ts b/src/commands/info/Botinfo.ts
index c4038bfea..a073f0406 100644
--- a/src/commands/info/Botinfo.ts
+++ b/src/commands/info/Botinfo.ts
@@ -1,83 +1,83 @@
-import os from "node:os";
-import { version } from "discord.js";
-import { showTotalMemory, usagePercent } from "node-system-stats";
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import os from 'node:os';
+import { version } from 'discord.js';
+import { showTotalMemory, usagePercent } from 'node-system-stats';
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Botinfo extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "botinfo",
- description: {
- content: "cmd.botinfo.description",
- examples: ["botinfo"],
- usage: "botinfo",
- },
- category: "info",
- aliases: ["bi", "info", "stats", "status"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: false,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'botinfo',
+ description: {
+ content: 'cmd.botinfo.description',
+ examples: ['botinfo'],
+ usage: 'botinfo',
+ },
+ category: 'info',
+ aliases: ['bi', 'info', 'stats', 'status'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: false,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context): Promise {
- const osInfo = `${os.type()} ${os.release()}`;
- const osUptime = client.utils.formatTime(os.uptime());
- const osHostname = os.hostname();
- const cpuInfo = `${os.arch()} (${os.cpus().length} cores)`;
- const cpuUsed = (await usagePercent({ coreIndex: 0, sampleMs: 2000 })).percent;
- const memTotal = showTotalMemory(true);
- const memUsed = (process.memoryUsage().rss / 1024 ** 2).toFixed(2);
- const nodeVersion = process.version;
- const discordJsVersion = version;
- const commands = client.commands.size;
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const osInfo = `${os.type()} ${os.release()}`;
+ const osUptime = client.utils.formatTime(os.uptime());
+ const osHostname = os.hostname();
+ const cpuInfo = `${os.arch()} (${os.cpus().length} cores)`;
+ const cpuUsed = (await usagePercent({ coreIndex: 0, sampleMs: 2000 })).percent;
+ const memTotal = showTotalMemory(true);
+ const memUsed = (process.memoryUsage().rss / 1024 ** 2).toFixed(2);
+ const nodeVersion = process.version;
+ const discordJsVersion = version;
+ const commands = client.commands.size;
- const promises = [
- client.shard.broadcastEval((client) => client.guilds.cache.size),
- client.shard.broadcastEval((client) => client.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0)),
- client.shard.broadcastEval((client) => client.channels.cache.size),
- ];
- return Promise.all(promises).then(async (results) => {
- const guilds = results[0].reduce((acc, guildCount) => acc + guildCount, 0);
- const users = results[1].reduce((acc, memberCount) => acc + memberCount, 0);
- const channels = results[2].reduce((acc, channelCount) => acc + channelCount, 0);
+ const promises = [
+ client.shard?.broadcastEval(client => client.guilds.cache.size),
+ client.shard?.broadcastEval(client => client.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0)),
+ client.shard?.broadcastEval(client => client.channels.cache.size),
+ ];
+ return Promise.all(promises).then(async results => {
+ const guilds = results[0]?.reduce((acc, guildCount) => acc + guildCount, 0);
+ const users = results[1]?.reduce((acc, memberCount) => acc + memberCount, 0);
+ const channels = results[2]?.reduce((acc, channelCount) => acc + channelCount, 0);
- const botInfo = ctx.locale("cmd.botinfo.content", {
- osInfo,
- osUptime,
- osHostname,
- cpuInfo,
- cpuUsed,
- memUsed,
- memTotal,
- nodeVersion,
- discordJsVersion,
- guilds,
- channels,
- users,
- commands,
- });
+ const botInfo = ctx.locale('cmd.botinfo.content', {
+ osInfo,
+ osUptime,
+ osHostname,
+ cpuInfo,
+ cpuUsed,
+ memUsed,
+ memTotal,
+ nodeVersion,
+ discordJsVersion,
+ guilds,
+ channels,
+ users,
+ commands,
+ });
- const embed = this.client.embed().setColor(this.client.color.main).setDescription(botInfo);
+ const embed = this.client.embed().setColor(this.client.color.main).setDescription(botInfo);
- return await ctx.sendMessage({
- embeds: [embed],
- });
- });
- }
+ return await ctx.sendMessage({
+ embeds: [embed],
+ });
+ });
+ }
}
/**
diff --git a/src/commands/info/Help.ts b/src/commands/info/Help.ts
index eddcc5617..65400ea36 100644
--- a/src/commands/info/Help.ts
+++ b/src/commands/info/Help.ts
@@ -1,112 +1,114 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Help extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "help",
- description: {
- content: "cmd.help.description",
- examples: ["help"],
- usage: "help",
- },
- category: "info",
- aliases: ["h"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: false,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [
- {
- name: "command",
- description: "cmd.help.options.command",
- type: 3,
- required: false,
- },
- ],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'help',
+ description: {
+ content: 'cmd.help.description',
+ examples: ['help'],
+ usage: 'help',
+ },
+ category: 'info',
+ aliases: ['h'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: false,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [
+ {
+ name: 'command',
+ description: 'cmd.help.options.command',
+ type: 3,
+ required: false,
+ },
+ ],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
- const embed = this.client.embed();
- const guild = await client.db.get(ctx.guild.id);
- const commands = this.client.commands.filter((cmd) => cmd.category !== "dev");
- const categories = [...new Set(commands.map((cmd) => cmd.category))];
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ const embed = this.client.embed();
+ const guild = await client.db.get(ctx.guild!.id);
+ const commands = this.client.commands.filter(cmd => cmd.category !== 'dev');
+ const categories = [...new Set(commands.map(cmd => cmd.category))];
- if (args[0]) {
- const command = this.client.commands.get(args[0].toLowerCase());
- if (!command) {
- return await ctx.sendMessage({
- embeds: [
- embed.setColor(this.client.color.red).setDescription(
- ctx.locale("cmd.help.not_found", {
- cmdName: args[0],
- }),
- ),
- ],
- });
- }
- const helpEmbed = embed
- .setColor(client.color.main)
- .setTitle(`${ctx.locale("cmd.help.title")} - ${command.name}`)
- .setDescription(
- ctx.locale("cmd.help.help_cmd", {
- description: ctx.locale(command.description.content),
- usage: `${guild.prefix}${command.description.usage}`,
- examples: command.description.examples.map((example) => `${guild.prefix}${example}`).join(", "),
- aliases: command.aliases.map((alias) => `\`${alias}\``).join(", "),
- category: command.category,
- cooldown: command.cooldown,
- premUser:
- command.permissions.user.length > 0 ? command.permissions.user.map((perm) => `\`${perm}\``).join(", ") : "None",
- premBot: command.permissions.client.map((perm) => `\`${perm}\``).join(", "),
- dev: command.permissions.dev ? "Yes" : "No",
- slash: command.slashCommand ? "Yes" : "No",
- args: command.args ? "Yes" : "No",
- player: command.player.active ? "Yes" : "No",
- dj: command.player.dj ? "Yes" : "No",
- djPerm: command.player.djPerm ? command.player.djPerm : "None",
- voice: command.player.voice ? "Yes" : "No",
- }),
- );
- return await ctx.sendMessage({ embeds: [helpEmbed] });
- }
+ if (args[0]) {
+ const command = this.client.commands.get(args[0].toLowerCase());
+ if (!command) {
+ return await ctx.sendMessage({
+ embeds: [
+ embed.setColor(this.client.color.red).setDescription(
+ ctx.locale('cmd.help.not_found', {
+ cmdName: args[0],
+ }),
+ ),
+ ],
+ });
+ }
+ const helpEmbed = embed
+ .setColor(client.color.main)
+ .setTitle(`${ctx.locale('cmd.help.title')} - ${command.name}`)
+ .setDescription(
+ ctx.locale('cmd.help.help_cmd', {
+ description: ctx.locale(command.description.content),
+ usage: `${guild?.prefix}${command.description.usage}`,
+ examples: command.description.examples.map((example: string) => `${guild.prefix}${example}`).join(', '),
+ aliases: command.aliases.map((alias: string) => `\`${alias}\``).join(', '),
+ category: command.category,
+ cooldown: command.cooldown,
+ premUser:
+ command.permissions.user.length > 0
+ ? command.permissions.user.map((perm: string) => `\`${perm}\``).join(', ')
+ : 'None',
+ premBot: command.permissions.client.map((perm: string) => `\`${perm}\``).join(', '),
+ dev: command.permissions.dev ? 'Yes' : 'No',
+ slash: command.slashCommand ? 'Yes' : 'No',
+ args: command.args ? 'Yes' : 'No',
+ player: command.player.active ? 'Yes' : 'No',
+ dj: command.player.dj ? 'Yes' : 'No',
+ djPerm: command.player.djPerm ? command.player.djPerm : 'None',
+ voice: command.player.voice ? 'Yes' : 'No',
+ }),
+ );
+ return await ctx.sendMessage({ embeds: [helpEmbed] });
+ }
- const fields = categories.map((category) => ({
- name: category,
- value: commands
- .filter((cmd) => cmd.category === category)
- .map((cmd) => `\`${cmd.name}\``)
- .join(", "),
- inline: false,
- }));
+ const fields = categories.map(category => ({
+ name: category,
+ value: commands
+ .filter(cmd => cmd.category === category)
+ .map(cmd => `\`${cmd.name}\``)
+ .join(', '),
+ inline: false,
+ }));
- const helpEmbed = embed
- .setColor(client.color.main)
- .setTitle(ctx.locale("cmd.help.title"))
- .setDescription(
- ctx.locale("cmd.help.content", {
- bot: client.user.username,
- prefix: guild.prefix,
- }),
- )
- .setFooter({
- text: ctx.locale("cmd.help.footer", { prefix: guild.prefix }),
- })
- .addFields(...fields);
+ const helpEmbed = embed
+ .setColor(client.color.main)
+ .setTitle(ctx.locale('cmd.help.title'))
+ .setDescription(
+ ctx.locale('cmd.help.content', {
+ bot: client.user?.username,
+ prefix: guild.prefix,
+ }),
+ )
+ .setFooter({
+ text: ctx.locale('cmd.help.footer', { prefix: guild.prefix }),
+ })
+ .addFields(...fields);
- return await ctx.sendMessage({ embeds: [helpEmbed] });
- }
+ return await ctx.sendMessage({ embeds: [helpEmbed] });
+ }
}
/**
diff --git a/src/commands/info/Invite.ts b/src/commands/info/Invite.ts
index 3e222457f..871e32e81 100644
--- a/src/commands/info/Invite.ts
+++ b/src/commands/info/Invite.ts
@@ -1,52 +1,55 @@
-import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js";
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from 'discord.js';
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Invite extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "invite",
- description: {
- content: "cmd.invite.description",
- examples: ["invite"],
- usage: "invite",
- },
- category: "info",
- aliases: ["iv"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: false,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'invite',
+ description: {
+ content: 'cmd.invite.description',
+ examples: ['invite'],
+ usage: 'invite',
+ },
+ category: 'info',
+ aliases: ['iv'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: false,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context): Promise {
- const embed = this.client.embed();
- const row = new ActionRowBuilder().addComponents(
- new ButtonBuilder()
- .setLabel(ctx.locale("buttons.invite"))
- .setStyle(ButtonStyle.Link)
- .setURL(
- `https://discord.com/api/oauth2/authorize?client_id=${client.config.clientId}&permissions=8&scope=bot%20applications.commands`,
- ),
- new ButtonBuilder().setLabel(ctx.locale("buttons.support")).setStyle(ButtonStyle.Link).setURL("https://discord.gg/STXurwnZD5"),
- );
- return await ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.main).setDescription(ctx.locale("cmd.invite.content"))],
- components: [row],
- });
- }
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const embed = this.client.embed();
+ const row = new ActionRowBuilder().addComponents(
+ new ButtonBuilder()
+ .setLabel(ctx.locale('buttons.invite'))
+ .setStyle(ButtonStyle.Link)
+ .setURL(
+ `https://discord.com/api/oauth2/authorize?client_id=${client.env.CLIENT_ID}&permissions=8&scope=bot%20applications.commands`,
+ ),
+ new ButtonBuilder()
+ .setLabel(ctx.locale('buttons.support'))
+ .setStyle(ButtonStyle.Link)
+ .setURL('https://discord.gg/STXurwnZD5'),
+ );
+ return await ctx.sendMessage({
+ embeds: [embed.setColor(this.client.color.main).setDescription(ctx.locale('cmd.invite.content'))],
+ components: [row],
+ });
+ }
}
/**
diff --git a/src/commands/info/LavaLink.ts b/src/commands/info/LavaLink.ts
index feccfe55c..9f0cb5cc8 100644
--- a/src/commands/info/LavaLink.ts
+++ b/src/commands/info/LavaLink.ts
@@ -1,88 +1,88 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class LavaLink extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "lavalink",
- description: {
- content: "cmd.lavalink.description",
- examples: ["lavalink"],
- usage: "lavalink",
- },
- category: "info",
- aliases: ["ll"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: false,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'lavalink',
+ description: {
+ content: 'cmd.lavalink.description',
+ examples: ['lavalink'],
+ usage: 'lavalink',
+ },
+ category: 'info',
+ aliases: ['ll'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: false,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context): Promise {
- const nodes = client.shoukaku.nodes;
- const nodesPerPage = 2;
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const nodes = client.manager.nodeManager.nodes;
+ const nodesPerPage = 2;
- const nodeArray = Array.from(nodes.values());
- const chunks = client.utils.chunk(nodeArray, nodesPerPage);
+ const nodeArray = Array.from(nodes.values());
+ const chunks = client.utils.chunk(nodeArray, nodesPerPage);
- if (chunks.length === 0) chunks.push(nodeArray);
+ if (chunks.length === 0) chunks.push(nodeArray);
- const pages = chunks.map((chunk, index) => {
- const embed = this.client
- .embed()
- .setTitle(ctx.locale("cmd.lavalink.title"))
- .setColor(this.client.color.main)
- .setThumbnail(this.client.user.avatarURL())
- .setTimestamp();
+ const pages = chunks.map((chunk, index) => {
+ const embed = this.client
+ .embed()
+ .setTitle(ctx.locale('cmd.lavalink.title'))
+ .setColor(this.client.color.main)
+ .setThumbnail(client.user?.avatarURL()!)
+ .setTimestamp();
- chunk.forEach((node) => {
- const statusEmoji = node.stats ? "🟢" : "🔴";
- const stats = node.stats || {
- players: 0,
- playingPlayers: 0,
- uptime: 0,
- cpu: { cores: 0, systemLoad: 0, lavalinkLoad: 0 },
- memory: { used: 0, reservable: 0 },
- };
+ chunk.forEach(node => {
+ const statusEmoji = node.stats ? '🟢' : '🔴';
+ const stats = node.stats || {
+ players: 0,
+ playingPlayers: 0,
+ uptime: 0,
+ cpu: { cores: 0, systemLoad: 0, lavalinkLoad: 0 },
+ memory: { used: 0, reservable: 0 },
+ };
- embed.addFields({
- name: `${node.name} (${statusEmoji})`,
- value: `\`\`\`yaml\n${ctx.locale("cmd.lavalink.content", {
- players: stats.players,
- playingPlayers: stats.playingPlayers,
- uptime: client.utils.formatTime(stats.uptime),
- cores: stats.cpu.cores,
- used: client.utils.formatBytes(stats.memory.used),
- reservable: client.utils.formatBytes(stats.memory.reservable),
- systemLoad: (stats.cpu.systemLoad * 100).toFixed(2),
- lavalinkLoad: (stats.cpu.lavalinkLoad * 100).toFixed(2),
- })}\n\`\`\``,
- });
- });
+ embed.addFields({
+ name: `${node.name} (${statusEmoji})`,
+ value: `\`\`\`yaml\n${ctx.locale('cmd.lavalink.content', {
+ players: stats.players,
+ playingPlayers: stats.playingPlayers,
+ uptime: client.utils.formatTime(stats.uptime),
+ cores: stats.cpu.cores,
+ used: client.utils.formatBytes(stats.memory.used),
+ reservable: client.utils.formatBytes(stats.memory.reservable),
+ systemLoad: (stats.cpu.systemLoad * 100).toFixed(2),
+ lavalinkLoad: (stats.cpu.lavalinkLoad * 100).toFixed(2),
+ })}\n\`\`\``,
+ });
+ });
- embed.setFooter({
- text: ctx.locale("cmd.lavalink.page_info", {
- index: index + 1,
- total: chunks.length,
- }),
- });
+ embed.setFooter({
+ text: ctx.locale('cmd.lavalink.page_info', {
+ index: index + 1,
+ total: chunks.length,
+ }),
+ });
- return embed;
- });
- return await client.utils.paginate(client, ctx, pages);
- }
+ return embed;
+ });
+ return await client.utils.paginate(client, ctx, pages);
+ }
}
/**
diff --git a/src/commands/info/Ping.ts b/src/commands/info/Ping.ts
index 298795cef..079101fd9 100644
--- a/src/commands/info/Ping.ts
+++ b/src/commands/info/Ping.ts
@@ -1,73 +1,73 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Ping extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "ping",
- description: {
- content: "cmd.ping.description",
- examples: ["ping"],
- usage: "ping",
- },
- category: "general",
- aliases: ["pong"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: false,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'ping',
+ description: {
+ content: 'cmd.ping.description',
+ examples: ['ping'],
+ usage: 'ping',
+ },
+ category: 'general',
+ aliases: ['pong'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: false,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [],
+ });
+ }
- public async run(_client: Lavamusic, ctx: Context): Promise {
- const msg = await ctx.sendDeferMessage(ctx.locale("cmd.ping.content"));
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const msg = await ctx.sendDeferMessage(ctx.locale('cmd.ping.content'));
- const botLatency = msg.createdTimestamp - ctx.createdTimestamp;
- const apiLatency = Math.round(ctx.client.ws.ping);
+ const botLatency = msg.createdTimestamp - ctx.createdTimestamp;
+ const apiLatency = Math.round(ctx.client.ws.ping);
- const botLatencySign = botLatency < 600 ? "+" : "-";
- const apiLatencySign = apiLatency < 500 ? "+" : "-";
+ const botLatencySign = botLatency < 600 ? '+' : '-';
+ const apiLatencySign = apiLatency < 500 ? '+' : '-';
- const embed = this.client
- .embed()
- .setAuthor({
- name: "Pong",
- iconURL: this.client.user.displayAvatarURL(),
- })
- .setColor(this.client.color.main)
- .addFields([
- {
- name: ctx.locale("cmd.ping.bot_latency"),
- value: `\`\`\`diff\n${botLatencySign} ${botLatency}ms\n\`\`\``,
- inline: true,
- },
- {
- name: ctx.locale("cmd.ping.api_latency"),
- value: `\`\`\`diff\n${apiLatencySign} ${apiLatency}ms\n\`\`\``,
- inline: true,
- },
- ])
- .setFooter({
- text: ctx.locale("cmd.ping.requested_by", {
- author: ctx.author.tag,
- }),
- iconURL: ctx.author.avatarURL({}),
- })
- .setTimestamp();
+ const embed = this.client
+ .embed()
+ .setAuthor({
+ name: 'Pong',
+ iconURL: client.user?.displayAvatarURL(),
+ })
+ .setColor(this.client.color.main)
+ .addFields([
+ {
+ name: ctx.locale('cmd.ping.bot_latency'),
+ value: `\`\`\`diff\n${botLatencySign} ${botLatency}ms\n\`\`\``,
+ inline: true,
+ },
+ {
+ name: ctx.locale('cmd.ping.api_latency'),
+ value: `\`\`\`diff\n${apiLatencySign} ${apiLatency}ms\n\`\`\``,
+ inline: true,
+ },
+ ])
+ .setFooter({
+ text: ctx.locale('cmd.ping.requested_by', {
+ author: ctx.author?.tag,
+ }),
+ iconURL: ctx.author?.displayAvatarURL({}),
+ })
+ .setTimestamp();
- return await ctx.editMessage({ content: "", embeds: [embed] });
- }
+ return await ctx.editMessage({ content: '', embeds: [embed] });
+ }
}
/**
diff --git a/src/commands/music/Autoplay.ts b/src/commands/music/Autoplay.ts
index d3266b486..3a457aa52 100644
--- a/src/commands/music/Autoplay.ts
+++ b/src/commands/music/Autoplay.ts
@@ -1,60 +1,61 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Autoplay extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "autoplay",
- description: {
- content: "cmd.autoplay.description",
- examples: ["autoplay"],
- usage: "autoplay",
- },
- category: "music",
- aliases: ["ap"],
- cooldown: 3,
- args: false,
- vote: true,
- player: {
- voice: true,
- dj: true,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'autoplay',
+ description: {
+ content: 'cmd.autoplay.description',
+ examples: ['autoplay'],
+ usage: 'autoplay',
+ },
+ category: 'music',
+ aliases: ['ap'],
+ cooldown: 3,
+ args: false,
+ vote: true,
+ player: {
+ voice: true,
+ dj: true,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', '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 await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("player.errors.no_player"),
- color: this.client.color.red,
- },
- ],
- });
- }
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ if (!player) {
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('player.errors.no_player'),
+ color: this.client.color.red,
+ },
+ ],
+ });
+ }
- const embed = this.client.embed();
- const autoplay = player.autoplay;
- player.setAutoplay(!autoplay);
+ const embed = this.client.embed();
+ const autoplay = player.get('autoplay');
- if (autoplay) {
- embed.setDescription(ctx.locale("cmd.autoplay.messages.disabled")).setColor(this.client.color.main);
- } else {
- embed.setDescription(ctx.locale("cmd.autoplay.messages.enabled")).setColor(this.client.color.main);
- }
+ player.set('autoplay', !autoplay);
- await ctx.sendMessage({ embeds: [embed] });
- }
+ if (autoplay) {
+ embed.setDescription(ctx.locale('cmd.autoplay.messages.disabled')).setColor(this.client.color.main);
+ } else {
+ embed.setDescription(ctx.locale('cmd.autoplay.messages.enabled')).setColor(this.client.color.main);
+ }
+
+ await ctx.sendMessage({ embeds: [embed] });
+ }
}
/**
diff --git a/src/commands/music/ClearQueue.ts b/src/commands/music/ClearQueue.ts
index 3087c0f82..05eb69d0e 100644
--- a/src/commands/music/ClearQueue.ts
+++ b/src/commands/music/ClearQueue.ts
@@ -1,56 +1,56 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class ClearQueue extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "clearqueue",
- description: {
- content: "cmd.clearqueue.description",
- examples: ["clearqueue"],
- usage: "clearqueue",
- },
- category: "music",
- aliases: ["cq"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: true,
- dj: true,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'clearqueue',
+ description: {
+ content: 'cmd.clearqueue.description',
+ examples: ['clearqueue'],
+ usage: 'clearqueue',
+ },
+ category: 'music',
+ aliases: ['cq'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: true,
+ dj: true,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', '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();
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const embed = this.client.embed();
- if (!player) {
- return await ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("player.errors.no_player"))],
- });
- }
+ if (!player) {
+ return await ctx.sendMessage({
+ embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale('player.errors.no_player'))],
+ });
+ }
- if (player.queue.length === 0) {
- return await ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("player.errors.no_song"))],
- });
- }
+ if (player.queue.tracks.length === 0) {
+ return await ctx.sendMessage({
+ embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale('player.errors.no_song'))],
+ });
+ }
- player.queue = [];
- return await ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.main).setDescription(ctx.locale("cmd.clearqueue.messages.cleared"))],
- });
- }
+ player.queue.tracks.splice(0, player.queue.tracks.length);
+ return await ctx.sendMessage({
+ embeds: [embed.setColor(this.client.color.main).setDescription(ctx.locale('cmd.clearqueue.messages.cleared'))],
+ });
+ }
}
/**
diff --git a/src/commands/music/Grab.ts b/src/commands/music/Grab.ts
index ee91ab13a..fc9768f6b 100644
--- a/src/commands/music/Grab.ts
+++ b/src/commands/music/Grab.ts
@@ -1,78 +1,81 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
+import type { Requester } from '../../types';
export default class Grab extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "grab",
- description: {
- content: "cmd.grab.description",
- examples: ["grab"],
- usage: "grab",
- },
- category: "music",
- aliases: ["gr"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: false,
- dj: false,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'grab',
+ description: {
+ content: 'cmd.grab.description',
+ examples: ['grab'],
+ usage: 'grab',
+ },
+ category: 'music',
+ aliases: ['gr'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: false,
+ dj: false,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context): Promise {
- const player = client.queue.get(ctx.guild!.id);
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
- await ctx.sendDeferMessage(ctx.locale("cmd.grab.loading"));
+ await ctx.sendDeferMessage(ctx.locale('cmd.grab.loading'));
- if (!player?.current) {
- return await ctx.sendMessage({
- embeds: [this.client.embed().setColor(this.client.color.red).setDescription(ctx.locale("player.errors.no_song"))],
- });
- }
+ if (!player?.queue.current) {
+ return await ctx.sendMessage({
+ embeds: [
+ this.client.embed().setColor(this.client.color.red).setDescription(ctx.locale('player.errors.no_song')),
+ ],
+ });
+ }
- const song = player.current;
+ const song = player.queue.current;
- const songInfo = ctx.locale("cmd.grab.content", {
- title: song.info.title,
- uri: song.info.uri,
- artworkUrl: song.info.artworkUrl,
- length: song.info.isStream ? "LIVE" : client.utils.formatTime(song.info.length),
- requester: song.info.requester,
- });
+ const songInfo = ctx.locale('cmd.grab.content', {
+ title: song.info.title,
+ uri: song.info.uri,
+ artworkUrl: song.info.artworkUrl,
+ length: song.info.isStream ? 'LIVE' : client.utils.formatTime(song.info.duration),
+ requester: (song.requester as Requester).id,
+ });
- try {
- await ctx.author?.send({
- embeds: [
- this.client
- .embed()
- .setTitle(`**${song.info.title}**`)
- .setURL(song.info.uri!)
- .setThumbnail(song.info.artworkUrl!)
- .setDescription(songInfo)
- .setColor(this.client.color.main),
- ],
- });
+ try {
+ await ctx.author?.send({
+ embeds: [
+ this.client
+ .embed()
+ .setTitle(`**${song.info.title}**`)
+ .setURL(song.info.uri!)
+ .setThumbnail(song.info.artworkUrl!)
+ .setDescription(songInfo)
+ .setColor(this.client.color.main),
+ ],
+ });
- return await ctx.editMessage({
- embeds: [this.client.embed().setDescription(ctx.locale("cmd.grab.check_dm")).setColor(this.client.color.green)],
- });
- } catch (_e) {
- return await ctx.editMessage({
- embeds: [this.client.embed().setDescription(ctx.locale("cmd.grab.dm_failed")).setColor(this.client.color.red)],
- });
- }
- }
+ return await ctx.editMessage({
+ embeds: [this.client.embed().setDescription(ctx.locale('cmd.grab.check_dm')).setColor(this.client.color.green)],
+ });
+ } catch (_e) {
+ return await ctx.editMessage({
+ embeds: [this.client.embed().setDescription(ctx.locale('cmd.grab.dm_failed')).setColor(this.client.color.red)],
+ });
+ }
+ }
}
/**
diff --git a/src/commands/music/Join.ts b/src/commands/music/Join.ts
index 7f2eab587..01428353e 100644
--- a/src/commands/music/Join.ts
+++ b/src/commands/music/Join.ts
@@ -1,77 +1,78 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import type { VoiceChannel } from 'discord.js';
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Join extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "join",
- description: {
- content: "cmd.join.description",
- examples: ["join"],
- usage: "join",
- },
- category: "music",
- aliases: ["come", "j"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: true,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks", "Connect", "Speak"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'join',
+ description: {
+ content: 'cmd.join.description',
+ examples: ['join'],
+ usage: 'join',
+ },
+ category: 'music',
+ aliases: ['come', 'j'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: true,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks', 'Connect', 'Speak'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context): Promise {
- const embed = this.client.embed();
- let player = client.queue.get(ctx.guild!.id);
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const embed = this.client.embed();
+ let player = client.manager.getPlayer(ctx.guild!.id);
- if (player) {
- const channelId = player.node.manager.connections.get(ctx.guild!.id)!.channelId;
- return await ctx.sendMessage({
- embeds: [
- embed.setColor(this.client.color.main).setDescription(
- ctx.locale("cmd.join.already_connected", {
- channelId,
- }),
- ),
- ],
- });
- }
+ if (player) {
+ return await ctx.sendMessage({
+ embeds: [
+ embed.setColor(this.client.color.main).setDescription(
+ ctx.locale('cmd.join.already_connected', {
+ channelId: player.voiceChannelId,
+ }),
+ ),
+ ],
+ });
+ }
- const memberVoiceChannel = (ctx.member as any).voice.channel;
- if (!memberVoiceChannel) {
- return await ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("cmd.join.no_voice_channel"))],
- });
- }
+ const memberVoiceChannel = (ctx.member as any).voice.channel as VoiceChannel;
+ if (!memberVoiceChannel) {
+ return await ctx.sendMessage({
+ embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale('cmd.join.no_voice_channel'))],
+ });
+ }
- player = await client.queue.create(
- ctx.guild!,
- memberVoiceChannel,
- ctx.channel,
- client.shoukaku.options.nodeResolver(client.shoukaku.nodes),
- );
-
- const joinedChannelId = player.node.manager.connections.get(ctx.guild!.id)!.channelId;
- return await ctx.sendMessage({
- embeds: [
- embed.setColor(this.client.color.main).setDescription(
- ctx.locale("cmd.join.joined", {
- channelId: joinedChannelId,
- }),
- ),
- ],
- });
- }
+ player = client.manager.createPlayer({
+ guildId: ctx.guild!.id,
+ voiceChannelId: memberVoiceChannel.id,
+ textChannelId: ctx.channel.id,
+ selfMute: false,
+ selfDeaf: true,
+ vcRegion: memberVoiceChannel.rtcRegion!,
+ });
+ if (!player.connected) await player.connect();
+ return await ctx.sendMessage({
+ embeds: [
+ embed.setColor(this.client.color.main).setDescription(
+ ctx.locale('cmd.join.joined', {
+ channelId: player.voiceChannelId,
+ }),
+ ),
+ ],
+ });
+ }
}
/**
diff --git a/src/commands/music/Leave.ts b/src/commands/music/Leave.ts
index 8673a86a8..1e17c5240 100644
--- a/src/commands/music/Leave.ts
+++ b/src/commands/music/Leave.ts
@@ -1,50 +1,50 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Leave extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "leave",
- description: {
- content: "cmd.leave.description",
- examples: ["leave"],
- usage: "leave",
- },
- category: "music",
- aliases: ["l"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: true,
- dj: true,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'leave',
+ description: {
+ content: 'cmd.leave.description',
+ examples: ['leave'],
+ usage: 'leave',
+ },
+ category: 'music',
+ aliases: ['l'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: true,
+ dj: true,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', '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();
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const embed = this.client.embed();
- if (player) {
- const channelId = player.node.manager.connections.get(ctx.guild!.id)!.channelId;
- player.destroy();
- return await ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.main).setDescription(ctx.locale("cmd.leave.left", { channelId }))],
- });
- }
- return await ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("cmd.leave.not_in_channel"))],
- });
- }
+ if (player) {
+ const channelId = player.voiceChannelId;
+ player.destroy();
+ return await ctx.sendMessage({
+ embeds: [embed.setColor(this.client.color.main).setDescription(ctx.locale('cmd.leave.left', { channelId }))],
+ });
+ }
+ return await ctx.sendMessage({
+ embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale('cmd.leave.not_in_channel'))],
+ });
+ }
}
/**
diff --git a/src/commands/music/Loop.ts b/src/commands/music/Loop.ts
index f4b090424..079c7fa29 100644
--- a/src/commands/music/Loop.ts
+++ b/src/commands/music/Loop.ts
@@ -1,59 +1,62 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Loop extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "loop",
- description: {
- content: "cmd.loop.description",
- examples: ["loop", "loop queue", "loop song"],
- usage: "loop",
- },
- category: "general",
- aliases: ["loop"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: true,
- dj: false,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'loop',
+ description: {
+ content: 'cmd.loop.description',
+ examples: ['loop', 'loop queue', 'loop song'],
+ usage: 'loop',
+ },
+ category: 'general',
+ aliases: ['loop'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: true,
+ dj: false,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context): Promise {
- const embed = this.client.embed().setColor(this.client.color.main);
- const player = client.queue.get(ctx.guild!.id);
- let loopMessage = "";
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const embed = this.client.embed().setColor(this.client.color.main);
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ let loopMessage = '';
- switch (player?.loop) {
- case "off":
- player.loop = "repeat";
- loopMessage = ctx.locale("cmd.loop.looping_song");
- break;
- case "repeat":
- player.loop = "queue";
- loopMessage = ctx.locale("cmd.loop.looping_queue");
- break;
- case "queue":
- player.loop = "off";
- loopMessage = ctx.locale("cmd.loop.looping_off");
- break;
- }
+ switch (player?.repeatMode) {
+ case 'off': {
+ player.setRepeatMode('track');
+ loopMessage = ctx.locale('cmd.loop.looping_song');
+ break;
+ }
+ case 'track': {
+ player.setRepeatMode('queue');
+ loopMessage = ctx.locale('cmd.loop.looping_queue');
+ break;
+ }
+ case 'queue': {
+ player.setRepeatMode('off');
+ loopMessage = ctx.locale('cmd.loop.looping_off');
+ break;
+ }
+ }
- return await ctx.sendMessage({
- embeds: [embed.setDescription(loopMessage)],
- });
- }
+ return await ctx.sendMessage({
+ embeds: [embed.setDescription(loopMessage)],
+ });
+ }
}
/**
diff --git a/src/commands/music/Lyrics.ts b/src/commands/music/Lyrics.ts
deleted file mode 100644
index c6d9dc4f2..000000000
--- a/src/commands/music/Lyrics.ts
+++ /dev/null
@@ -1,177 +0,0 @@
-import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ComponentType } from "discord.js";
-import { getLyrics } from "genius-lyrics-api";
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
-
-export default class Lyrics extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "lyrics",
- description: {
- content: "cmd.lyrics.description",
- examples: ["lyrics"],
- usage: "lyrics",
- },
- category: "music",
- aliases: ["ly"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: true,
- dj: false,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "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 currentTrack = player.current;
- const trackTitle = currentTrack.info.title.replace(/\[.*?\]/g, "").trim();
- const artistName = currentTrack.info.author.replace(/\[.*?\]/g, "").trim();
- const trackUrl = currentTrack.info.uri;
- const artworkUrl = currentTrack.info.artworkUrl;
-
- await ctx.sendDeferMessage(ctx.locale("cmd.lyrics.searching", { trackTitle }));
-
- const options = {
- apiKey: client.config.lyricsApi,
- title: trackTitle,
- artist: artistName,
- optimizeQuery: true,
- };
-
- try {
- const lyrics = await getLyrics(options);
- if (lyrics) {
- const lyricsPages = this.paginateLyrics(lyrics);
- let currentPage = 0;
-
- const row = new ActionRowBuilder().addComponents(
- new ButtonBuilder()
- .setCustomId("prev")
- .setEmoji(this.client.emoji.page.back)
- .setStyle(ButtonStyle.Secondary)
- .setDisabled(true),
- new ButtonBuilder().setCustomId("stop").setEmoji(this.client.emoji.page.cancel).setStyle(ButtonStyle.Danger),
- new ButtonBuilder()
- .setCustomId("next")
- .setEmoji(this.client.emoji.page.next)
- .setStyle(ButtonStyle.Secondary)
- .setDisabled(lyricsPages.length <= 1),
- );
-
- await ctx.editMessage({
- embeds: [
- embed
- .setColor(client.color.main)
- .setDescription(
- ctx.locale("cmd.lyrics.lyrics_track", { trackTitle, trackUrl, lyrics: lyricsPages[currentPage] }),
- )
- .setThumbnail(artworkUrl)
- .setTimestamp(),
- ],
- components: [row],
- });
-
- const filter = (interaction) => interaction.user.id === ctx.author.id;
- const collector = ctx.channel.createMessageComponentCollector({
- filter,
- componentType: ComponentType.Button,
- time: 60000,
- });
-
- collector.on("collect", async (interaction) => {
- if (interaction.customId === "prev") {
- currentPage--;
- } else if (interaction.customId === "next") {
- currentPage++;
- } else if (interaction.customId === "stop") {
- collector.stop();
- return interaction.update({ components: [] });
- }
-
- await interaction.update({
- embeds: [
- embed
- .setDescription(
- ctx.locale("cmd.lyrics.lyrics_track", { trackTitle, trackUrl, lyrics: lyricsPages[currentPage] }),
- )
- .setThumbnail(artworkUrl)
- .setTimestamp(),
- ],
- components: [
- new ActionRowBuilder().addComponents(
- new ButtonBuilder()
- .setCustomId("prev")
- .setEmoji(this.client.emoji.page.back)
- .setStyle(ButtonStyle.Secondary)
- .setDisabled(currentPage === 0),
- new ButtonBuilder()
- .setCustomId("stop")
- .setEmoji(this.client.emoji.page.cancel)
- .setStyle(ButtonStyle.Danger),
- new ButtonBuilder()
- .setCustomId("next")
- .setEmoji(this.client.emoji.page.next)
- .setStyle(ButtonStyle.Secondary)
- .setDisabled(currentPage === lyricsPages.length - 1),
- ),
- ],
- });
- });
-
- collector.on("end", () => {
- ctx.editMessage({ components: [] });
- });
- } else {
- await ctx.editMessage({
- embeds: [embed.setColor(client.color.red).setDescription(ctx.locale("cmd.lyrics.errors.no_results"))],
- });
- }
- } catch (error) {
- console.error(error);
- await ctx.editMessage({
- embeds: [embed.setColor(client.color.red).setDescription(ctx.locale("cmd.lyrics.errors.lyrics_error"))],
- });
- }
- }
-
- paginateLyrics(lyrics) {
- const lines = lyrics.split("\n");
- const pages = [];
- let page = "";
-
- for (const line of lines) {
- if (page.length + line.length > 2048) {
- pages.push(page);
- page = "";
- }
- page += `${line}\n`;
- }
-
- if (page) pages.push(page);
- return pages;
- }
-}
-
-/**
- * Project: lavamusic
- * Author: Appu
- * Main Contributor: LucasB25
- * Company: Coders
- * Copyright (c) 2024. All rights reserved.
- * 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
- */
diff --git a/src/commands/music/Lyrics.ts.txt b/src/commands/music/Lyrics.ts.txt
new file mode 100644
index 000000000..4273611ae
--- /dev/null
+++ b/src/commands/music/Lyrics.ts.txt
@@ -0,0 +1,187 @@
+/* import {
+ ActionRowBuilder,
+ ButtonBuilder,
+ type ButtonInteraction,
+ ButtonStyle,
+ ComponentType,
+ type TextChannel,
+} from 'discord.js';
+import { getLyrics } from 'genius-lyrics-api';
+import { Command, type Context, type Lavamusic } from '../../structures/index';
+
+export default class Lyrics extends Command {
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'lyrics',
+ description: {
+ content: 'cmd.lyrics.description',
+ examples: ['lyrics'],
+ usage: 'lyrics',
+ },
+ category: 'music',
+ aliases: ['ly'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: true,
+ dj: false,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [],
+ });
+ }
+
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const embed = this.client.embed();
+
+ const currentTrack = player.queue.current!;
+ const trackTitle = currentTrack.info.title.replace(/\[.*?\]/g, '').trim();
+ const artistName = currentTrack.info.author.replace(/\[.*?\]/g, '').trim();
+ const trackUrl = currentTrack.info.uri;
+ const artworkUrl = currentTrack.info.artworkUrl;
+
+ await ctx.sendDeferMessage(ctx.locale('cmd.lyrics.searching', { trackTitle }));
+
+ const options = {
+ apiKey: client.env.GENIUS_API,
+ title: trackTitle,
+ artist: artistName,
+ optimizeQuery: true,
+ };
+
+ try {
+ const lyrics = await getLyrics(options);
+ if (lyrics) {
+ const lyricsPages = this.paginateLyrics(lyrics);
+ let currentPage = 0;
+
+ const row = new ActionRowBuilder().addComponents(
+ new ButtonBuilder()
+ .setCustomId('prev')
+ .setEmoji(this.client.emoji.page.back)
+ .setStyle(ButtonStyle.Secondary)
+ .setDisabled(true),
+ new ButtonBuilder().setCustomId('stop').setEmoji(this.client.emoji.page.cancel).setStyle(ButtonStyle.Danger),
+ new ButtonBuilder()
+ .setCustomId('next')
+ .setEmoji(this.client.emoji.page.next)
+ .setStyle(ButtonStyle.Secondary)
+ .setDisabled(lyricsPages.length <= 1),
+ );
+
+ await ctx.editMessage({
+ embeds: [
+ embed
+ .setColor(client.color.main)
+ .setDescription(
+ ctx.locale('cmd.lyrics.lyrics_track', { trackTitle, trackUrl, lyrics: lyricsPages[currentPage] }),
+ )
+ .setThumbnail(artworkUrl)
+ .setTimestamp(),
+ ],
+ components: [row],
+ });
+
+ const filter = (interaction: ButtonInteraction<'cached'>) => interaction.user.id === ctx.author?.id;
+ const collector = (ctx.channel as TextChannel).createMessageComponentCollector({
+ filter,
+ componentType: ComponentType.Button,
+ time: 60000,
+ });
+
+ collector.on('collect', async (interaction: ButtonInteraction) => {
+ if (interaction.customId === 'prev') {
+ currentPage--;
+ } else if (interaction.customId === 'next') {
+ currentPage++;
+ } else if (interaction.customId === 'stop') {
+ collector.stop();
+ return interaction.update({ components: [] });
+ }
+
+ await interaction.update({
+ embeds: [
+ embed
+ .setDescription(
+ ctx.locale('cmd.lyrics.lyrics_track', { trackTitle, trackUrl, lyrics: lyricsPages[currentPage] }),
+ )
+ .setThumbnail(artworkUrl)
+ .setTimestamp(),
+ ],
+ components: [
+ new ActionRowBuilder().addComponents(
+ new ButtonBuilder()
+ .setCustomId('prev')
+ .setEmoji(this.client.emoji.page.back)
+ .setStyle(ButtonStyle.Secondary)
+ .setDisabled(currentPage === 0),
+ new ButtonBuilder()
+ .setCustomId('stop')
+ .setEmoji(this.client.emoji.page.cancel)
+ .setStyle(ButtonStyle.Danger),
+ new ButtonBuilder()
+ .setCustomId('next')
+ .setEmoji(this.client.emoji.page.next)
+ .setStyle(ButtonStyle.Secondary)
+ .setDisabled(currentPage === lyricsPages.length - 1),
+ ),
+ ],
+ });
+ return;
+ });
+
+ collector.on('end', () => {
+ ctx.editMessage({ components: [] });
+ });
+ } else {
+ await ctx.editMessage({
+ embeds: [embed.setColor(client.color.red).setDescription(ctx.locale('cmd.lyrics.errors.no_results'))],
+ });
+ }
+ } catch (error) {
+ // biome-ignore lint/suspicious/noConsole:
+ console.error(error);
+ await ctx.editMessage({
+ embeds: [embed.setColor(client.color.red).setDescription(ctx.locale('cmd.lyrics.errors.lyrics_error'))],
+ });
+ }
+ }
+
+ paginateLyrics(lyrics: string) {
+ const lines = lyrics.split('\n');
+ const pages: any = [];
+ let page = '';
+
+ for (const line of lines) {
+ if (page.length + line.length > 2048) {
+ pages.push(page);
+ page = '';
+ }
+ page += `${line}\n`;
+ }
+
+ if (page) pages.push(page);
+ return pages;
+ }
+}
+*/
+
+/**
+ * Project: lavamusic
+ * Author: Appu
+ * Main Contributor: LucasB25
+ * Company: Coders
+ * Copyright (c) 2024. All rights reserved.
+ * 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/music/Nowplaying.ts b/src/commands/music/Nowplaying.ts
index 55766cceb..ac9d7a014 100644
--- a/src/commands/music/Nowplaying.ts
+++ b/src/commands/music/Nowplaying.ts
@@ -1,65 +1,65 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Nowplaying extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "nowplaying",
- description: {
- content: "cmd.nowplaying.description",
- examples: ["nowplaying"],
- usage: "nowplaying",
- },
- category: "music",
- aliases: ["np"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: true,
- dj: false,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'nowplaying',
+ description: {
+ content: 'cmd.nowplaying.description',
+ examples: ['nowplaying'],
+ usage: 'nowplaying',
+ },
+ category: 'music',
+ aliases: ['np'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: true,
+ dj: false,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', '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);
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const track = player.queue.current!;
+ const position = player.position;
+ const duration = track.info.duration;
+ const bar = client.utils.progressBar(position, duration, 20);
- const embed = this.client
- .embed()
- .setColor(this.client.color.main)
- .setAuthor({
- name: ctx.locale("cmd.nowplaying.now_playing"),
- iconURL: ctx.guild?.iconURL({})!,
- })
- .setThumbnail(track.info.artworkUrl!)
- .setDescription(
- ctx.locale("cmd.nowplaying.track_info", {
- title: track.info.title,
- uri: track.info.uri,
- requester: track.info.requester,
- bar: bar,
- }),
- )
- .addFields({
- name: "\u200b",
- value: `\`${client.utils.formatTime(position)} / ${client.utils.formatTime(duration)}\``,
- });
+ const embed = this.client
+ .embed()
+ .setColor(this.client.color.main)
+ .setAuthor({
+ name: ctx.locale('cmd.nowplaying.now_playing'),
+ iconURL: ctx.guild?.iconURL({})!,
+ })
+ .setThumbnail(track.info.artworkUrl!)
+ .setDescription(
+ ctx.locale('cmd.nowplaying.track_info', {
+ title: track.info.title,
+ uri: track.info.uri,
+ requester: (track.requester as any).id,
+ bar: bar,
+ }),
+ )
+ .addFields({
+ name: '\u200b',
+ value: `\`${client.utils.formatTime(position)} / ${client.utils.formatTime(duration)}\``,
+ });
- return await ctx.sendMessage({ embeds: [embed] });
- }
+ return await ctx.sendMessage({ embeds: [embed] });
+ }
}
/**
diff --git a/src/commands/music/Pause.ts b/src/commands/music/Pause.ts
index 48923906b..0a78a879f 100644
--- a/src/commands/music/Pause.ts
+++ b/src/commands/music/Pause.ts
@@ -1,51 +1,51 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Pause extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "pause",
- description: {
- content: "cmd.pause.description",
- examples: ["pause"],
- usage: "pause",
- },
- category: "music",
- aliases: ["pu"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: true,
- dj: false,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'pause',
+ description: {
+ content: 'cmd.pause.description',
+ examples: ['pause'],
+ usage: 'pause',
+ },
+ category: 'music',
+ aliases: ['pu'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: true,
+ dj: false,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', '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();
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const embed = this.client.embed();
- if (player?.paused) {
- return await ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("player.errors.already_paused"))],
- });
- }
+ if (player?.paused) {
+ return await ctx.sendMessage({
+ embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale('player.errors.already_paused'))],
+ });
+ }
- player?.pause();
+ player?.pause();
- return await ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.main).setDescription(ctx.locale("cmd.pause.successfully_paused"))],
- });
- }
+ return await ctx.sendMessage({
+ embeds: [embed.setColor(this.client.color.main).setDescription(ctx.locale('cmd.pause.successfully_paused'))],
+ });
+ }
}
/**
diff --git a/src/commands/music/Play.ts b/src/commands/music/Play.ts
index 9ca06e567..b05483263 100644
--- a/src/commands/music/Play.ts
+++ b/src/commands/music/Play.ts
@@ -1,189 +1,129 @@
-import type { AutocompleteInteraction } from "discord.js";
-import { LoadType } from "shoukaku";
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import type { ApplicationCommandOptionChoiceData, AutocompleteInteraction, VoiceChannel } from 'discord.js';
+import type { SearchResult } from 'lavalink-client';
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Play extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "play",
- description: {
- content: "cmd.play.description",
- examples: [
- "play example",
- "play https://www.youtube.com/watch?v=example",
- "play https://open.spotify.com/track/example",
- "play http://www.example.com/example.mp3",
- ],
- usage: "play ",
- },
- category: "music",
- aliases: ["p"],
- cooldown: 3,
- args: true,
- vote: false,
- player: {
- voice: true,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks", "Connect", "Speak"],
- user: [],
- },
- slashCommand: true,
- options: [
- {
- name: "song",
- description: "cmd.play.options.song",
- type: 3,
- required: true,
- autocomplete: true,
- },
- ],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'play',
+ description: {
+ content: 'cmd.play.description',
+ examples: [
+ 'play example',
+ 'play https://www.youtube.com/watch?v=example',
+ 'play https://open.spotify.com/track/example',
+ 'play http://www.example.com/example.mp3',
+ ],
+ usage: 'play ',
+ },
+ category: 'music',
+ aliases: ['p'],
+ cooldown: 3,
+ args: true,
+ vote: false,
+ player: {
+ voice: true,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks', 'Connect', 'Speak'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [
+ {
+ name: 'song',
+ description: 'cmd.play.options.song',
+ type: 3,
+ required: true,
+ autocomplete: true,
+ },
+ ],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
- const query = args.join(" ");
- await ctx.sendDeferMessage(ctx.locale("cmd.play.loading"));
- 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);
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ const query = args.join(' ');
+ await ctx.sendDeferMessage(ctx.locale('cmd.play.loading'));
+ let player = client.manager.getPlayer(ctx.guild!.id);
+ const memberVoiceChannel = (ctx.member as any).voice.channel as VoiceChannel;
- const res = await this.client.queue.search(query);
- const embed = this.client.embed();
+ if (!player)
+ player = client.manager.createPlayer({
+ guildId: ctx.guild!.id,
+ voiceChannelId: memberVoiceChannel.id,
+ textChannelId: ctx.channel.id,
+ selfMute: false,
+ selfDeaf: true,
+ vcRegion: memberVoiceChannel.rtcRegion!,
+ });
+ if (!player.connected) await player.connect();
- switch (res.loadType) {
- case LoadType.ERROR:
- await ctx.editMessage({
- content: "",
- embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("cmd.play.errors.search_error"))],
- });
- break;
- case LoadType.EMPTY:
- await ctx.editMessage({
- content: "",
- embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("cmd.play.errors.no_results"))],
- });
- break;
- case LoadType.TRACK: {
- const track = player.buildTrack(res.data, ctx.author);
- if (player.queue.length > client.config.maxQueueSize)
- return await ctx.editMessage({
- content: "",
- embeds: [
- embed
- .setColor(this.client.color.red)
- .setDescription(ctx.locale("cmd.play.errors.queue_too_long", { maxQueueSize: client.config.maxQueueSize })),
- ],
- });
- player.queue.push(track);
- await player.isPlaying();
- await ctx.editMessage({
- content: "",
- embeds: [
- embed
- .setColor(this.client.color.main)
- .setDescription(ctx.locale("cmd.play.added_to_queue", { title: res.data.info.title, uri: res.data.info.uri })),
- ],
- });
- break;
- }
- case LoadType.PLAYLIST: {
- if (res.data.tracks.length > client.config.maxPlaylistSize)
- return await ctx.editMessage({
- content: "",
- embeds: [
- embed
- .setColor(this.client.color.red)
- .setDescription(
- ctx.locale("cmd.play.errors.playlist_too_long", { maxPlaylistSize: client.config.maxPlaylistSize }),
- ),
- ],
- });
- for (const track of res.data.tracks) {
- const pl = player.buildTrack(track, ctx.author);
- if (player.queue.length > client.config.maxQueueSize)
- return await ctx.editMessage({
- content: "",
- embeds: [
- embed
- .setColor(this.client.color.red)
- .setDescription(
- ctx.locale("cmd.play.errors.queue_too_long", { maxQueueSize: client.config.maxQueueSize }),
- ),
- ],
- });
- player.queue.push(pl);
- }
- await player.isPlaying();
- await ctx.editMessage({
- content: "",
- embeds: [
- embed
- .setColor(this.client.color.main)
- .setDescription(ctx.locale("cmd.play.added_playlist_to_queue", { length: res.data.tracks.length })),
- ],
- });
- break;
- }
- case LoadType.SEARCH: {
- const track1 = player.buildTrack(res.data[0], ctx.author);
- if (player.queue.length > client.config.maxQueueSize)
- return await ctx.editMessage({
- content: "",
- embeds: [
- embed
- .setColor(this.client.color.red)
- .setDescription(ctx.locale("cmd.play.errors.queue_too_long", { maxQueueSize: client.config.maxQueueSize })),
- ],
- });
- player.queue.push(track1);
- await player.isPlaying();
- await ctx.editMessage({
- content: "",
- embeds: [
- embed
- .setColor(this.client.color.main)
- .setDescription(
- ctx.locale("cmd.play.added_to_queue", { title: res.data[0].info.title, uri: res.data[0].info.uri }),
- ),
- ],
- });
- break;
- }
- }
- }
- public async autocomplete(interaction: AutocompleteInteraction): Promise {
- const focusedValue = interaction.options.getFocused();
+ const response = (await player.search({ query: query }, ctx.author)) as SearchResult;
+ const embed = this.client.embed();
- const res = await this.client.queue.search(focusedValue);
- const songs = [];
+ if (!response || response.tracks?.length === 0) {
+ return await ctx.editMessage({
+ content: '',
+ embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale('cmd.play.errors.search_error'))],
+ });
+ }
- if (res?.loadType) {
- if (res.loadType === LoadType.SEARCH && res.data.length > 0) {
- res.data.slice(0, 10).forEach((track) => {
- const name = `${track.info.title} by ${track.info.author}`;
- songs.push({
- name: name.length > 100 ? `${name.substring(0, 97)}...` : name,
- value: track.info.uri,
- });
- });
- } else if (res.loadType === LoadType.PLAYLIST && res.data.tracks.length > 0) {
- res.data.tracks.slice(0, 10).forEach((track) => {
- const name = `${track.info.title} by ${track.info.author}`;
- songs.push({
- name: name.length > 100 ? `${name.substring(0, 97)}...` : name,
- value: track.info.uri,
- });
- });
- }
- }
+ await player.queue.add(response.loadType === 'playlist' ? response.tracks : response.tracks[0]);
- return await interaction.respond(songs).catch(console.error);
- }
+ if (response.loadType === 'playlist') {
+ await ctx.editMessage({
+ content: '',
+ embeds: [
+ embed
+ .setColor(this.client.color.main)
+ .setDescription(ctx.locale('cmd.play.added_playlist_to_queue', { length: response.tracks.length })),
+ ],
+ });
+ } else {
+ await ctx.editMessage({
+ content: '',
+ embeds: [
+ embed.setColor(this.client.color.main).setDescription(
+ ctx.locale('cmd.play.added_to_queue', {
+ title: response.tracks[0].info.title,
+ uri: response.tracks[0].info.uri,
+ }),
+ ),
+ ],
+ });
+ }
+ if (!player.playing) await player.play({ paused: false });
+ }
+ public async autocomplete(interaction: AutocompleteInteraction): Promise {
+ const focusedValue = interaction.options.getFocused();
+
+ if (!focusedValue) {
+ return interaction.respond([]).catch(() => {
+ null;
+ });
+ }
+
+ const res = await this.client.manager.search(focusedValue, interaction.user);
+ const songs: ApplicationCommandOptionChoiceData[] = [];
+
+ if (res.loadType === 'search') {
+ res.tracks.slice(0, 10).forEach(track => {
+ const name = `${track.info.title} by ${track.info.author}`;
+ songs.push({
+ name: name.length > 100 ? `${name.substring(0, 97)}...` : name,
+ value: track.info.uri,
+ });
+ });
+ }
+
+ return await interaction.respond(songs).catch(() => {
+ null;
+ });
+ }
}
/**
diff --git a/src/commands/music/PlayNext.ts b/src/commands/music/PlayNext.ts
index 6ef71ee4c..a0b167532 100644
--- a/src/commands/music/PlayNext.ts
+++ b/src/commands/music/PlayNext.ts
@@ -1,187 +1,125 @@
-import type { AutocompleteInteraction } from "discord.js";
-import { LoadType } from "shoukaku";
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import type { ApplicationCommandOptionChoiceData, AutocompleteInteraction, VoiceChannel } from 'discord.js';
+import type { SearchResult } from 'lavalink-client';
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class PlayNext extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "playnext",
- description: {
- content: "cmd.playnext.description",
- examples: [
- "playnext example",
- "playnext https://www.youtube.com/watch?v=example",
- "playnext https://open.spotify.com/track/example",
- "playnext http://www.example.com/example.mp3",
- ],
- usage: "playnext ",
- },
- category: "music",
- aliases: ["pn"],
- cooldown: 3,
- args: true,
- vote: false,
- player: {
- voice: true,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks", "Connect", "Speak"],
- user: [],
- },
- slashCommand: true,
- options: [
- {
- name: "song",
- description: "cmd.playnext.options.song",
- type: 3,
- required: true,
- autocomplete: true,
- },
- ],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'playnext',
+ description: {
+ content: 'cmd.playnext.description',
+ examples: [
+ 'playnext example',
+ 'playnext https://www.youtube.com/watch?v=example',
+ 'playnext https://open.spotify.com/track/example',
+ 'playnext http://www.example.com/example.mp3',
+ ],
+ usage: 'playnext ',
+ },
+ category: 'music',
+ aliases: ['pn'],
+ cooldown: 3,
+ args: true,
+ vote: false,
+ player: {
+ voice: true,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks', 'Connect', 'Speak'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [
+ {
+ name: 'song',
+ description: 'cmd.playnext.options.song',
+ 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);
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ const query = args.join(' ');
+ let player = client.manager.getPlayer(ctx.guild!.id);
+ const memberVoiceChannel = (ctx.member as any).voice.channel as VoiceChannel;
- await ctx.sendDeferMessage(ctx.locale("cmd.playnext.loading"));
- const res = await this.client.queue.search(query);
- const embed = this.client.embed();
- switch (res.loadType) {
- case LoadType.ERROR:
- await ctx.editMessage({
- content: "",
- embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("cmd.playnext.errors.search_error"))],
- });
- break;
- case LoadType.EMPTY:
- await ctx.editMessage({
- content: "",
- embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("cmd.playnext.errors.no_results"))],
- });
- break;
- case LoadType.TRACK: {
- const track = player.buildTrack(res.data, ctx.author);
- if (player.queue.length > client.config.maxQueueSize)
- return await ctx.editMessage({
- content: "",
- embeds: [
- embed
- .setColor(this.client.color.red)
- .setDescription(
- ctx.locale("cmd.playnext.errors.queue_too_long", { maxQueueSize: client.config.maxQueueSize }),
- ),
- ],
- });
- player.queue.splice(0, 0, track);
- await player.isPlaying();
- await ctx.editMessage({
- content: "",
- embeds: [
- embed
- .setColor(this.client.color.main)
- .setDescription(
- ctx.locale("cmd.playnext.added_to_play_next", { title: res.data.info.title, uri: res.data.info.uri }),
- ),
- ],
- });
- break;
- }
- case LoadType.PLAYLIST: {
- if (res.data.tracks.length > client.config.maxPlaylistSize)
- return await ctx.editMessage({
- content: "",
- embeds: [
- embed
- .setColor(this.client.color.red)
- .setDescription(
- ctx.locale("cmd.playnext.errors.playlist_too_long", { maxPlaylistSize: client.config.maxPlaylistSize }),
- ),
- ],
- });
- for (const track of res.data.tracks) {
- const pl = player.buildTrack(track, ctx.author);
- if (player.queue.length > client.config.maxQueueSize)
- return await ctx.editMessage({
- content: "",
- embeds: [
- embed
- .setColor(this.client.color.red)
- .setDescription(
- ctx.locale("cmd.playnext.errors.queue_too_long", { maxQueueSize: client.config.maxQueueSize }),
- ),
- ],
- });
- player.queue.splice(0, 0, pl);
- }
- await player.isPlaying();
- await ctx.editMessage({
- content: "",
- embeds: [
- embed
- .setColor(this.client.color.main)
- .setDescription(ctx.locale("cmd.playnext.added_playlist_to_play_next", { length: res.data.tracks.length })),
- ],
- });
- break;
- }
- case LoadType.SEARCH: {
- const track1 = player.buildTrack(res.data[0], ctx.author);
- if (player.queue.length > client.config.maxQueueSize)
- return await ctx.editMessage({
- content: "",
- embeds: [
- embed
- .setColor(this.client.color.red)
- .setDescription(
- ctx.locale("cmd.playnext.errors.queue_too_long", { maxQueueSize: client.config.maxQueueSize }),
- ),
- ],
- });
- player.queue.splice(0, 0, track1);
- await player.isPlaying();
- await ctx.editMessage({
- content: "",
- embeds: [
- embed
- .setColor(this.client.color.main)
- .setDescription(
- ctx.locale("cmd.playnext.added_to_play_next", { title: res.data[0].info.title, uri: res.data[0].info.uri }),
- ),
- ],
- });
- break;
- }
- }
- }
- public async autocomplete(interaction: AutocompleteInteraction): Promise {
- const focusedValue = interaction.options.getFocused();
+ if (!player)
+ player = client.manager.createPlayer({
+ guildId: ctx.guild!.id,
+ voiceChannelId: memberVoiceChannel.id,
+ textChannelId: ctx.channel.id,
+ selfMute: false,
+ selfDeaf: true,
+ vcRegion: memberVoiceChannel.rtcRegion!,
+ });
+ if (!player.connected) await player.connect();
- const res = await this.client.queue.search(focusedValue);
- const songs = [];
+ await ctx.sendDeferMessage(ctx.locale('cmd.playnext.loading'));
- if (res.loadType === LoadType.SEARCH && res.data.length > 0) {
- res.data.slice(0, 10).forEach((x) => {
- let name = `${x.info.title} by ${x.info.author}`;
- if (name.length > 100) {
- name = `${name.substring(0, 97)}...`;
- }
- songs.push({
- name: name,
- value: x.info.uri,
- });
- });
- }
+ const response = (await player.search({ query: query }, ctx.author)) as SearchResult;
+ const embed = this.client.embed();
- return await interaction.respond(songs).catch(console.error);
- }
+ if (!response || response.tracks?.length === 0) {
+ return await ctx.editMessage({
+ content: '',
+ embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale('cmd.play.errors.search_error'))],
+ });
+ }
+ await player.queue.splice(0, 0, response.loadType === 'playlist' ? response.tracks : response.tracks[0]);
+
+ if (response.loadType === 'playlist') {
+ await ctx.editMessage({
+ content: '',
+ embeds: [
+ embed
+ .setColor(this.client.color.main)
+ .setDescription(ctx.locale('cmd.playnext.added_playlist_to_play_next', { length: response.tracks.length })),
+ ],
+ });
+ } else {
+ await ctx.editMessage({
+ content: '',
+ embeds: [
+ embed.setColor(this.client.color.main).setDescription(
+ ctx.locale('cmd.playnext.added_to_play_next', {
+ title: response.tracks[0].info.title,
+ uri: response.tracks[0].info.uri,
+ }),
+ ),
+ ],
+ });
+ }
+ if (!player.playing) await player.play({ paused: false });
+ }
+ public async autocomplete(interaction: AutocompleteInteraction): Promise {
+ const focusedValue = interaction.options.getFocused();
+
+ if (!focusedValue) {
+ return;
+ }
+
+ const res = await this.client.manager.search(focusedValue, interaction.user);
+ const songs: ApplicationCommandOptionChoiceData[] = [];
+
+ if (res.loadType === 'search') {
+ res.tracks.slice(0, 10).forEach(track => {
+ const name = `${track.info.title} by ${track.info.author}`;
+ songs.push({
+ name: name.length > 100 ? `${name.substring(0, 97)}...` : name,
+ value: track.info.uri,
+ });
+ });
+ }
+
+ return await interaction.respond(songs).catch(console.error);
+ }
}
/**
diff --git a/src/commands/music/Queue.ts b/src/commands/music/Queue.ts
index a6707fcc7..947e75349 100644
--- a/src/commands/music/Queue.ts
+++ b/src/commands/music/Queue.ts
@@ -1,89 +1,89 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Queue extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "queue",
- description: {
- content: "cmd.queue.description",
- examples: ["queue"],
- usage: "queue",
- },
- category: "music",
- aliases: ["q"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: true,
- dj: false,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'queue',
+ description: {
+ content: 'cmd.queue.description',
+ examples: ['queue'],
+ usage: 'queue',
+ },
+ category: 'music',
+ aliases: ['q'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: true,
+ dj: false,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', '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 === 0) {
- return await ctx.sendMessage({
- embeds: [
- embed.setColor(this.client.color.main).setDescription(
- ctx.locale("cmd.queue.now_playing", {
- title: player.current.info.title,
- uri: player.current.info.uri,
- requester: player.current?.info.requester,
- duration: player.current.info.isStream
- ? ctx.locale("cmd.queue.live")
- : client.utils.formatTime(player.current.info.length),
- }),
- ),
- ],
- });
- }
- const songStrings = [];
- for (let i = 0; i < player.queue.length; i++) {
- const track = player.queue[i];
- songStrings.push(
- ctx.locale("cmd.queue.track_info", {
- index: i + 1,
- title: track.info.title,
- uri: track.info.uri,
- requester: track?.info.requester,
- duration: track.info.isStream ? ctx.locale("cmd.queue.live") : client.utils.formatTime(track.info.length),
- }),
- );
- }
- let chunks = client.utils.chunk(songStrings, 10);
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const embed = this.client.embed();
+ if (player.queue.current && player.queue.tracks.length === 0) {
+ return await ctx.sendMessage({
+ embeds: [
+ embed.setColor(this.client.color.main).setDescription(
+ ctx.locale('cmd.queue.now_playing', {
+ title: player.queue.current.info.title,
+ uri: player.queue.current.info.uri,
+ requester: (player.queue.current.requester as any).id,
+ duration: player.queue.current.info.isStream
+ ? ctx.locale('cmd.queue.live')
+ : client.utils.formatTime(player.queue.current.info.duration),
+ }),
+ ),
+ ],
+ });
+ }
+ const songStrings: string[] = [];
+ for (let i = 0; i < player.queue.tracks.length; i++) {
+ const track = player.queue.tracks[i];
+ songStrings.push(
+ ctx.locale('cmd.queue.track_info', {
+ index: i + 1,
+ title: track.info.title,
+ uri: track.info.uri,
+ requester: (track.requester as any).id,
+ duration: track.info.isStream ? ctx.locale('cmd.queue.live') : client.utils.formatTime(track.info.duration!),
+ }),
+ );
+ }
+ let chunks = client.utils.chunk(songStrings, 10);
- if (chunks.length === 0) chunks = [songStrings];
+ if (chunks.length === 0) chunks = [songStrings];
- const pages = chunks.map((chunk, index) => {
- return this.client
- .embed()
- .setColor(this.client.color.main)
- .setAuthor({
- name: ctx.locale("cmd.queue.title"),
- iconURL: ctx.guild.iconURL({}),
- })
- .setDescription(chunk.join("\n"))
- .setFooter({
- text: ctx.locale("cmd.queue.page_info", {
- index: index + 1,
- total: chunks.length,
- }),
- });
- });
- return await client.utils.paginate(client, ctx, pages);
- }
+ const pages = chunks.map((chunk, index) => {
+ return this.client
+ .embed()
+ .setColor(this.client.color.main)
+ .setAuthor({
+ name: ctx.locale('cmd.queue.title'),
+ iconURL: ctx.guild.icon ? ctx.guild.iconURL()! : ctx.author?.displayAvatarURL(),
+ })
+ .setDescription(chunk.join('\n'))
+ .setFooter({
+ text: ctx.locale('cmd.queue.page_info', {
+ index: index + 1,
+ total: chunks.length,
+ }),
+ });
+ });
+ return await client.utils.paginate(client, ctx, pages);
+ }
}
/**
diff --git a/src/commands/music/Remove.ts b/src/commands/music/Remove.ts
index 83445236a..92d7264a8 100644
--- a/src/commands/music/Remove.ts
+++ b/src/commands/music/Remove.ts
@@ -1,68 +1,68 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Remove extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "remove",
- description: {
- content: "cmd.remove.description",
- examples: ["remove 1"],
- usage: "remove ",
- },
- category: "music",
- aliases: ["rm"],
- cooldown: 3,
- args: true,
- vote: false,
- player: {
- voice: true,
- dj: true,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [
- {
- name: "song",
- description: "cmd.remove.options.song",
- type: 4,
- required: true,
- },
- ],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'remove',
+ description: {
+ content: 'cmd.remove.description',
+ examples: ['remove 1'],
+ usage: 'remove ',
+ },
+ category: 'music',
+ aliases: ['rm'],
+ cooldown: 3,
+ args: true,
+ vote: false,
+ player: {
+ voice: true,
+ dj: true,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [
+ {
+ name: 'song',
+ description: 'cmd.remove.options.song',
+ 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();
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const embed = this.client.embed();
- if (player.queue.length === 0)
- return await ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("cmd.remove.errors.no_songs"))],
- });
+ if (player.queue.tracks.length === 0)
+ return await ctx.sendMessage({
+ embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale('cmd.remove.errors.no_songs'))],
+ });
- const songNumber = Number(args[0]);
- if (isNaN(songNumber) || songNumber <= 0 || songNumber > player.queue.length)
- return await ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("cmd.remove.errors.invalid_number"))],
- });
+ const songNumber = Number(args[0]);
+ if (Number.isNaN(songNumber) || songNumber <= 0 || songNumber > player.queue.tracks.length)
+ return await ctx.sendMessage({
+ embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale('cmd.remove.errors.invalid_number'))],
+ });
- player.remove(songNumber - 1);
- return await ctx.sendMessage({
- embeds: [
- embed.setColor(this.client.color.main).setDescription(
- ctx.locale("cmd.remove.messages.removed", {
- songNumber,
- }),
- ),
- ],
- });
- }
+ player.queue.remove(songNumber - 1);
+ return await ctx.sendMessage({
+ embeds: [
+ embed.setColor(this.client.color.main).setDescription(
+ ctx.locale('cmd.remove.messages.removed', {
+ songNumber,
+ }),
+ ),
+ ],
+ });
+ }
}
/**
diff --git a/src/commands/music/Replay.ts b/src/commands/music/Replay.ts
index d1a32907d..5b63284b4 100644
--- a/src/commands/music/Replay.ts
+++ b/src/commands/music/Replay.ts
@@ -1,50 +1,50 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Replay extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "replay",
- description: {
- content: "cmd.replay.description",
- examples: ["replay"],
- usage: "replay",
- },
- category: "music",
- aliases: ["rp"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: true,
- dj: false,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'replay',
+ description: {
+ content: 'cmd.replay.description',
+ examples: ['replay'],
+ usage: 'replay',
+ },
+ category: 'music',
+ aliases: ['rp'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: true,
+ dj: false,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', '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();
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const embed = this.client.embed();
- if (!player.current?.info.isSeekable) {
- return await ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("cmd.replay.errors.not_seekable"))],
- });
- }
+ if (!player.queue.current?.info.isSeekable) {
+ return await ctx.sendMessage({
+ embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale('cmd.replay.errors.not_seekable'))],
+ });
+ }
- player.seek(0);
- return await ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.main).setDescription(ctx.locale("cmd.replay.messages.replaying"))],
- });
- }
+ player.seek(0);
+ return await ctx.sendMessage({
+ embeds: [embed.setColor(this.client.color.main).setDescription(ctx.locale('cmd.replay.messages.replaying'))],
+ });
+ }
}
/**
diff --git a/src/commands/music/Resume.ts b/src/commands/music/Resume.ts
index d55eddfa5..020d6ea7a 100644
--- a/src/commands/music/Resume.ts
+++ b/src/commands/music/Resume.ts
@@ -1,50 +1,50 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Resume extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "resume",
- description: {
- content: "cmd.resume.description",
- examples: ["resume"],
- usage: "resume",
- },
- category: "music",
- aliases: ["r"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: true,
- dj: false,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'resume',
+ description: {
+ content: 'cmd.resume.description',
+ examples: ['resume'],
+ usage: 'resume',
+ },
+ category: 'music',
+ aliases: ['r'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: true,
+ dj: false,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', '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();
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const embed = this.client.embed();
- if (!player.paused) {
- return await ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("cmd.resume.errors.not_paused"))],
- });
- }
+ if (!player.paused) {
+ return await ctx.sendMessage({
+ embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale('cmd.resume.errors.not_paused'))],
+ });
+ }
- player.pause();
- return await ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.main).setDescription(ctx.locale("cmd.resume.messages.resumed"))],
- });
- }
+ player.resume();
+ return await ctx.sendMessage({
+ embeds: [embed.setColor(this.client.color.main).setDescription(ctx.locale('cmd.resume.messages.resumed'))],
+ });
+ }
}
/**
diff --git a/src/commands/music/Search.ts b/src/commands/music/Search.ts
index a26412b72..3735bbde7 100644
--- a/src/commands/music/Search.ts
+++ b/src/commands/music/Search.ts
@@ -1,124 +1,112 @@
-import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js";
-import { LoadType } from "shoukaku";
-import type { Song } from "../../structures/Dispatcher.js";
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { ActionRowBuilder, ButtonBuilder, ButtonStyle, type TextChannel, type VoiceChannel } from 'discord.js';
+import type { SearchResult, Track } from 'lavalink-client';
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Search extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "search",
- description: {
- content: "cmd.search.description",
- examples: ["search example"],
- usage: "search ",
- },
- category: "music",
- aliases: ["sc"],
- cooldown: 3,
- args: true,
- vote: true,
- player: {
- voice: true,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [
- {
- name: "song",
- description: "cmd.search.options.song",
- type: 3,
- required: true,
- },
- ],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'search',
+ description: {
+ content: 'cmd.search.description',
+ examples: ['search example'],
+ usage: 'search ',
+ },
+ category: 'music',
+ aliases: ['sc'],
+ cooldown: 3,
+ args: true,
+ vote: true,
+ player: {
+ voice: true,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [
+ {
+ name: 'song',
+ description: 'cmd.search.options.song',
+ type: 3,
+ required: true,
+ },
+ ],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
- const embed = this.client.embed().setColor(this.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.options.nodeResolver(client.shoukaku.nodes),
- );
- }
- const res = await this.client.queue.search(query);
- if (!res) {
- return await ctx.sendMessage({
- embeds: [embed.setDescription(ctx.locale("cmd.search.errors.no_results")).setColor(this.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 LoadType.ERROR:
- ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("cmd.search.errors.search_error"))],
- });
- break;
- case LoadType.EMPTY:
- ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("cmd.search.errors.no_results"))],
- });
- break;
- case LoadType.SEARCH: {
- const tracks = res.data.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,
- max: 1,
- time: 60000,
- idle: 60000 / 2,
- });
- collector.on("collect", async (int: any) => {
- const track = res.data[parseInt(int.customId) - 1];
- await int.deferUpdate();
- if (!track) return;
- const song = player.buildTrack(track, ctx.author);
- player.queue.push(song);
- player.isPlaying();
- await ctx.editMessage({
- embeds: [
- embed.setDescription(
- ctx.locale("cmd.search.messages.added_to_queue", {
- title: song.info.title,
- uri: song.info.uri,
- }),
- ),
- ],
- components: [],
- });
- return collector.stop();
- });
- collector.on("end", async () => {
- await ctx.editMessage({ components: [] });
- });
- }
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ const embed = this.client.embed().setColor(this.client.color.main);
+ let player = client.manager.getPlayer(ctx.guild!.id);
+ const query = args.join(' ');
+ const memberVoiceChannel = (ctx.member as any).voice.channel as VoiceChannel;
+
+ if (!player)
+ player = client.manager.createPlayer({
+ guildId: ctx.guild!.id,
+ voiceChannelId: memberVoiceChannel.id,
+ textChannelId: ctx.channel.id,
+ selfMute: false,
+ selfDeaf: true,
+ vcRegion: memberVoiceChannel.rtcRegion!,
+ });
+ if (!player.connected) await player.connect();
+ const response = (await player.search({ query: query }, ctx.author)) as SearchResult;
+ if (!response || response.tracks?.length === 0) {
+ return await ctx.sendMessage({
+ embeds: [embed.setDescription(ctx.locale('cmd.search.errors.no_results')).setColor(this.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),
+ );
+ if (response.loadType === 'search' && response.tracks.length > 5) {
+ const embeds = response.tracks.map(
+ (track: Track, index: number) =>
+ `${index + 1}. [${track.info.title}](${track.info.uri}) - \`${track.info.author}\``,
+ );
+ await ctx.sendMessage({
+ embeds: [embed.setDescription(embeds.join('\n'))],
+ components: [row],
+ });
+ }
+ const collector = (ctx.channel as TextChannel).createMessageComponentCollector({
+ filter: (f: any) => f.user.id === ctx.author?.id,
+ max: 1,
+ time: 60000,
+ idle: 60000 / 2,
+ });
+ collector.on('collect', async (int: any) => {
+ const track = response.tracks[Number.parseInt(int.customId) - 1];
+ await int.deferUpdate();
+ if (!track) return;
+ player.queue.add(track);
+ if (!player.playing) await player.play({ paused: false });
+ await ctx.editMessage({
+ embeds: [
+ embed.setDescription(
+ ctx.locale('cmd.search.messages.added_to_queue', {
+ title: track.info.title,
+ uri: track.info.uri,
+ }),
+ ),
+ ],
+ components: [],
+ });
+ return collector.stop();
+ });
+ collector.on('end', async () => {
+ await ctx.editMessage({ components: [] });
+ });
+ }
}
/**
diff --git a/src/commands/music/Seek.ts b/src/commands/music/Seek.ts
index f17c21489..8b62f79a3 100644
--- a/src/commands/music/Seek.ts
+++ b/src/commands/music/Seek.ts
@@ -1,79 +1,79 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Seek extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "seek",
- description: {
- content: "cmd.seek.description",
- examples: ["seek 1m, seek 1h 30m", "seek 1h 30m 30s"],
- usage: "seek ",
- },
- category: "music",
- aliases: ["s"],
- cooldown: 3,
- args: true,
- vote: false,
- player: {
- voice: true,
- dj: false,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [
- {
- name: "duration",
- description: "cmd.seek.options.duration",
- type: 3,
- required: true,
- },
- ],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'seek',
+ description: {
+ content: 'cmd.seek.description',
+ examples: ['seek 1m, seek 1h 30m', 'seek 1h 30m 30s'],
+ usage: 'seek ',
+ },
+ category: 'music',
+ aliases: ['s'],
+ cooldown: 3,
+ args: true,
+ vote: false,
+ player: {
+ voice: true,
+ dj: false,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [
+ {
+ name: 'duration',
+ description: 'cmd.seek.options.duration',
+ type: 3,
+ required: true,
+ },
+ ],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
- const player = client.queue.get(ctx.guild!.id);
- const current = player.current.info;
- const embed = this.client.embed();
- const duration = client.utils.parseTime(args.join(" "));
- if (!duration) {
- return await ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("cmd.seek.errors.invalid_format"))],
- });
- }
- if (!current.isSeekable) {
- return await ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("cmd.seek.errors.not_seekable"))],
- });
- }
- if (duration > current.length) {
- return await ctx.sendMessage({
- embeds: [
- embed.setColor(this.client.color.red).setDescription(
- ctx.locale("cmd.seek.errors.beyond_duration", {
- length: client.utils.formatTime(current.length),
- }),
- ),
- ],
- });
- }
- player.seek(duration);
- return await ctx.sendMessage({
- embeds: [
- embed.setColor(this.client.color.main).setDescription(
- ctx.locale("cmd.seek.messages.seeked_to", {
- duration: client.utils.formatTime(duration),
- }),
- ),
- ],
- });
- }
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const current = player.queue.current?.info;
+ const embed = this.client.embed();
+ const duration = client.utils.parseTime(args.join(' '));
+ if (!duration) {
+ return await ctx.sendMessage({
+ embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale('cmd.seek.errors.invalid_format'))],
+ });
+ }
+ if (!current?.isSeekable) {
+ return await ctx.sendMessage({
+ embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale('cmd.seek.errors.not_seekable'))],
+ });
+ }
+ if (duration > current.duration) {
+ return await ctx.sendMessage({
+ embeds: [
+ embed.setColor(this.client.color.red).setDescription(
+ ctx.locale('cmd.seek.errors.beyond_duration', {
+ length: client.utils.formatTime(current.duration),
+ }),
+ ),
+ ],
+ });
+ }
+ player.seek(duration);
+ return await ctx.sendMessage({
+ embeds: [
+ embed.setColor(this.client.color.main).setDescription(
+ ctx.locale('cmd.seek.messages.seeked_to', {
+ duration: client.utils.formatTime(duration),
+ }),
+ ),
+ ],
+ });
+ }
}
/**
diff --git a/src/commands/music/Shuffle.ts b/src/commands/music/Shuffle.ts
index 0fb4d908b..4a3eeaaf4 100644
--- a/src/commands/music/Shuffle.ts
+++ b/src/commands/music/Shuffle.ts
@@ -1,48 +1,48 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Shuffle extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "shuffle",
- description: {
- content: "cmd.shuffle.description",
- examples: ["shuffle"],
- usage: "shuffle",
- },
- category: "music",
- aliases: ["sh"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: true,
- dj: true,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'shuffle',
+ description: {
+ content: 'cmd.shuffle.description',
+ examples: ['shuffle'],
+ usage: 'shuffle',
+ },
+ category: 'music',
+ aliases: ['sh'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: true,
+ dj: true,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', '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 === 0) {
- return await ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("player.errors.no_song"))],
- });
- }
- player.setShuffle();
- return await ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.main).setDescription(ctx.locale("cmd.shuffle.messages.shuffled"))],
- });
- }
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const embed = this.client.embed();
+ if (player.queue.tracks.length === 0) {
+ return await ctx.sendMessage({
+ embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale('player.errors.no_song'))],
+ });
+ }
+ player.queue.shuffle();
+ return await ctx.sendMessage({
+ embeds: [embed.setColor(this.client.color.main).setDescription(ctx.locale('cmd.shuffle.messages.shuffled'))],
+ });
+ }
}
/**
diff --git a/src/commands/music/Skip.ts b/src/commands/music/Skip.ts
index 057b415a5..e31aa161e 100644
--- a/src/commands/music/Skip.ts
+++ b/src/commands/music/Skip.ts
@@ -1,59 +1,59 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Skip extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "skip",
- description: {
- content: "cmd.skip.description",
- examples: ["skip"],
- usage: "skip",
- },
- category: "music",
- aliases: ["sk"],
- cooldown: 3,
- args: false,
- vote: true,
- player: {
- voice: true,
- dj: true,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'skip',
+ description: {
+ content: 'cmd.skip.description',
+ examples: ['skip'],
+ usage: 'skip',
+ },
+ category: 'music',
+ aliases: ['sk'],
+ cooldown: 3,
+ args: false,
+ vote: true,
+ player: {
+ voice: true,
+ dj: true,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', '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 === 0) {
- return await ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("player.errors.no_song"))],
- });
- }
- const currentTrack = player.current.info;
- player.skip();
- if (ctx.isInteraction) {
- return await ctx.sendMessage({
- embeds: [
- embed.setColor(this.client.color.main).setDescription(
- ctx.locale("cmd.skip.messages.skipped", {
- title: currentTrack.title,
- uri: currentTrack.uri,
- }),
- ),
- ],
- });
- }
- ctx.message?.react("👍");
- }
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const embed = this.client.embed();
+ if (player.queue.tracks.length === 0) {
+ return await ctx.sendMessage({
+ embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale('player.errors.no_song'))],
+ });
+ }
+ const currentTrack = player.queue.current?.info;
+ player.skip();
+ if (ctx.isInteraction) {
+ return await ctx.sendMessage({
+ embeds: [
+ embed.setColor(this.client.color.main).setDescription(
+ ctx.locale('cmd.skip.messages.skipped', {
+ title: currentTrack?.title,
+ uri: currentTrack?.uri,
+ }),
+ ),
+ ],
+ });
+ }
+ ctx.message?.react('👍');
+ }
}
/**
diff --git a/src/commands/music/Skipto.ts b/src/commands/music/Skipto.ts
index e0bad9876..5820d1c10 100644
--- a/src/commands/music/Skipto.ts
+++ b/src/commands/music/Skipto.ts
@@ -1,64 +1,64 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Skipto extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "skipto",
- description: {
- content: "cmd.skipto.description",
- examples: ["skipto 3"],
- usage: "skipto ",
- },
- category: "music",
- aliases: ["skt"],
- cooldown: 3,
- args: true,
- vote: true,
- player: {
- voice: true,
- dj: true,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [
- {
- name: "number",
- description: "cmd.skipto.options.number",
- type: 4,
- required: true,
- },
- ],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'skipto',
+ description: {
+ content: 'cmd.skipto.description',
+ examples: ['skipto 3'],
+ usage: 'skipto ',
+ },
+ category: 'music',
+ aliases: ['skt'],
+ cooldown: 3,
+ args: true,
+ vote: true,
+ player: {
+ voice: true,
+ dj: true,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [
+ {
+ name: 'number',
+ description: 'cmd.skipto.options.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();
- const num = Number(args[0]);
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const embed = this.client.embed();
+ const num = Number(args[0]);
- if (player.queue.length === 0 || isNaN(num) || num > player.queue.length || num < 1) {
- return await ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("cmd.skipto.errors.invalid_number"))],
- });
- }
+ if (player.queue.tracks.length === 0 || Number.isNaN(num) || num > player.queue.tracks.length || num < 1) {
+ return await ctx.sendMessage({
+ embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale('cmd.skipto.errors.invalid_number'))],
+ });
+ }
- player.skip(num);
- return await ctx.sendMessage({
- embeds: [
- embed.setColor(this.client.color.main).setDescription(
- ctx.locale("cmd.skipto.messages.skipped_to", {
- number: num,
- }),
- ),
- ],
- });
- }
+ player.skip(num);
+ return await ctx.sendMessage({
+ embeds: [
+ embed.setColor(this.client.color.main).setDescription(
+ ctx.locale('cmd.skipto.messages.skipped_to', {
+ number: num,
+ }),
+ ),
+ ],
+ });
+ }
}
/**
diff --git a/src/commands/music/Stop.ts b/src/commands/music/Stop.ts
index e8f97a802..12054564c 100644
--- a/src/commands/music/Stop.ts
+++ b/src/commands/music/Stop.ts
@@ -1,46 +1,45 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Stop extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "stop",
- description: {
- content: "cmd.stop.description",
- examples: ["stop"],
- usage: "stop",
- },
- category: "music",
- aliases: ["sp"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: true,
- dj: true,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'stop',
+ description: {
+ content: 'cmd.stop.description',
+ examples: ['stop'],
+ usage: 'stop',
+ },
+ category: 'music',
+ aliases: ['sp'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: true,
+ dj: true,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', '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();
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const embed = this.client.embed();
- player.queue = [];
- player.stop();
+ player.stopPlaying(true, false);
- return await ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.main).setDescription(ctx.locale("cmd.stop.messages.stopped"))],
- });
- }
+ return await ctx.sendMessage({
+ embeds: [embed.setColor(this.client.color.main).setDescription(ctx.locale('cmd.stop.messages.stopped'))],
+ });
+ }
}
/**
diff --git a/src/commands/music/Volume.ts b/src/commands/music/Volume.ts
index 36ef52acb..91dcc0f7f 100644
--- a/src/commands/music/Volume.ts
+++ b/src/commands/music/Volume.ts
@@ -1,71 +1,71 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class Volume extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "volume",
- description: {
- content: "cmd.volume.description",
- examples: ["volume 100"],
- usage: "volume ",
- },
- category: "music",
- aliases: ["v", "vol"],
- cooldown: 3,
- args: true,
- vote: true,
- player: {
- voice: true,
- dj: true,
- active: true,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [
- {
- name: "number",
- description: "cmd.volume.options.number",
- type: 4,
- required: true,
- },
- ],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'volume',
+ description: {
+ content: 'cmd.volume.description',
+ examples: ['volume 100'],
+ usage: 'volume ',
+ },
+ category: 'music',
+ aliases: ['v', 'vol'],
+ cooldown: 3,
+ args: true,
+ vote: true,
+ player: {
+ voice: true,
+ dj: true,
+ active: true,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [
+ {
+ name: 'number',
+ description: 'cmd.volume.options.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();
- const number = Number(args[0]);
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ const player = client.manager.getPlayer(ctx.guild!.id);
+ const embed = this.client.embed();
+ const number = Number(args[0]);
- if (isNaN(number) || number < 0 || number > 200) {
- let description = "";
- if (isNaN(number)) description = ctx.locale("cmd.volume.messages.invalid_number");
- else if (number < 0) description = ctx.locale("cmd.volume.messages.too_low");
- else if (number > 200) description = ctx.locale("cmd.volume.messages.too_high");
+ if (Number.isNaN(number) || number < 0 || number > 200) {
+ let description = '';
+ if (Number.isNaN(number)) description = ctx.locale('cmd.volume.messages.invalid_number');
+ else if (number < 0) description = ctx.locale('cmd.volume.messages.too_low');
+ else if (number > 200) description = ctx.locale('cmd.volume.messages.too_high');
- return await ctx.sendMessage({
- embeds: [embed.setColor(this.client.color.red).setDescription(description)],
- });
- }
+ return await ctx.sendMessage({
+ embeds: [embed.setColor(this.client.color.red).setDescription(description)],
+ });
+ }
- await player.player.setGlobalVolume(number);
- const currentVolume = player.player.volume;
+ await player.setVolume(number);
+ const currentVolume = player.volume;
- return await ctx.sendMessage({
- embeds: [
- embed.setColor(this.client.color.main).setDescription(
- ctx.locale("cmd.volume.messages.set", {
- volume: currentVolume,
- }),
- ),
- ],
- });
- }
+ return await ctx.sendMessage({
+ embeds: [
+ embed.setColor(this.client.color.main).setDescription(
+ ctx.locale('cmd.volume.messages.set', {
+ volume: currentVolume,
+ }),
+ ),
+ ],
+ });
+ }
}
/**
diff --git a/src/commands/playlist/AddSong.ts b/src/commands/playlist/AddSong.ts
index c4ef21ff3..491bf0367 100644
--- a/src/commands/playlist/AddSong.ts
+++ b/src/commands/playlist/AddSong.ts
@@ -1,146 +1,139 @@
-import type { AutocompleteInteraction } from "discord.js";
-import { LoadType } from "shoukaku";
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import type { AutocompleteInteraction } from 'discord.js';
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class AddSong extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "addsong",
- description: {
- content: "cmd.addsong.description",
- examples: ["addsong test exemple", "addsong exemple https://www.youtube.com/watch?v=example"],
- usage: "addsong ",
- },
- category: "playlist",
- aliases: ["as"],
- cooldown: 3,
- args: true,
- vote: true,
- player: {
- voice: false,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [
- {
- name: "playlist",
- description: "cmd.addsong.options.playlist",
- type: 3,
- required: true,
- autocomplete: true,
- },
- {
- name: "song",
- description: "cmd.addsong.options.song",
- type: 3,
- required: true,
- },
- ],
- });
- }
-
- public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
- const playlist = args.shift();
- const song = args.join(" ");
-
- if (!playlist) {
- return await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.addsong.messages.no_playlist"),
- color: this.client.color.red,
- },
- ],
- });
- }
-
- if (!song) {
- return await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.addsong.messages.no_song"),
- color: this.client.color.red,
- },
- ],
- });
- }
- const res = await client.queue.search(song);
-
- if (!res || res.loadType === LoadType.EMPTY) {
- return await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.addsong.messages.no_songs_found"),
- color: this.client.color.red,
- },
- ],
- });
- }
-
- const playlistData = await client.db.getPlaylist(ctx.author.id, playlist);
-
- if (!playlistData) {
- return await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.addsong.messages.playlist_not_found"),
- color: this.client.color.red,
- },
- ],
- });
- }
-
- let trackStrings: any;
- let count: number;
-
- if (res.loadType === LoadType.PLAYLIST) {
- trackStrings = res.data.tracks;
- count = res.data.tracks.length;
- } else if (res.loadType === LoadType.TRACK) {
- trackStrings = [res.data];
- count = 1;
- } else if (res.loadType === LoadType.SEARCH) {
- trackStrings = [res.data[0]];
- count = 1;
- }
-
- await client.db.addSong(ctx.author.id, playlist, trackStrings);
-
- await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.addsong.messages.added", {
- count,
- playlist: playlistData.name,
- }),
- color: this.client.color.main,
- },
- ],
- });
- }
-
- public async autocomplete(interaction: AutocompleteInteraction): Promise {
- const focusedValue = interaction.options.getFocused();
- const userId = interaction.user.id;
-
- const playlists = await this.client.db.getUserPlaylists(userId);
-
- const filtered = playlists.filter((playlist) => playlist.name.toLowerCase().startsWith(focusedValue.toLowerCase()));
-
- return await interaction.respond(
- filtered.map((playlist) => ({
- name: playlist.name,
- value: playlist.name,
- })),
- );
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'addsong',
+ description: {
+ content: 'cmd.addsong.description',
+ examples: ['addsong test exemple', 'addsong exemple https://www.youtube.com/watch?v=example'],
+ usage: 'addsong ',
+ },
+ category: 'playlist',
+ aliases: ['as'],
+ cooldown: 3,
+ args: true,
+ vote: true,
+ player: {
+ voice: false,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [
+ {
+ name: 'playlist',
+ description: 'cmd.addsong.options.playlist',
+ type: 3,
+ required: true,
+ autocomplete: true,
+ },
+ {
+ name: 'song',
+ description: 'cmd.addsong.options.song',
+ type: 3,
+ required: true,
+ },
+ ],
+ });
+ }
+
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ const playlist = args.shift();
+ const song = args.join(' ');
+
+ if (!playlist) {
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.addsong.messages.no_playlist'),
+ color: this.client.color.red,
+ },
+ ],
+ });
+ }
+
+ if (!song) {
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.addsong.messages.no_song'),
+ color: this.client.color.red,
+ },
+ ],
+ });
+ }
+ const res = await client.manager.search(song, ctx.author);
+ if (!res) {
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.addsong.messages.no_songs_found'),
+ color: this.client.color.red,
+ },
+ ],
+ });
+ }
+
+ const playlistData = await client.db.getPlaylist(ctx.author?.id!, playlist);
+ if (!playlistData) {
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.addsong.messages.playlist_not_found'),
+ color: this.client.color.red,
+ },
+ ],
+ });
+ }
+
+ let trackStrings: any;
+ let count = 0;
+ if (res.loadType === 'playlist') {
+ trackStrings = res.tracks.map(track => track.encoded);
+ count = res.tracks.length;
+ } else if (res.loadType === 'track') {
+ trackStrings = [res.tracks[0].encoded];
+ count = 1;
+ } else if (res.loadType === 'search') {
+ trackStrings = [res.tracks[0].encoded];
+ count = 1;
+ }
+
+ await client.db.addTracksToPlaylist(ctx.author?.id!, playlist, trackStrings);
+
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.addsong.messages.added', { playlist: playlistData.name, count }),
+ color: this.client.color.green,
+ },
+ ],
+ });
+ }
+
+ public async autocomplete(interaction: AutocompleteInteraction): Promise {
+ const focusedValue = interaction.options.getFocused();
+ const userId = interaction.user.id;
+
+ const playlists = await this.client.db.getUserPlaylists(userId);
+
+ const filtered = playlists.filter(playlist => playlist.name.toLowerCase().startsWith(focusedValue.toLowerCase()));
+
+ return await interaction.respond(
+ filtered.map(playlist => ({
+ name: playlist.name,
+ value: playlist.name,
+ })),
+ );
+ }
}
/**
diff --git a/src/commands/playlist/Create.ts b/src/commands/playlist/Create.ts
index c6b80a7ea..2aa9d947b 100644
--- a/src/commands/playlist/Create.ts
+++ b/src/commands/playlist/Create.ts
@@ -1,72 +1,74 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class CreatePlaylist extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "create",
- description: {
- content: "cmd.create.description",
- examples: ["create "],
- usage: "create ",
- },
- category: "playlist",
- aliases: ["cre"],
- cooldown: 3,
- args: true,
- vote: true,
- player: {
- voice: false,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [
- {
- name: "name",
- description: "cmd.create.options.name",
- type: 3,
- required: true,
- },
- ],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'create',
+ description: {
+ content: 'cmd.create.description',
+ examples: ['create '],
+ usage: 'create ',
+ },
+ category: 'playlist',
+ aliases: ['cre'],
+ cooldown: 3,
+ args: true,
+ vote: true,
+ player: {
+ voice: false,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [
+ {
+ name: 'name',
+ description: 'cmd.create.options.name',
+ type: 3,
+ required: true,
+ },
+ ],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
- const name = args.join(" ").trim();
- const embed = this.client.embed();
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ const name = args.join(' ').trim();
+ const embed = this.client.embed();
- if (name.length > 50) {
- return await ctx.sendMessage({
- embeds: [embed.setDescription(ctx.locale("cmd.create.messages.name_too_long")).setColor(this.client.color.red)],
- });
- }
+ if (name.length > 50) {
+ return await ctx.sendMessage({
+ embeds: [embed.setDescription(ctx.locale('cmd.create.messages.name_too_long')).setColor(this.client.color.red)],
+ });
+ }
- const playlistExists = await client.db.getPlaylist(ctx.author.id, name);
- if (playlistExists) {
- return await ctx.sendMessage({
- embeds: [embed.setDescription(ctx.locale("cmd.create.messages.playlist_exists")).setColor(this.client.color.red)],
- });
- }
+ const playlistExists = await client.db.getPlaylist(ctx.author?.id!, name);
+ if (playlistExists) {
+ return await ctx.sendMessage({
+ embeds: [
+ embed.setDescription(ctx.locale('cmd.create.messages.playlist_exists')).setColor(this.client.color.red),
+ ],
+ });
+ }
- await client.db.createPlaylist(ctx.author.id, name);
- return await ctx.sendMessage({
- embeds: [
- embed
- .setDescription(
- ctx.locale("cmd.create.messages.playlist_created", {
- name,
- }),
- )
- .setColor(this.client.color.green),
- ],
- });
- }
+ await client.db.createPlaylist(ctx.author?.id!, name);
+ return await ctx.sendMessage({
+ embeds: [
+ embed
+ .setDescription(
+ ctx.locale('cmd.create.messages.playlist_created', {
+ name,
+ }),
+ )
+ .setColor(this.client.color.green),
+ ],
+ });
+ }
}
/**
diff --git a/src/commands/playlist/Delete.ts b/src/commands/playlist/Delete.ts
index 663bd4518..4a0846e9b 100644
--- a/src/commands/playlist/Delete.ts
+++ b/src/commands/playlist/Delete.ts
@@ -1,87 +1,89 @@
-import type { AutocompleteInteraction } from "discord.js";
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import type { AutocompleteInteraction } from 'discord.js';
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class DeletePlaylist extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "delete",
- description: {
- content: "cmd.delete.description",
- examples: ["delete "],
- usage: "delete ",
- },
- category: "playlist",
- aliases: ["del"],
- cooldown: 3,
- args: true,
- vote: true,
- player: {
- voice: false,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [
- {
- name: "playlist",
- description: "cmd.delete.options.playlist",
- type: 3,
- required: true,
- autocomplete: true,
- },
- ],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'delete',
+ description: {
+ content: 'cmd.delete.description',
+ examples: ['delete '],
+ usage: 'delete ',
+ },
+ category: 'playlist',
+ aliases: ['del'],
+ cooldown: 3,
+ args: true,
+ vote: true,
+ player: {
+ voice: false,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [
+ {
+ name: 'playlist',
+ description: 'cmd.delete.options.playlist',
+ type: 3,
+ required: true,
+ autocomplete: true,
+ },
+ ],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
- const playlistName = args.join(" ").trim();
- const embed = this.client.embed();
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ const playlistName = args.join(' ').trim();
+ const embed = this.client.embed();
- const playlistExists = await client.db.getPlaylist(ctx.author.id, playlistName);
- if (!playlistExists) {
- return await ctx.sendMessage({
- embeds: [embed.setDescription(ctx.locale("cmd.delete.messages.playlist_not_found")).setColor(this.client.color.red)],
- });
- }
+ const playlistExists = await client.db.getPlaylist(ctx.author?.id!, playlistName);
+ if (!playlistExists) {
+ return await ctx.sendMessage({
+ embeds: [
+ embed.setDescription(ctx.locale('cmd.delete.messages.playlist_not_found')).setColor(this.client.color.red),
+ ],
+ });
+ }
- // First, delete all songs from the playlist
- await client.db.deleteSongsFromPlaylist(ctx.author.id, playlistName);
+ // First, delete all songs from the playlist
+ await client.db.deleteSongsFromPlaylist(ctx.author?.id!, playlistName);
- await client.db.deletePlaylist(ctx.author.id, playlistName);
- return await ctx.sendMessage({
- embeds: [
- embed
- .setDescription(
- ctx.locale("cmd.delete.messages.playlist_deleted", {
- playlistName,
- }),
- )
- .setColor(this.client.color.green),
- ],
- });
- }
+ await client.db.deletePlaylist(ctx.author?.id!, playlistName);
+ return await ctx.sendMessage({
+ embeds: [
+ embed
+ .setDescription(
+ ctx.locale('cmd.delete.messages.playlist_deleted', {
+ playlistName,
+ }),
+ )
+ .setColor(this.client.color.green),
+ ],
+ });
+ }
- public async autocomplete(interaction: AutocompleteInteraction): Promise {
- const focusedValue = interaction.options.getFocused();
- const userId = interaction.user.id;
+ public async autocomplete(interaction: AutocompleteInteraction): Promise {
+ const focusedValue = interaction.options.getFocused();
+ const userId = interaction.user.id;
- const playlists = await this.client.db.getUserPlaylists(userId);
+ const playlists = await this.client.db.getUserPlaylists(userId);
- const filtered = playlists.filter((playlist) => playlist.name.toLowerCase().startsWith(focusedValue.toLowerCase()));
+ const filtered = playlists.filter(playlist => playlist.name.toLowerCase().startsWith(focusedValue.toLowerCase()));
- await interaction.respond(
- filtered.map((playlist) => ({
- name: playlist.name,
- value: playlist.name,
- })),
- );
- }
+ await interaction.respond(
+ filtered.map(playlist => ({
+ name: playlist.name,
+ value: playlist.name,
+ })),
+ );
+ }
}
/**
diff --git a/src/commands/playlist/List.ts b/src/commands/playlist/List.ts
index 73e136c91..842438e56 100644
--- a/src/commands/playlist/List.ts
+++ b/src/commands/playlist/List.ts
@@ -1,128 +1,128 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class GetPlaylists extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "list",
- description: {
- content: "cmd.list.description",
- examples: ["list", "list @user"],
- usage: "list [@user]",
- },
- category: "playlist",
- aliases: ["lst"],
- cooldown: 3,
- args: false,
- vote: false,
- player: {
- voice: false,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [
- {
- name: "user",
- description: "cmd.list.options.user",
- type: 6,
- required: false,
- },
- ],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'list',
+ description: {
+ content: 'cmd.list.description',
+ examples: ['list', 'list @user'],
+ usage: 'list [@user]',
+ },
+ category: 'playlist',
+ aliases: ['lst'],
+ cooldown: 3,
+ args: false,
+ vote: false,
+ player: {
+ voice: false,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [
+ {
+ name: 'user',
+ description: 'cmd.list.options.user',
+ type: 6,
+ required: false,
+ },
+ ],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context): Promise {
- try {
- let userId: string | null = null;
- let targetUser = ctx.args[0];
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ try {
+ let userId: string | undefined;
+ let targetUser = ctx.args[0];
- if (targetUser?.startsWith("<@") && targetUser.endsWith(">")) {
- targetUser = targetUser.slice(2, -1);
+ if (targetUser?.startsWith('<@') && targetUser.endsWith('>')) {
+ targetUser = targetUser.slice(2, -1);
- if (targetUser.startsWith("!")) {
- targetUser = targetUser.slice(1);
- }
+ if (targetUser.startsWith('!')) {
+ targetUser = targetUser.slice(1);
+ }
- targetUser = await client.users.fetch(targetUser);
- userId = targetUser.id;
- } else if (targetUser) {
- try {
- targetUser = await client.users.fetch(targetUser);
- userId = targetUser.id;
- } catch (_error) {
- const users = client.users.cache.filter((user) => user.username.toLowerCase() === targetUser.toLowerCase());
+ targetUser = await client.users.fetch(targetUser);
+ userId = targetUser.id;
+ } else if (targetUser) {
+ try {
+ targetUser = await client.users.fetch(targetUser);
+ userId = targetUser.id;
+ } catch (_error) {
+ const users = client.users.cache.filter(user => user.username.toLowerCase() === targetUser.toLowerCase());
- if (users.size > 0) {
- targetUser = users.first();
- userId = targetUser?.id ?? null;
- } else {
- return await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.list.messages.invalid_username"),
- color: this.client.color.red,
- },
- ],
- });
- }
- }
- } else {
- userId = ctx.author.id;
- targetUser = ctx.author;
- }
+ if (users.size > 0) {
+ targetUser = users.first();
+ userId = targetUser?.id ?? null;
+ } else {
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.list.messages.invalid_username'),
+ color: this.client.color.red,
+ },
+ ],
+ });
+ }
+ }
+ } else {
+ userId = ctx.author?.id;
+ targetUser = ctx.author;
+ }
- if (!userId) {
- return await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.list.messages.invalid_userid"),
- color: this.client.color.red,
- },
- ],
- });
- }
+ if (!userId) {
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.list.messages.invalid_userid'),
+ color: this.client.color.red,
+ },
+ ],
+ });
+ }
- const playlists = await client.db.getUserPlaylists(userId);
+ const playlists = await client.db.getUserPlaylists(userId);
- if (!playlists || playlists.length === 0) {
- return await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.list.messages.no_playlists"),
- color: this.client.color.red,
- },
- ],
- });
- }
+ if (!playlists || playlists.length === 0) {
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.list.messages.no_playlists'),
+ color: this.client.color.red,
+ },
+ ],
+ });
+ }
- const targetUsername = targetUser ? targetUser.username : ctx.locale("cmd.list.messages.your");
- return await ctx.sendMessage({
- embeds: [
- {
- title: ctx.locale("cmd.list.messages.playlists_title", { username: targetUsername }),
- description: playlists.map((playlist: any) => playlist.name).join("\n"),
- color: this.client.color.main,
- },
- ],
- });
- } catch (error) {
- console.error(error);
- return await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.list.messages.error"),
- color: this.client.color.red,
- },
- ],
- });
- }
- }
+ const targetUsername = targetUser ? targetUser.username : ctx.locale('cmd.list.messages.your');
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ title: ctx.locale('cmd.list.messages.playlists_title', { username: targetUsername }),
+ description: playlists.map((playlist: any) => playlist.name).join('\n'),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ } catch (error) {
+ console.error(error);
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.list.messages.error'),
+ color: this.client.color.red,
+ },
+ ],
+ });
+ }
+ }
}
/**
diff --git a/src/commands/playlist/Load.ts b/src/commands/playlist/Load.ts
index 618e7c10c..9f6ca3689 100644
--- a/src/commands/playlist/Load.ts
+++ b/src/commands/playlist/Load.ts
@@ -1,115 +1,129 @@
-import type { AutocompleteInteraction } from "discord.js";
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import type { AutocompleteInteraction, GuildMember } from 'discord.js';
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class LoadPlaylist extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "load",
- description: {
- content: "cmd.load.description",
- examples: ["load "],
- usage: "load ",
- },
- category: "playlist",
- aliases: ["lo"],
- cooldown: 3,
- args: true,
- vote: true,
- player: {
- voice: true,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [
- {
- name: "playlist",
- description: "cmd.load.options.playlist",
- type: 3,
- required: true,
- autocomplete: true,
- },
- ],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'load',
+ description: {
+ content: 'cmd.load.description',
+ examples: ['load '],
+ usage: 'load ',
+ },
+ category: 'playlist',
+ aliases: ['lo'],
+ cooldown: 3,
+ args: true,
+ vote: true,
+ player: {
+ voice: true,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [
+ {
+ name: 'playlist',
+ description: 'cmd.load.options.playlist',
+ type: 3,
+ required: true,
+ autocomplete: true,
+ },
+ ],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
- let player = client.queue.get(ctx.guild!.id);
- const playlistName = args.join(" ").trim();
- const playlistData = await client.db.getPlaylist(ctx.author.id, playlistName);
- if (!playlistData) {
- return await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.load.messages.playlist_not_exist"),
- color: this.client.color.red,
- },
- ],
- });
- }
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ let player = client.manager.getPlayer(ctx.guild!.id);
+ const playlistName = args.join(' ').trim();
+ const playlistData = await client.db.getPlaylist(ctx.author?.id!, playlistName);
+ if (!playlistData) {
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.load.messages.playlist_not_exist'),
+ color: this.client.color.red,
+ },
+ ],
+ });
+ }
- const songs = await client.db.getSongs(ctx.author.id, playlistName);
- if (songs.length === 0) {
- return await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.load.messages.playlist_empty"),
- color: client.color.red,
- },
- ],
- });
- }
+ const songs = await client.db.getTracksFromPlaylist(ctx.author?.id!, playlistName);
+ if (songs.length === 0) {
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.load.messages.playlist_empty'),
+ color: client.color.red,
+ },
+ ],
+ });
+ }
- const vc = ctx.member as any;
- if (!player) {
- player = await client.queue.create(
- ctx.guild,
- vc.voice.channel,
- ctx.channel,
- client.shoukaku.options.nodeResolver(client.shoukaku.nodes),
- );
- }
+ const member = ctx.member as GuildMember;
+ if (!player) {
+ player = client.manager.createPlayer({
+ guildId: ctx.guild!.id,
+ voiceChannelId: member.voice.channelId!,
+ textChannelId: ctx.channel.id,
+ selfMute: false,
+ selfDeaf: true,
+ vcRegion: member.voice.channel?.rtcRegion!,
+ });
+ if (!player.connected) await player.connect();
+ }
- for (const song of songs) {
- const trackData = JSON.parse(song.track);
- for (const track of trackData) {
- const builtTrack = player.buildTrack(track, ctx.author as any);
- player.queue.push(builtTrack);
- }
- }
+ const nodes = client.manager.nodeManager.leastUsedNodes();
+ const node = nodes[Math.floor(Math.random() * nodes.length)];
+ const tracks = await node.decode.multipleTracks(songs as any, ctx.author);
+ if (tracks.length === 0) {
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.load.messages.playlist_empty'),
+ color: client.color.red,
+ },
+ ],
+ });
+ }
+ player.queue.add(tracks);
- await player.isPlaying();
- return await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.load.messages.playlist_loaded", { name: playlistData.name, count: songs.length }),
- color: this.client.color.main,
- },
- ],
- });
- }
+ if (!player.playing) await player.play({ paused: false });
- public async autocomplete(interaction: AutocompleteInteraction): Promise {
- const focusedValue = interaction.options.getFocused();
- const userId = interaction.user.id;
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.load.messages.playlist_loaded', {
+ name: playlistData.name,
+ count: songs.length,
+ }),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ }
- const playlists = await this.client.db.getUserPlaylists(userId);
+ public async autocomplete(interaction: AutocompleteInteraction): Promise {
+ const focusedValue = interaction.options.getFocused();
+ const userId = interaction.user.id;
- const filtered = playlists.filter((playlist) => playlist.name.toLowerCase().startsWith(focusedValue.toLowerCase()));
+ const playlists = await this.client.db.getUserPlaylists(userId);
- await interaction.respond(
- filtered.map((playlist) => ({
- name: playlist.name,
- value: playlist.name,
- })),
- );
- }
+ const filtered = playlists.filter(playlist => playlist.name.toLowerCase().startsWith(focusedValue.toLowerCase()));
+
+ await interaction.respond(
+ filtered.map(playlist => ({
+ name: playlist.name,
+ value: playlist.name,
+ })),
+ );
+ }
}
/**
diff --git a/src/commands/playlist/RemoveSong.ts b/src/commands/playlist/RemoveSong.ts
index 04c2e7201..ca60f6a99 100644
--- a/src/commands/playlist/RemoveSong.ts
+++ b/src/commands/playlist/RemoveSong.ts
@@ -1,82 +1,81 @@
-import type { AutocompleteInteraction } from "discord.js";
-import { LoadType } from "shoukaku";
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import type { AutocompleteInteraction } from 'discord.js';
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class RemoveSong extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "removesong",
- description: {
- content: "cmd.removesong.description",
- examples: ["removesong "],
- usage: "removesong ",
- },
- category: "playlist",
- aliases: ["rs"],
- cooldown: 3,
- args: true,
- vote: true,
- player: {
- voice: false,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [
- {
- name: "playlist",
- description: "cmd.removesong.options.playlist",
- type: 3,
- required: true,
- autocomplete: true,
- },
- {
- name: "song",
- description: "cmd.removesong.options.song",
- type: 3,
- required: true,
- },
- ],
- });
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'removesong',
+ description: {
+ content: 'cmd.removesong.description',
+ examples: ['removesong '],
+ usage: 'removesong ',
+ },
+ category: 'playlist',
+ aliases: ['rs'],
+ cooldown: 3,
+ args: true,
+ vote: true,
+ player: {
+ voice: false,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [
+ {
+ name: 'playlist',
+ description: 'cmd.removesong.options.playlist',
+ type: 3,
+ required: true,
+ autocomplete: true,
+ },
+ {
+ name: 'song',
+ description: 'cmd.removesong.options.song',
+ type: 3,
+ required: true,
+ },
+ ],
+ });
+ }
- public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
- const playlist = args.shift();
- const song = args.join(" ");
+ public async run(client: Lavamusic, ctx: Context, args: string[]): Promise {
+ const playlist = args.shift();
+ const song = args.join(' ');
- if (!playlist) {
- const errorMessage = this.client
- .embed()
- .setDescription(ctx.locale("cmd.removesong.messages.provide_playlist"))
- .setColor(this.client.color.red);
- return await ctx.sendMessage({ embeds: [errorMessage] });
- }
+ if (!playlist) {
+ const errorMessage = this.client
+ .embed()
+ .setDescription(ctx.locale('cmd.removesong.messages.provide_playlist'))
+ .setColor(this.client.color.red);
+ return await ctx.sendMessage({ embeds: [errorMessage] });
+ }
- if (!song) {
- const errorMessage = this.client
- .embed()
- .setDescription(ctx.locale("cmd.removesong.messages.provide_song"))
- .setColor(this.client.color.red);
- return await ctx.sendMessage({ embeds: [errorMessage] });
- }
+ if (!song) {
+ const errorMessage = this.client
+ .embed()
+ .setDescription(ctx.locale('cmd.removesong.messages.provide_song'))
+ .setColor(this.client.color.red);
+ return await ctx.sendMessage({ embeds: [errorMessage] });
+ }
- const playlistData = await client.db.getPlaylist(ctx.author.id, playlist);
+ const playlistData = await client.db.getPlaylist(ctx.author?.id!, playlist);
- if (!playlistData) {
- const playlistNotFoundError = this.client
- .embed()
- .setDescription(ctx.locale("cmd.removesong.messages.playlist_not_exist"))
- .setColor(this.client.color.red);
- return await ctx.sendMessage({ embeds: [playlistNotFoundError] });
- }
+ if (!playlistData) {
+ const playlistNotFoundError = this.client
+ .embed()
+ .setDescription(ctx.locale('cmd.removesong.messages.playlist_not_exist'))
+ .setColor(this.client.color.red);
+ return await ctx.sendMessage({ embeds: [playlistNotFoundError] });
+ }
- const res = await client.queue.search(song);
+ /* const res = await client.queue.search(song);
if (!res || res.loadType !== LoadType.TRACK) {
const noSongsFoundError = this.client
@@ -108,23 +107,23 @@ export default class RemoveSong extends Command {
.setDescription(ctx.locale("cmd.removesong.messages.error_occurred"))
.setColor(this.client.color.red);
return await ctx.sendMessage({ embeds: [genericError] });
- }
- }
- public async autocomplete(interaction: AutocompleteInteraction): Promise {
- const focusedValue = interaction.options.getFocused();
- const userId = interaction.user.id;
+ } */
+ }
+ public async autocomplete(interaction: AutocompleteInteraction): Promise {
+ const focusedValue = interaction.options.getFocused();
+ const userId = interaction.user.id;
- const playlists = await this.client.db.getUserPlaylists(userId);
+ const playlists = await this.client.db.getUserPlaylists(userId);
- const filtered = playlists.filter((playlist) => playlist.name.toLowerCase().startsWith(focusedValue.toLowerCase()));
+ const filtered = playlists.filter(playlist => playlist.name.toLowerCase().startsWith(focusedValue.toLowerCase()));
- await interaction.respond(
- filtered.map((playlist) => ({
- name: playlist.name,
- value: playlist.name,
- })),
- );
- }
+ await interaction.respond(
+ filtered.map(playlist => ({
+ name: playlist.name,
+ value: playlist.name,
+ })),
+ );
+ }
}
/**
diff --git a/src/commands/playlist/Steal.ts b/src/commands/playlist/Steal.ts
index c780c7a21..eef61c6ae 100644
--- a/src/commands/playlist/Steal.ts
+++ b/src/commands/playlist/Steal.ts
@@ -1,197 +1,199 @@
-import { Command, type Context, type Lavamusic } from "../../structures/index.js";
+import type { AutocompleteInteraction } from 'discord.js';
+import { Command, type Context, type Lavamusic } from '../../structures/index';
export default class StealPlaylist extends Command {
- constructor(client: Lavamusic) {
- super(client, {
- name: "steal",
- description: {
- content: "cmd.steal.description",
- examples: ["steal <@user> "],
- usage: "steal <@user> ",
- },
- category: "playlist",
- aliases: ["st"],
- cooldown: 3,
- args: true,
- vote: false,
- player: {
- voice: false,
- dj: false,
- active: false,
- djPerm: null,
- },
- permissions: {
- dev: false,
- client: ["SendMessages", "ReadMessageHistory", "ViewChannel", "EmbedLinks"],
- user: [],
- },
- slashCommand: true,
- options: [
- {
- name: "user",
- description: "cmd.steal.options.user",
- type: 6,
- required: true,
- },
- {
- name: "playlist",
- description: "cmd.steal.options.playlist",
- type: 3,
- required: true,
- autocomplete: true,
- },
- ],
- });
- }
-
- public async run(client: Lavamusic, ctx: Context): Promise {
- let targetUser = ctx.args[0];
- const playlistName = ctx.args[1];
- let targetUserId: string | null = null;
-
- if (targetUser?.startsWith("<@") && targetUser.endsWith(">")) {
- targetUser = targetUser.slice(2, -1);
- if (targetUser.startsWith("!")) {
- targetUser = targetUser.slice(1);
- }
- targetUser = await client.users.fetch(targetUser);
- targetUserId = targetUser.id;
- } else if (targetUser) {
- try {
- targetUser = await client.users.fetch(targetUser);
- targetUserId = targetUser.id;
- } catch (_error) {
- const users = client.users.cache.filter((user) => user.username.toLowerCase() === targetUser.toLowerCase());
-
- if (users.size > 0) {
- targetUser = users.first();
- targetUserId = targetUser.id;
- } else {
- return await ctx.sendMessage({
- embeds: [
- {
- description: "Invalid username or user not found.",
- color: this.client.color.red,
- },
- ],
- });
- }
- }
- }
-
- if (!playlistName) {
- return await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.steal.messages.provide_playlist"),
- color: this.client.color.red,
- },
- ],
- });
- }
-
- if (!targetUserId) {
- return await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.steal.messages.provide_user"),
- color: this.client.color.red,
- },
- ],
- });
- }
-
- try {
- const targetPlaylist = await client.db.getPlaylist(targetUserId, playlistName);
-
- if (!targetPlaylist) {
- return await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.steal.messages.playlist_not_exist"),
- color: this.client.color.red,
- },
- ],
- });
- }
-
- const targetSongs = await client.db.getSongs(targetUserId, playlistName);
-
- const existingPlaylist = await client.db.getPlaylist(ctx.author.id, playlistName);
- if (existingPlaylist) {
- return await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.steal.messages.playlist_exists", { playlist: playlistName }),
- color: this.client.color.red,
- },
- ],
- });
- }
-
- await client.db.createPlaylistWithSongs(ctx.author.id, playlistName, targetSongs);
-
- return await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.steal.messages.playlist_stolen", {
- playlist: playlistName,
- user: targetUser.username,
- }),
- color: this.client.color.main,
- },
- ],
- });
- } catch (error) {
- console.error(error);
- return await ctx.sendMessage({
- embeds: [
- {
- description: ctx.locale("cmd.steal.messages.error_occurred"),
- color: this.client.color.red,
- },
- ],
- });
- }
- }
-
- public async autocomplete(interaction) {
- try {
- const focusedValue = interaction.options.getFocused();
- const userOptionId = interaction.options.get("user")?.value;
-
- if (!userOptionId) {
- await interaction
- .respond([{ name: "Please specify a user to search their playlists.", value: "NoUser" }])
- .catch(console.error);
- return;
- }
-
- const user = await interaction.client.users.fetch(userOptionId);
- if (!user) {
- await interaction.respond([{ name: "User not found.", value: "NoUserFound" }]).catch(console.error);
- return;
- }
-
- const playlists = await this.client.db.getUserPlaylists(user.id);
-
- if (!playlists || playlists.length === 0) {
- await interaction.respond([{ name: "No playlists found for this user.", value: "NoPlaylists" }]).catch(console.error);
- return;
- }
-
- const filtered = playlists.filter((playlist) => playlist.name.toLowerCase().startsWith(focusedValue.toLowerCase()));
-
- return await interaction
- .respond(filtered.map((playlist) => ({ name: playlist.name, value: playlist.name })))
- .catch(console.error);
- } catch (error) {
- console.error("Error in autocomplete interaction:", error);
- return await interaction
- .respond([{ name: "An error occurred while fetching playlists.", value: "Error" }])
- .catch(console.error);
- }
- }
+ constructor(client: Lavamusic) {
+ super(client, {
+ name: 'steal',
+ description: {
+ content: 'cmd.steal.description',
+ examples: ['steal <@user> '],
+ usage: 'steal <@user> ',
+ },
+ category: 'playlist',
+ aliases: ['st'],
+ cooldown: 3,
+ args: true,
+ vote: false,
+ player: {
+ voice: false,
+ dj: false,
+ active: false,
+ djPerm: null,
+ },
+ permissions: {
+ dev: false,
+ client: ['SendMessages', 'ReadMessageHistory', 'ViewChannel', 'EmbedLinks'],
+ user: [],
+ },
+ slashCommand: true,
+ options: [
+ {
+ name: 'user',
+ description: 'cmd.steal.options.user',
+ type: 6,
+ required: true,
+ },
+ {
+ name: 'playlist',
+ description: 'cmd.steal.options.playlist',
+ type: 3,
+ required: true,
+ autocomplete: true,
+ },
+ ],
+ });
+ }
+
+ public async run(client: Lavamusic, ctx: Context): Promise {
+ let targetUser = ctx.args[0];
+ const playlistName = ctx.args[1];
+ let targetUserId: string | null = null;
+
+ if (targetUser?.startsWith('<@') && targetUser.endsWith('>')) {
+ targetUser = targetUser.slice(2, -1);
+ if (targetUser.startsWith('!')) {
+ targetUser = targetUser.slice(1);
+ }
+ targetUser = await client.users.fetch(targetUser);
+ targetUserId = targetUser.id;
+ } else if (targetUser) {
+ try {
+ targetUser = await client.users.fetch(targetUser);
+ targetUserId = targetUser.id;
+ } catch (_error) {
+ const users = client.users.cache.filter(user => user.username.toLowerCase() === targetUser.toLowerCase());
+
+ if (users.size > 0) {
+ targetUser = users.first();
+ targetUserId = targetUser.id;
+ } else {
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: 'Invalid username or user not found.',
+ color: this.client.color.red,
+ },
+ ],
+ });
+ }
+ }
+ }
+
+ if (!playlistName) {
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.steal.messages.provide_playlist'),
+ color: this.client.color.red,
+ },
+ ],
+ });
+ }
+
+ if (!targetUserId) {
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.steal.messages.provide_user'),
+ color: this.client.color.red,
+ },
+ ],
+ });
+ }
+
+ try {
+ const targetPlaylist = await client.db.getPlaylist(targetUserId, playlistName);
+
+ if (!targetPlaylist) {
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.steal.messages.playlist_not_exist'),
+ color: this.client.color.red,
+ },
+ ],
+ });
+ }
+
+ const targetSongs = await client.db.getTracksFromPlaylist(targetUserId, playlistName);
+
+ const existingPlaylist = await client.db.getPlaylist(ctx.author?.id!, playlistName);
+ if (existingPlaylist) {
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.steal.messages.playlist_exists', { playlist: playlistName }),
+ color: this.client.color.red,
+ },
+ ],
+ });
+ }
+
+ await client.db.createPlaylistWithTracks(ctx.author?.id!, playlistName, targetSongs);
+
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.steal.messages.playlist_stolen', {
+ playlist: playlistName,
+ user: targetUser.username,
+ }),
+ color: this.client.color.main,
+ },
+ ],
+ });
+ } catch (error) {
+ console.error(error);
+ return await ctx.sendMessage({
+ embeds: [
+ {
+ description: ctx.locale('cmd.steal.messages.error_occurred'),
+ color: this.client.color.red,
+ },
+ ],
+ });
+ }
+ }
+
+ public async autocomplete(interaction: AutocompleteInteraction) {
+ try {
+ const focusedValue = interaction.options.getFocused();
+ const userOptionId = interaction.options.get('user')?.value as string;
+
+ if (!userOptionId) {
+ await interaction
+ .respond([{ name: 'Please specify a user to search their playlists.', value: 'NoUser' }])
+ .catch(console.error);
+ return;
+ }
+
+ const user = await interaction.client.users.fetch(userOptionId);
+ if (!user) {
+ await interaction.respond([{ name: 'User not found.', value: 'NoUserFound' }]).catch(console.error);
+ return;
+ }
+
+ const playlists = await this.client.db.getUserPlaylists(user.id);
+
+ if (!playlists || playlists.length === 0) {
+ await interaction
+ .respond([{ name: 'No playlists found for this user.', value: 'NoPlaylists' }])
+ .catch(console.error);
+ return;
+ }
+
+ const filtered = playlists.filter(playlist => playlist.name.toLowerCase().startsWith(focusedValue.toLowerCase()));
+
+ return await interaction
+ .respond(filtered.map(playlist => ({ name: playlist.name, value: playlist.name })))
+ .catch(console.error);
+ } catch (error) {
+ return await interaction
+ .respond([{ name: 'An error occurred while fetching playlists.', value: 'Error' }])
+ .catch(console.error);
+ }
+ }
}
/**
diff --git a/src/config.ts b/src/config.ts
index 7368abb93..792c8a04a 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -1,82 +1,46 @@
-import "dotenv/config";
-import { SearchEngine } from "./types.js";
-
-const parseBoolean = (value) => {
- if (typeof value !== "string") return false;
- return value.trim().toLowerCase() === "true";
-};
-
export default {
- token: process.env.TOKEN,
- prefix: process.env.PREFIX,
- color: {
- red: 0xff0000,
- green: 0x00ff00,
- blue: 0x0000ff,
- yellow: 0xffff00,
- main: 0x2f3136,
- },
- emoji: {
- // You can add custom emoji with ID format (e.g., <:emojiName:123456789012345678>)
- pause: "⏸️",
- resume: "▶️",
- stop: "⏹️",
- skip: "⏭️",
- previous: "⏮️",
- forward: "⏩",
- rewind: "⏪",
- voldown: "🔉",
- volup: "🔊",
- shuffle: "🔀",
- loop: {
- none: "🔁",
- track: "🔂",
- },
- page: {
- last: "⏩",
- first: "⏪",
- back: "⬅️",
- next: "➡️",
- cancel: "⏹️",
- },
- },
- defaultLanguage: process.env.DEFAULT_LANGUAGE,
- topGG: process.env.TOPGG,
- keepAlive: parseBoolean(process.env.KEEP_ALIVE),
- autoNode: parseBoolean(process.env.AUTO_NODE),
- searchEngine: SearchEngine[process.env.SEARCH_ENGINE] || SearchEngine.YouTubeMusic,
- maxPlaylistSize: parseInt(process.env.MAX_PLAYLIST_SIZE || "100"),
- botStatus: process.env.BOT_STATUS || "online",
- botActivity: process.env.BOT_ACTIVITY || "Lavamusic",
- botActivityType: parseInt(process.env.BOT_ACTIVITY_TYPE || "2"),
- maxQueueSize: parseInt(process.env.MAX_QUEUE_SIZE || "100"),
- owners: process.env.OWNER_IDS ? JSON.parse(process.env.OWNER_IDS) : [],
- clientId: process.env.CLIENT_ID,
- guildId: process.env.GUILD_ID,
- logChannelId: process.env.LOG_CHANNEL_ID,
- commandLogs: process.env.LOG_COMMANDS_ID,
- lyricsApi: process.env.GENIUS_API,
- links: {
- img: process.env.IMG_LINK || "https://i.imgur.com/ud3EWNh.jpg",
- },
- icons: {
- youtube: "https://i.imgur.com/xzVHhFY.png",
- spotify: "https://i.imgur.com/qvdqtsc.png",
- soundcloud: "https://i.imgur.com/MVnJ7mj.png",
- applemusic: "https://i.imgur.com/Wi0oyYm.png",
- deezer: "https://i.imgur.com/xyZ43FG.png",
- jiosaavn: "https://i.imgur.com/N9Nt80h.png",
- },
- lavalink: process.env.LAVALINK_SERVERS
- ? JSON.parse(process.env.LAVALINK_SERVERS).map((server) => {
- return {
- url: server.url,
- auth: server.auth,
- name: server.name,
- secure: parseBoolean(server.secure),
- };
- })
- : [],
+ color: {
+ red: 0xff0000,
+ green: 0x00ff00,
+ blue: 0x0000ff,
+ yellow: 0xffff00,
+ main: 0x2f3136,
+ },
+ emoji: {
+ // You can add custom emoji with ID format (e.g., <:emojiName:123456789012345678>)
+ pause: '⏸️',
+ resume: '▶️',
+ stop: '⏹️',
+ skip: '⏭️',
+ previous: '⏮️',
+ forward: '⏩',
+ rewind: '⏪',
+ voldown: '🔉',
+ volup: '🔊',
+ shuffle: '🔀',
+ loop: {
+ none: '🔁',
+ track: '🔂',
+ },
+ page: {
+ last: '⏩',
+ first: '⏪',
+ back: '⬅️',
+ next: '➡️',
+ cancel: '⏹️',
+ },
+ },
+ icons: {
+ youtube: 'https://i.imgur.com/xzVHhFY.png',
+ spotify: 'https://i.imgur.com/qvdqtsc.png',
+ soundcloud: 'https://i.imgur.com/MVnJ7mj.png',
+ applemusic: 'https://i.imgur.com/Wi0oyYm.png',
+ deezer: 'https://i.imgur.com/xyZ43FG.png',
+ jiosaavn: 'https://i.imgur.com/N9Nt80h.png',
+ } as any,
+ links: {
+ img: 'https://i.imgur.com/ud3EWNh.jpg',
+ },
};
/**
diff --git a/src/database/server.ts b/src/database/server.ts
index 1710a8321..6f3a4248e 100644
--- a/src/database/server.ts
+++ b/src/database/server.ts
@@ -1,212 +1,270 @@
-import { type Dj, type Guild, type Playlist, PrismaClient, type Role, type Setup, type Song, type Stay } from "@prisma/client";
-import config from "../config.js";
+import { type Dj, type Guild, type Playlist, PrismaClient, type Role, type Setup, type Stay } from '@prisma/client';
+import { env } from '../env';
export default class ServerData {
- private prisma: PrismaClient;
-
- constructor() {
- this.prisma = new PrismaClient();
- }
-
- public async get(guildId: string): Promise {
- return (await this.prisma.guild.findUnique({ where: { guildId } })) ?? this.createGuild(guildId);
- }
-
- private async createGuild(guildId: string): Promise {
- return await this.prisma.guild.create({
- data: {
- guildId,
- prefix: config.prefix,
- },
- });
- }
-
- public async setPrefix(guildId: string, prefix: string): Promise {
- await this.prisma.guild.upsert({
- where: { guildId },
- update: { prefix },
- create: { guildId, prefix },
- });
- }
-
- public async getPrefix(guildId: string): Promise {
- const guild = await this.get(guildId);
- return guild?.prefix ?? config.prefix;
- }
-
- public async updateLanguage(guildId: string, language: string): Promise {
- await this.prisma.guild.update({
- where: { guildId },
- data: { language },
- });
- }
-
- public async getLanguage(guildId: string): Promise {
- const guild = await this.get(guildId);
- return guild?.language ?? config.defaultLanguage;
- }
-
- public async getSetup(guildId: string): Promise {
- return await this.prisma.setup.findUnique({ where: { guildId } });
- }
-
- public async setSetup(guildId: string, textId: string, messageId: string): Promise {
- await this.prisma.setup.upsert({
- where: { guildId },
- update: { textId, messageId },
- create: { guildId, textId, messageId },
- });
- }
-
- public async deleteSetup(guildId: string): Promise {
- await this.prisma.setup.delete({ where: { guildId } });
- }
-
- public async set_247(guildId: string, textId: string, voiceId: string): Promise {
- await this.prisma.stay.upsert({
- where: { guildId },
- update: { textId, voiceId },
- create: { guildId, textId, voiceId },
- });
- }
-
- public async delete_247(guildId: string): Promise {
- await this.prisma.stay.delete({ where: { guildId } });
- }
-
- public async get_247(guildId?: string): Promise {
- if (guildId) {
- return await this.prisma.stay.findUnique({ where: { guildId } });
- }
- return this.prisma.stay.findMany();
- }
-
- public async setDj(guildId: string, mode: boolean): Promise {
- await this.prisma.dj.upsert({
- where: { guildId },
- update: { mode },
- create: { guildId, mode },
- });
- }
-
- public async getDj(guildId: string): Promise {
- return await this.prisma.dj.findUnique({ where: { guildId } });
- }
-
- public async getRoles(guildId: string): Promise {
- return await this.prisma.role.findMany({ where: { guildId } });
- }
-
- public async addRole(guildId: string, roleId: string): Promise {
- await this.prisma.role.create({ data: { guildId, roleId } });
- }
-
- public async removeRole(guildId: string, roleId: string): Promise {
- await this.prisma.role.deleteMany({ where: { guildId, roleId } });
- }
-
- public async clearRoles(guildId: string): Promise {
- await this.prisma.role.deleteMany({ where: { guildId } });
- }
-
- public async getPlaylist(userId: string, name: string): Promise {
- return await this.prisma.playlist.findUnique({
- where: { userId_name: { userId, name } },
- });
- }
-
- public async getUserPlaylists(userId: string): Promise {
- return await this.prisma.playlist.findMany({
- where: { userId },
- });
- }
-
- public async createPlaylist(userId: string, name: string): Promise {
- await this.prisma.playlist.create({ data: { userId, name } });
- }
-
- public async createPlaylistWithSongs(userId: string, name: string, songs: any[]): Promise {
- await this.prisma.playlist.create({
- data: {
- userId,
- name,
- songs: {
- create: songs.map((song) => ({ track: song.track })),
- },
- },
- });
- }
-
- public async deletePlaylist(userId: string, name: string): Promise {
- await this.prisma.playlist.delete({
- where: { userId_name: { userId, name } },
- });
- }
-
- public async deleteSongsFromPlaylist(userId: string, playlistName: string): Promise {
- const playlist = await this.getPlaylist(userId, playlistName);
- if (playlist) {
- await this.prisma.song.deleteMany({
- where: {
- playlistId: playlist.id,
- },
- });
- }
- }
-
- public async addSong(userId: string, name: string, song: string): Promise {
- const playlist = await this.getPlaylist(userId, name);
- if (playlist) {
- await this.prisma.song.create({
- data: {
- track: JSON.stringify(song),
- playlistId: playlist.id,
- },
- });
- } else {
- await this.createPlaylist(userId, name);
- await this.addSong(userId, name, song);
- }
- }
-
- public async removeSong(userId: string, playlistName: string, encodedSong: string): Promise {
- const playlist = await this.getPlaylist(userId, playlistName);
- if (playlist) {
- await this.prisma.song.deleteMany({
- where: {
- playlistId: playlist.id,
- track: { contains: encodedSong },
- },
- });
- }
- }
-
- public async getSongs(userId: string, name: string): Promise {
- const playlist = await this.getPlaylist(userId, name);
- if (playlist) {
- return this.prisma.song.findMany({ where: { playlistId: playlist.id } });
- }
- return [];
- }
-
- public async clearPlaylist(userId: string, name: string): Promise {
- const playlist = await this.getPlaylist(userId, name);
- if (playlist) {
- await this.prisma.song.deleteMany({ where: { playlistId: playlist.id } });
- }
- }
-
- public async clearPlaylists(userId: string): Promise {
- await this.prisma.playlist.deleteMany({ where: { userId } });
- }
-
- public async clearAllPlaylists(): Promise {
- await this.prisma.playlist.deleteMany();
- }
-
- public async clearAllSongs(): Promise {
- await this.prisma.song.deleteMany();
- }
+ private prisma: PrismaClient;
+
+ constructor() {
+ this.prisma = new PrismaClient();
+ }
+
+ public async get(guildId: string): Promise {
+ return (await this.prisma.guild.findUnique({ where: { guildId } })) ?? this.createGuild(guildId);
+ }
+
+ private async createGuild(guildId: string): Promise {
+ return await this.prisma.guild.create({
+ data: {
+ guildId,
+ prefix: env.PREFIX,
+ },
+ });
+ }
+
+ public async setPrefix(guildId: string, prefix: string): Promise {
+ await this.prisma.guild.upsert({
+ where: { guildId },
+ update: { prefix },
+ create: { guildId, prefix },
+ });
+ }
+
+ public async getPrefix(guildId: string): Promise {
+ const guild = await this.get(guildId);
+ return guild?.prefix ?? env.PREFIX;
+ }
+
+ public async updateLanguage(guildId: string, language: string): Promise {
+ await this.prisma.guild.update({
+ where: { guildId },
+ data: { language },
+ });
+ }
+
+ public async getLanguage(guildId: string): Promise {
+ const guild = await this.get(guildId);
+ return guild?.language ?? env.DEFAULT_LANGUAGE;
+ }
+
+ public async getSetup(guildId: string): Promise {
+ return await this.prisma.setup.findUnique({ where: { guildId } });
+ }
+
+ public async setSetup(guildId: string, textId: string, messageId: string): Promise {
+ await this.prisma.setup.upsert({
+ where: { guildId },
+ update: { textId, messageId },
+ create: { guildId, textId, messageId },
+ });
+ }
+
+ public async deleteSetup(guildId: string): Promise {
+ await this.prisma.setup.delete({ where: { guildId } });
+ }
+
+ public async set_247(guildId: string, textId: string, voiceId: string): Promise