mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-02 14:38:49 +00:00
52 files changed
+2822
-732
No files matched your search
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"ignorePatterns": ["config/**/*.js"],
|
||||
"ignorePatterns": ["config/**/*.js", "locales/**"],
|
||||
"env": {
|
||||
"node": true,
|
||||
"es2021": true
|
||||
|
||||
@@ -21,13 +21,16 @@
|
||||
</p>
|
||||
|
||||
## Core Features 🌟
|
||||
|
||||
Cadence offers an enriching audio experience on Discord with features such as:
|
||||
- High-quality music playback from [many supported sources](https://discord-player.js.org/guide/extractors/stream-sources) thanks to [discord-player](https://github.com/androz2091/discord-player).
|
||||
- Slash commands, autocompleting search queries, select menus, buttons and more interactive features!
|
||||
- Full queue management system to add, remove, skip or move tracks, view queue and history.
|
||||
- Audio filters, shuffle mode, repeat track, queue or autoplay similar tracks!
|
||||
- Open-source codebase and community based development, open to feedback and improvements.
|
||||
- No locked functionality, no premium tier, no ads; everything's free, always.
|
||||
|
||||
- High-quality music playback from [many supported sources](https://discord-player.js.org/guide/extractors/stream-sources) thanks to [discord-player](https://github.com/androz2091/discord-player).
|
||||
- Slash commands, autocompleting search queries, select menus, buttons and more interactive features!
|
||||
- Full queue management system to add, remove, skip or move tracks, view queue and history.
|
||||
- Audio filters, shuffle mode, repeat track, queue or autoplay similar tracks!
|
||||
- Localization with support for multiple languages both for Slash Commands and embed replies.
|
||||
- Open-source codebase and community based development, open to feedback and improvements.
|
||||
- No locked functionality, no premium tier, no ads; everything's free, always.
|
||||
|
||||
<br>
|
||||
|
||||
@@ -54,10 +57,10 @@ Cadence offers an enriching audio experience on Discord with features such as:
|
||||
|
||||
### Configuration and Logging:
|
||||
|
||||
- Override default configuration by creating `/config/local.js`.
|
||||
- Use `npm run deploy-pretty` and `npm run start-pretty` for better console output, requires [pino-pretty](https://www.npmjs.com/package/pino-pretty).
|
||||
- Logs are stored in `/logs` folder. Configure the logging level in the config file.
|
||||
- For production, usage of `pm2` or similar to manage the bot process is recommended.
|
||||
- Override default configuration by creating `/config/local.js`.
|
||||
- Use `npm run deploy-pretty` and `npm run start-pretty` for better console output, requires [pino-pretty](https://www.npmjs.com/package/pino-pretty).
|
||||
- Logs are stored in `/logs` folder. Configure the logging level in the config file.
|
||||
- For production, usage of `pm2` or similar to manage the bot process is recommended.
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@ module.exports.embedOptions = {
|
||||
nextTrack: '⏭️',
|
||||
previousTrack: '⏮️',
|
||||
pauseResumeTrack: '⏯️',
|
||||
paused: '⏸',
|
||||
shuffleQueue: '🔀',
|
||||
loop: '🔁',
|
||||
loopAction: '🔁',
|
||||
|
||||
@@ -0,0 +1,409 @@
|
||||
{
|
||||
"autocomplete": {
|
||||
"trackName": "{{title}} [Author: {{author}}]"
|
||||
},
|
||||
"commands": {
|
||||
"back": {
|
||||
"metadata": {
|
||||
"name": "back",
|
||||
"description": "Go back to previous track or specified position in history.",
|
||||
"options": {
|
||||
"position": {
|
||||
"name": "position",
|
||||
"description": "The position in history to go back to."
|
||||
}
|
||||
}
|
||||
},
|
||||
"trackHistoryEmpty": "{{icon}} **Oops!**\nThe history is empty, add some tracks with {{playCommand}}!",
|
||||
"trackPositionHigherThanHistoryLength_one": "{{icon}} **Oops!**\nThere is only **1** track in the history. You cannot go back to track **{{backPosition}}**.\n\nView tracks added in the history with {{historyCommand}}.",
|
||||
"trackPositionHigherThanHistoryLength": "{{icon}} **Oops!**\nThere are only **{{count}}** tracks in the history. You cannot go back to track **{{backPosition}}**.\n\nView tracks added in the history with {{historyCommand}}.",
|
||||
"trackRecovered": "{{icon}} **Recovered track**\n{{track}}"
|
||||
},
|
||||
"filters": {
|
||||
"metadata": {
|
||||
"name": "filters",
|
||||
"description": "Toggle various audio filters.",
|
||||
"options": {
|
||||
"type": {
|
||||
"name": "type",
|
||||
"description": "Audio filter type to use.",
|
||||
"choices": {
|
||||
"ffmpeg": "FFmpeg",
|
||||
"biquad": "Biquad",
|
||||
"equalizer": "Equalizer",
|
||||
"disable": "Disabled"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"allFiltersDisabled": "{{icon}} **Disabled filters**\nAll audio filters have been disabled.",
|
||||
"disableAllFiltersButton": "Disable all filters",
|
||||
"nowUsingFilters": "{{icon}} **Filters toggled**\nNow using these {{mode}} filters:",
|
||||
"selectFilterPlaceholder": "Select a filter from the menu.",
|
||||
"selectFilterPlaceholderMany": "Select one or multiple filters.",
|
||||
"toggleFilterInstructions": "**Toggle filters ({{provider}})**\nEnable or disable audio filters for playback from the menu."
|
||||
},
|
||||
"guilds": {
|
||||
"metadata": {
|
||||
"name": "guilds",
|
||||
"description": "Show the top 25 guilds by member count."
|
||||
},
|
||||
"topGuildsByMemberCount": "{{icon}} **Top {{count}} guilds by member count ({{totalCount}} total)**",
|
||||
"totalMembers": "**Total members:** **`{{count}`**"
|
||||
},
|
||||
"help": {
|
||||
"metadata": {
|
||||
"name": "help",
|
||||
"description": "Show the list of bot commands."
|
||||
},
|
||||
"addBotButton": "Add bot",
|
||||
"listTitle": "{{icon}} **List of commands**",
|
||||
"supportServerButton": "Support server"
|
||||
},
|
||||
"history": {
|
||||
"metadata": {
|
||||
"name": "history",
|
||||
"description": "Show history of tracks that have been played.",
|
||||
"options": {
|
||||
"page": {
|
||||
"name": "page",
|
||||
"description": "Page number to display for the history."
|
||||
}
|
||||
}
|
||||
},
|
||||
"emptyHistory": "The history is empty, add some tracks with {{playCommand}}!",
|
||||
"invalidPageNumber_one": "{{icon}} **Oops!**\nPage **`{{page}}`** is not a valid page number.\n\nThere is only **`1`** page in the history.",
|
||||
"invalidPageNumber": "{{icon}} **Oops!**\nPage **`{{page}}`** is not a valid page number.\n\nThere are only a total of **`{{count}}`** pages in the history.",
|
||||
"tracksInHistoryTitle": "{{icon}} **Tracks in history**"
|
||||
},
|
||||
"join": {
|
||||
"metadata": {
|
||||
"name": "join",
|
||||
"description": "The bot will join the voice channel if not already in one."
|
||||
},
|
||||
"alreadyConnected": "{{icon}} **Oops!**\nI am already connected to the {{channel}} voice channel.\n\nTo disconnect me from the channel, use the {{leaveCommand}} command.",
|
||||
"couldNotJoin": "{{icon}} **Oops!**\nCould not join voice channel, please try again.",
|
||||
"joinedChannel": "{{icon}} **Joined channel**\nConnected to voice channel: {{channel}}\n\nTo add tracks, use the {{playCommand}} command!"
|
||||
},
|
||||
"leave": {
|
||||
"metadata": {
|
||||
"name": "leave",
|
||||
"description": "Clear the queue and remove bot from voice channel."
|
||||
},
|
||||
"leavingChannel": "{{icon}} **Leaving channel**\nCleared the track queue and left voice channel.\n\nTo play more music, use the {{playCommand}} command!"
|
||||
},
|
||||
"loop": {
|
||||
"metadata": {
|
||||
"name": "loop",
|
||||
"description": "Toggle looping a track, the whole queue or autoplay.",
|
||||
"options": {
|
||||
"mode": {
|
||||
"name": "mode",
|
||||
"description": "Loop mode: Track, queue, autoplay or disabled.",
|
||||
"choices": {
|
||||
"0": "Off",
|
||||
"1": "Track",
|
||||
"2": "Queue",
|
||||
"3": "Autoplay"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"alreadySet": "{{icon}} **Oops!**\nLoop mode is already **`{{mode}}`**.",
|
||||
"loopModeInformation": "{{icon}} **Current loop mode**\nThe looping mode is currently set to **`{{mode}}`**.",
|
||||
"modeChanged": "{{icon}} **Loop mode changed**\nChanging loop mode from **`{{fromName}}`** to **`{{toName}}`**.",
|
||||
"willAutoplay": "When the queue is empty, similar tracks will start playing!",
|
||||
"willNoLongerPlay": "The {{mode}} will no longer play on repeat!",
|
||||
"willNowPlay": "The {{mode}} will now play on repeat!"
|
||||
},
|
||||
"lyrics": {
|
||||
"metadata": {
|
||||
"name": "lyrics",
|
||||
"description": "Search Genius lyrics for current or specified track.",
|
||||
"options": {
|
||||
"query": {
|
||||
"name": "query",
|
||||
"description": "Search query by text or URL."
|
||||
}
|
||||
}
|
||||
},
|
||||
"autocompleteSearchResult": "{{title}} [Artist: {{artist}}]",
|
||||
"lyricsEmbed": "{{icon}} **Showing lyrics**\n**Track: [{{trackTitle}}]({{trackUrl}})**\n**Artist: [{{artistName}}]({{artistUrl}})**",
|
||||
"noLyricsFound": "{{icon}} **No lyrics found**\nThere were no Genius lyrics found for track **{{query}}**."
|
||||
},
|
||||
"move": {
|
||||
"metadata": {
|
||||
"name": "move",
|
||||
"description": "Move a track to a specified position in queue.",
|
||||
"options": {
|
||||
"from": {
|
||||
"name": "from",
|
||||
"description": "The position of the track to move."
|
||||
},
|
||||
"to": {
|
||||
"name": "to",
|
||||
"description": "The position to move the track to."
|
||||
}
|
||||
}
|
||||
},
|
||||
"trackMoved": "{{icon}} **Moved track**\n{track}\n\nTrack has been moved from position **`{{fromPosition}}`** to position **`{{toPosition}}`**.",
|
||||
"trackPositionHigherThanQueueLength_one": "{{icon}} **Oops!**\nYou cannot move the track in position **`{{fromPosition}}`** to position **`{{toPosition}}`**. There is only **`1`** track in the queue.\n\nView tracks added to the queue with {{queueCommand}}.",
|
||||
"trackPositionHigherThanQueueLength": "{{icon}} **Oops!**\nYou cannot move the track in position **`{{fromPosition}}`** to position **`{{toPosition}}`**. There are only **`{{count}}`** tracks in the queue.\n\nView tracks added to the queue with {{queueCommand}}."
|
||||
},
|
||||
"nowplaying": {
|
||||
"metadata": {
|
||||
"name": "nowplaying",
|
||||
"description": "Show information about the current track."
|
||||
},
|
||||
"embedFields": {
|
||||
"author": "**Artist**",
|
||||
"plays": "**Plays**",
|
||||
"source": "**Track source**"
|
||||
},
|
||||
"otherTracksInQueue_one": "1 other track in the queue...",
|
||||
"otherTracksInQueue": "{{count}} other tracks in the queue...",
|
||||
"playCount_zero": "Unknown",
|
||||
"playCount": "{{count, number}}"
|
||||
},
|
||||
"pause": {
|
||||
"metadata": {
|
||||
"name": "pause",
|
||||
"description": "Toggle pause for the current track."
|
||||
},
|
||||
"pauseConfirmation": "{{icon}} **Paused track**",
|
||||
"resumeConfirmation": "{{icon}} **Resumed track**",
|
||||
"directSource": "Direct source"
|
||||
},
|
||||
"play": {
|
||||
"metadata": {
|
||||
"name": "play",
|
||||
"description": "Add a track or playlist to the queue by search query or URL.",
|
||||
"options": {
|
||||
"query": {
|
||||
"name": "query",
|
||||
"description": "Search query by text or URL."
|
||||
}
|
||||
}
|
||||
},
|
||||
"addedToQueueTitle": "{{icon}} **Added to queue**",
|
||||
"playlistAddedTitle": "{{icon}} **Added playlist to queue**",
|
||||
"playlistAddedTrackCount_one": "And **1** more track... Use {{queueCommand}} to view all.",
|
||||
"playlistAddedTrackCount": "And **{{count}}** more tracks... Use {{queueCommand}} to view all.",
|
||||
"playlistTooLarge": "{{icon}} **Playlist too large**\nThis playlist is too large to be added to the queue.\n\nThe maximum amount of tracks that can be added to the queue is **{{count}}**.",
|
||||
"trackNotFound": "{{icon}} **No track found\nNo results found for **{{query}}**.\n\nIf you specified a URL, please make sure it is valid and public."
|
||||
},
|
||||
"queue": {
|
||||
"metadata": {
|
||||
"name": "queue",
|
||||
"description": "Show tracks that have been added to the queue.",
|
||||
"options": {
|
||||
"page": {
|
||||
"name": "page",
|
||||
"description": "Page number to display for the queue."
|
||||
}
|
||||
}
|
||||
},
|
||||
"tracksInQueueTitle": "{{icon}} **Tracks in queue**",
|
||||
"emptyQueue": "The queue is empty, add some tracks with {{playCommand}}!",
|
||||
"estimatedDuration": "Estimated duration: {{duration}}",
|
||||
"estimatedReallyLongTime": "Estimated duration: A really long time",
|
||||
"invalidPageNumber_one": "{{icon}} **Oops!**\nPage **`{{page}}`** is not a valid page number.\n\nThere is only **`1`** page in the queue.",
|
||||
"invalidPageNumber": "{{icon}} **Oops!**\nPage **`{{page}}`** is not a valid page number.\n\nThere are only a total of **`{{count}}`** pages in the queue."
|
||||
},
|
||||
"reload": {
|
||||
"metadata": {
|
||||
"name": "reload",
|
||||
"description": "Reload slash command, autocomplete and component interactions across shards."
|
||||
},
|
||||
"reloadedCommands": "{{icon}} **Reloaded commands**",
|
||||
"unableToReload": "{{icon}} **Oops!**\n_Hmm..._ It seems I am unable to reload the interaction module across shards."
|
||||
},
|
||||
"remove": {
|
||||
"noTracksRemoved": "{{icon}} **No tracks removed**\nThere were no tracks removed from the queue. Please check if the option you selected has tracks to remove.",
|
||||
"removedTrack": "{{icon}} **Removed track**",
|
||||
"removedTracks": "{{icon}} **Removed tracks**\n**`{{count}}`** tracks were removed from the queue.",
|
||||
"startPositionHigherThanEndPosition": "{{icon}} **Oops!**\nStart position **`{{start}}`** is higher than end position **`{{end}}`**. Please specify a valid range.\n\nView tracks added to the queue with {{queueCommand}}.",
|
||||
"trackPositionHigherThanQueueLength_one": "{{icon}} **Oops!**\nPosition **`{{position}}`** is not a valid track position. There is only a total of **`1`** track in the queue.\n\nView the tracks added to the queue with {{queueCommand}}.",
|
||||
"trackPositionHigherThanQueueLength": "{{icon}} **Oops!**\nPosition **`{{position}}`** is not a valid track position. There are only a total of **`{{count}}`** tracks in the queue.\n\nView the tracks added to the queue with {{queueCommand}}."
|
||||
},
|
||||
"seek": {
|
||||
"metadata": {
|
||||
"name": "seek",
|
||||
"description": "Seek to a time position in the current track.",
|
||||
"options": {
|
||||
"duration": {
|
||||
"name": "duration",
|
||||
"description": "Timestamp in format 00:00:00 (HH:mm:ss)."
|
||||
}
|
||||
}
|
||||
},
|
||||
"correctFormatInstruction": "{{icon}} **Oops!**\nYou entered an invalid duration format, **`{{wrongDuration}}`**.\nPlease use the format **`HH:mm:ss`**, **`mm:ss`** or **`ss`**.\n\n**Examples:**\n- **`/seek`** **`1:24:12`** - Seek to 1 hour, 24 minutes and 12 seconds.\n- **`/seek`** **`3:27`** - Seek to 3 minutes and 27 seconds.\n- **`/seek`** **`42`** - Seek to 42 seconds.",
|
||||
"durationLongerThanTrackDuration": "{{icon}} **Oops!**\nYou entered **`{{wrongDuration}}`**, which is a timestamp longer than the duration of the current track.\n\nPlease try a timestamp that is less than the duration of the track (**{{trackDuration}}**).",
|
||||
"seekingToTimestamp": "{{icon}} **Seeking to timestamp**\nSeeking to **`{{duration}}`** in current track."
|
||||
},
|
||||
"shards": {
|
||||
"metadata": {
|
||||
"name": "shards",
|
||||
"description": "Show information about all connected shards.",
|
||||
"options": {
|
||||
"sort": {
|
||||
"name": "sort",
|
||||
"description": "What to sort the shards by.",
|
||||
"choices": {
|
||||
"none": "None (Shard ID)",
|
||||
"memory": "Memory usage",
|
||||
"connections": "Voice Connections",
|
||||
"tracks": "Tracks",
|
||||
"listeners": "Listeners",
|
||||
"guilds": "Guilds",
|
||||
"members": "Members"
|
||||
}
|
||||
},
|
||||
"page": {
|
||||
"name": "page",
|
||||
"description": "Page number to display for the shards."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"shuffle": {
|
||||
"metadata": {
|
||||
"name": "shuffle",
|
||||
"description": "Randomly shuffle all tracks in the queue."
|
||||
},
|
||||
"shuffledTracks": "{{icon}} **Shuffled queue tracks**\nThe **{{count}}** tracks in the queue have been shuffled.\n\nView the new queue order with {{queueCommand}}."
|
||||
},
|
||||
"skip": {
|
||||
"metadata": {
|
||||
"name": "skip",
|
||||
"description": "Skip track to next or specified position in queue.",
|
||||
"options": {
|
||||
"position": {
|
||||
"name": "position",
|
||||
"description": "The position in queue to skip to."
|
||||
}
|
||||
}
|
||||
},
|
||||
"emptyQueue": "{{icon}} **Oops!**\nThe queue is empty, add some tracks with {{playCommand}}!",
|
||||
"skippedTrack": "{{icon}} **Skipped track**",
|
||||
"trackPositionHigherThanQueueLength_one": "{{icon}} **Oops!**\nThere is only **1** track in the queue. You cannot skip to track **{{position}}**.\n\nView tracks added to the queue with {{queueCommand}}.",
|
||||
"trackPositionHigherThanQueueLength": "{{icon}} **Oops!**\nThere are only **{{count}}** tracks in the queue. You cannot skip to track **{{position}}**.\n\nView tracks added to the queue with {{queueCommand}}."
|
||||
},
|
||||
"status": {
|
||||
"metadata": {
|
||||
"name": "status",
|
||||
"description": "Show operational status of the bot."
|
||||
}
|
||||
},
|
||||
"stop": {
|
||||
"metadata": {
|
||||
"name": "stop",
|
||||
"description": "Clear the queue and stop playing audio."
|
||||
},
|
||||
"stoppedPlaying": "{{icon}} **Stopped playing**\nStopped playing the audio and cleared the track queue.\n\nTo play more music, use the {{playCommand}} command!"
|
||||
},
|
||||
"systemstatus": {
|
||||
"metadata": {
|
||||
"name": "systemstatus",
|
||||
"description": "Show operational status of the bot with additional technical information."
|
||||
}
|
||||
},
|
||||
"volume": {
|
||||
"metadata": {
|
||||
"name": "volume",
|
||||
"description": "Show or change the playback volume for tracks.",
|
||||
"options": {
|
||||
"percentage": {
|
||||
"name": "percentage",
|
||||
"description": "Volume percentage: From 1% to 100%."
|
||||
}
|
||||
}
|
||||
},
|
||||
"invalidVolumeRange": "{{icon}} **Oops!**\nYou cannot set the volume to **`{{wrongVolume}}%`**, please pick a value between **`1%`** and **`100%`**.",
|
||||
"volumeChanged": "{{icon}} **Volume changed**\nPlayback volume has been changed to **`{{volume}}%`**.",
|
||||
"volumeInformation": "{{icon}} **Playback volume**\nThe playback volume is currently set to **`{{volume}}`**.",
|
||||
"volumeMuted": "{{icon}} **Audio muted**\nPlayback audio has been muted, because the volume was set to **`0%`**."
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"responses": {
|
||||
"paused": "Paused track",
|
||||
"resumed": "Resumed track"
|
||||
}
|
||||
},
|
||||
"musicPlayerCommon": {
|
||||
"controls": {
|
||||
"stop": "Stop",
|
||||
"previous": "Previous",
|
||||
"pause": "Pause",
|
||||
"resume": "Resume",
|
||||
"skip": "Skip"
|
||||
},
|
||||
"footerPageNumber_one": "Page {{page}} of {{pageCount}} (1 track)",
|
||||
"footerPageNumber": "Page {{page}} of {{pageCount}} ({{count}} tracks)",
|
||||
"loopingInfo": "{{icon}} **Looping**\nLoop mode is set to **`{{loopMode}}`**. You can change it with {{loopCommand}}.\n",
|
||||
"nowPausedTitle": "{{icon}} **Currently paused**",
|
||||
"nowPlayingTitle": "{{icon}} **Now playing**",
|
||||
"playingLive": "{{icon}} **`LIVE`** - Playing continuously from live source.",
|
||||
"queueRepeatMode": {
|
||||
"off": "Disabled",
|
||||
"track": "Track",
|
||||
"queue": "Queue",
|
||||
"autoplay": "Autoplay"
|
||||
},
|
||||
"requestedBy": "**Requested by:** {{user}}",
|
||||
"unavailableAuthor": "Unavailable",
|
||||
"unavailableDuration": "_No duration available._",
|
||||
"unavailableRequestedBy": "Unavailable",
|
||||
"unavailableTrackTitle": "Title unavailable",
|
||||
"unavailableTrackUrl": "**Unavailable**",
|
||||
"unavailableSource": "Unavailable",
|
||||
"voiceChannelInfo": "Channel: {{channel}} ({{bitrate}}kbps)"
|
||||
},
|
||||
"statistics": {
|
||||
"botStatus": {
|
||||
"title": "{{icon}} **Bot status**",
|
||||
"joinedServers": "**{{count}}** Joined servers",
|
||||
"joinedServers_one": "**1** Joined server",
|
||||
"totalMembers": "**{{count}}** Total members",
|
||||
"releaseVersion": "**{{version}}** Release version"
|
||||
},
|
||||
"queueStatus": {
|
||||
"title": "{{icon}} **Queue status**",
|
||||
"voiceConnections": "**{{count}}** Voice connections",
|
||||
"voiceConnections_one": "**1** Voice connection",
|
||||
"tracksInQueues": "**{{count}}** Tracks in queues",
|
||||
"tracksInQueues_one": "**1** Track in queues",
|
||||
"usersListening": "**{{count}}** Users listening",
|
||||
"usersListening_one": "**1** User listening"
|
||||
},
|
||||
"systemStatus": {
|
||||
"title": "{{icon}} **System status**",
|
||||
"uptime": "**{{value}}** Uptime",
|
||||
"cpu": "**{{value, number(minimumFractionDigits: 2)}}%** CPU usage",
|
||||
"cpuDetailed": "**{{usage}}% @ {{cores}} cores** CPU usage",
|
||||
"memory": "**{{value, number}} MB** Memory usage",
|
||||
"memoryDetailed": "**{{used, number}} / {{total, number}} MB** Memory usage",
|
||||
"platform": "**{{value}}** Platform"
|
||||
},
|
||||
"discordStatus": {
|
||||
"title": "{{icon}} **Discord status**",
|
||||
"apiLatency": "**{{value, number}} ms** Discord API latency"
|
||||
},
|
||||
"dependencies": {
|
||||
"title": "{{icon}} **Dependencies**"
|
||||
}
|
||||
},
|
||||
"validation": {
|
||||
"cannotJoinVoiceOrTalk": "{{icon}} **Oops!**\nI do not have permission to play audio in the voice channel {{channel}}.\n\nPlease make sure I have the **`Connect`** and **`Speak`** permissions in this voice channel.",
|
||||
"cannotSendMessageInChannel": "{{icon}} **Oops!**\nI do not have permission to send message replies in the channel {{channel}}.\n\nPlease make sure I have the **`View Channel`** permission in this text channel.",
|
||||
"historyDoesNotExist": "{{icon}} **Oops!**\nThere are no tracks in the history and nothing currently playing. First add some tracks with {{playCommand}}!",
|
||||
"notInSameVoiceChannel": "{{icon}} **Not in same voice channel**\nYou need to be in the same voice channel as me to perform this action.\n\n**Voice channel:** {{channel}}",
|
||||
"notInVoiceChannel": "{{icon}} **Not in a voice channel**\nYou need to be in a voice channel to perform this action.",
|
||||
"notValidGuildId": "{{icon}} **Oops!**\nNo permission to perform this action.\n\nThe command {{command}} cannot be executed in this server.",
|
||||
"queueDoesNotExist": "{{icon}} **Oops!**\nThere are no tracks in the queue and nothing currently playing. First add some tracks with {{playCommand}}!",
|
||||
"queueIsEmpty": "{{icon}} **Oops!\nThere are no tracks added to the queue. First add some tracks with {{playCommand}}!",
|
||||
"queueNoCurrentTrack": "{{icon}} **Oops!**\nThere is nothing currently playing. First add some tracks with {{playCommand}}!",
|
||||
"trackNotPlayingAnymore": "{{icon}} **Oops!**\nThis track has been skipped or is no longer playing."
|
||||
}
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
import Resources from './resources';
|
||||
|
||||
declare module 'i18next' {
|
||||
interface CustomTypeOptions {
|
||||
defaultNS: 'bot';
|
||||
resources: Resources;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,409 @@
|
||||
{
|
||||
"autocomplete": {
|
||||
"trackName": "{{title}} [Artist: {{author}}]"
|
||||
},
|
||||
"commands": {
|
||||
"back": {
|
||||
"metadata": {
|
||||
"name": "back",
|
||||
"description": "Gå tilbake til forrige låt eller angitt posisjon i historikken.",
|
||||
"options": {
|
||||
"position": {
|
||||
"name": "posisjon",
|
||||
"description": "Posisjon for låt i historikken å gå tilbake til."
|
||||
}
|
||||
}
|
||||
},
|
||||
"trackHistoryEmpty": "{{icon}} **Oi sann!**\nHistorikken er tom, legg til noen låter med {{playCommand}}!",
|
||||
"trackPositionHigherThanHistoryLength_one": "{{icon}} **Oi sann!**\nDet er bare **1** låt i historikken. Du kan ikke gå tilbake til posisjon **{{backPosition}}**.\n\nVis låter lagt til i historikken med {{historyCommand}}.",
|
||||
"trackPositionHigherThanHistoryLength": "{{icon}} **Oi sann!**\nDet er bare **{{count}}** låter i historikken. Du kan ikke gå tilbake til posisjon **{{backPosition}}**.\n\nVis låter lagt til i historikken med {{historyCommand}}.",
|
||||
"trackRecovered": "{{icon}} **Gjenopprettet låt**\n{{track}}"
|
||||
},
|
||||
"filters": {
|
||||
"metadata": {
|
||||
"name": "filters",
|
||||
"description": "Velg mellom ulike lydfiltre.",
|
||||
"options": {
|
||||
"type": {
|
||||
"name": "type",
|
||||
"description": "Type lydfilter å bruke.",
|
||||
"choices": {
|
||||
"ffmpeg": "FFmpeg",
|
||||
"biquad": "Biquad",
|
||||
"equalizer": "Equalizer",
|
||||
"disable": "Deaktivert"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"allFiltersDisabled": "{{icon}} **Deaktiverte lydfiltre**\nAlle lydfiltre har blitt deaktivert.",
|
||||
"disableAllFiltersButton": "Deaktiver alle lydfiltre",
|
||||
"nowUsingFilters": "{{icon}} **Lydfiltre aktivert**\nBruker nå disse {{mode}} filtrene:",
|
||||
"selectFilterPlaceholder": "Velg et lydfilter fra menyen.",
|
||||
"selectFilterPlaceholderMany": "Velg ett eller flere lydfiltre.",
|
||||
"toggleFilterInstructions": "**Juster filtre ({{provider}})**\nAktiver eller deaktiver lydfiltre fra menyen."
|
||||
},
|
||||
"guilds": {
|
||||
"metadata": {
|
||||
"name": "guilds",
|
||||
"description": "Vis de 25 største serverne etter medlemstall."
|
||||
},
|
||||
"topGuildsByMemberCount": "{{icon}} **Topp {{count}} servere etter medlemstall ({{totalCount}} totalt)**",
|
||||
"totalMembers": "**Totalt antall medlemmer:** **`{{count}`**"
|
||||
},
|
||||
"help": {
|
||||
"metadata": {
|
||||
"name": "help",
|
||||
"description": "Vis listen over bot-kommandoer."
|
||||
},
|
||||
"addBotButton": "Legg til bot",
|
||||
"listTitle": "{{icon}} **Liste over kommandoer**",
|
||||
"supportServerButton": "Støtteserver"
|
||||
},
|
||||
"history": {
|
||||
"metadata": {
|
||||
"name": "history",
|
||||
"description": "Vis historikk over låter som har blitt spilt.",
|
||||
"options": {
|
||||
"page": {
|
||||
"name": "side",
|
||||
"description": "Sidenummer for å vise for historikken."
|
||||
}
|
||||
}
|
||||
},
|
||||
"emptyHistory": "Historikken er tom, legg til noen låter med {{playCommand}}!",
|
||||
"invalidPageNumber_one": "{{icon}} **Oi sann!**\nSide **`{{page}}`** er ikke et gyldig sidenummer.\n\nDet er bare **`1`** side i historikken.",
|
||||
"invalidPageNumber": "{{icon}} **Oi sann!**\nSide **`{{page}}`** er ikke et gyldig sidenummer.\n\nDet er totalt bare **`{{count}}`** sider i historikken.",
|
||||
"tracksInHistoryTitle": "{{icon}} **Låter i historikken**"
|
||||
},
|
||||
"join": {
|
||||
"metadata": {
|
||||
"name": "join",
|
||||
"description": "Botten vil bli med i talekanalen hvis den ikke allerede er i en."
|
||||
},
|
||||
"alreadyConnected": "{{icon}} **Oi sann!**\nJeg er allerede koblet til talekanalen {{channel}}.\n\nFor å koble meg fra kanalen, bruk kommandoen {{leaveCommand}}.",
|
||||
"couldNotJoin": "{{icon}} **Oi sann!**\nKunne ikke bli med i talekanalen, vennligst prøv igjen.",
|
||||
"joinedChannel": "{{icon}} **Ble med i kanal**\nKoblet til talekanalen: {{channel}}\n\nFor å legge til låter, bruk kommandoen {{playCommand}}!"
|
||||
},
|
||||
"leave": {
|
||||
"metadata": {
|
||||
"name": "leave",
|
||||
"description": "Tøm køen og fjern botten fra talekanalen."
|
||||
},
|
||||
"leavingChannel": "{{icon}} **Koblet fra kanal**\nTømte låtkøen og koblet fra talekanalen.\n\nFor å spille mer musikk, bruk kommandoen {{playCommand}}!"
|
||||
},
|
||||
"loop": {
|
||||
"metadata": {
|
||||
"name": "loop",
|
||||
"description": "Velg mellom å spille en låt på reptisjon, hele køen eller autoplay.",
|
||||
"options": {
|
||||
"mode": {
|
||||
"name": "modus",
|
||||
"description": "Loop-modus: Låt, kø, autoplay eller deaktivert.",
|
||||
"choices": {
|
||||
"0": "Deaktivert",
|
||||
"1": "Låt",
|
||||
"2": "Kø",
|
||||
"3": "Autoplay"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"alreadySet": "{{icon}} **Oi sann!**\nLoop-modus er allerede satt til **`{{mode}}`**.",
|
||||
"loopModeInformation": "{{icon}} **Nåværende loop-modus**\nLoop-modusen er for øyeblikket satt til **`{{mode}}`**.",
|
||||
"modeChanged": "{{icon}} **Endret loop-modus**\nEndrer loop-modus fra **`{{fromName}}`** til **`{{toName}}`**.",
|
||||
"willAutoplay": "Når køen er tom, vil lignende låter begynne å spille!",
|
||||
"willNoLongerPlay": "{{mode}} vil ikke lenger spille på repeat!",
|
||||
"willNowPlay": "{{mode}} vil nå spille på repeat!"
|
||||
},
|
||||
"lyrics": {
|
||||
"metadata": {
|
||||
"name": "lyrics",
|
||||
"description": "Søk etter Genius sangtekster for nåværende eller angitt låt.",
|
||||
"options": {
|
||||
"query": {
|
||||
"name": "søk",
|
||||
"description": "Søkespørring etter tekst eller URL."
|
||||
}
|
||||
}
|
||||
},
|
||||
"autocompleteSearchResult": "{{title}} [Artist: {{artist}}]",
|
||||
"lyricsEmbed": "{{icon}} **Viser sangtekster**\n**Låt: [{{trackTitle}}]({{trackUrl}})**\n**Artist: [{{artistName}}]({{artistUrl}})**",
|
||||
"noLyricsFound": "{{icon}} **Ingen sangtekster funnet**\nDet ble ikke funnet noen Genius sangtekster for låten **{{query}}**."
|
||||
},
|
||||
"move": {
|
||||
"metadata": {
|
||||
"name": "move",
|
||||
"description": "Flytt en låt til en spesifisert posisjon i køen.",
|
||||
"options": {
|
||||
"from": {
|
||||
"name": "fra",
|
||||
"description": "Posisjonen til låten som skal flyttes."
|
||||
},
|
||||
"to": {
|
||||
"name": "til",
|
||||
"description": "Posisjonen for å flytte låten til."
|
||||
}
|
||||
}
|
||||
},
|
||||
"trackMoved": "{{icon}} **Flyttet låten**\n{track}\n\nLåten har blitt flyttet fra posisjon **`{{fromPosition}}`** til posisjon **`{{toPosition}}`** i køen.",
|
||||
"trackPositionHigherThanQueueLength_one": "{{icon}} **Oi sann!**\nDu kan ikke flytte låten i posisjon **`{{fromPosition}}`** til posisjon **`{{toPosition}}`** i køen. Det er bare **`1`** låt i køen.\n\nVis låter lagt til i køen med {{queueCommand}}.",
|
||||
"trackPositionHigherThanQueueLength": "{{icon}} **Oi sann!**\nDu kan ikke flytte låten i posisjon **`{{fromPosition}}`** til posisjon **`{{toPosition}}`** i køen. Det er bare **`{{count}}`** låter i køen.\n\nVis låter lagt til i køen med {{queueCommand}}."
|
||||
},
|
||||
"nowplaying": {
|
||||
"metadata": {
|
||||
"name": "nowplaying",
|
||||
"description": "Vis informasjon om nåværende låt."
|
||||
},
|
||||
"embedFields": {
|
||||
"author": "**Artist**",
|
||||
"plays": "**Avspillinger**",
|
||||
"source": "**Kilde for låt**"
|
||||
},
|
||||
"otherTracksInQueue_one": "1 annen låt i køen...",
|
||||
"otherTracksInQueue": "{{count}} andre låter i køen...",
|
||||
"playCount_zero": "Ukjent",
|
||||
"playCount": "{{count, number}}"
|
||||
},
|
||||
"pause": {
|
||||
"metadata": {
|
||||
"name": "pause",
|
||||
"description": "Pause eller gjenoppta nåværende låt."
|
||||
},
|
||||
"pauseConfirmation": "{{icon}} **Pauset låten**",
|
||||
"resumeConfirmation": "{{icon}} **Gjenopptok låten**",
|
||||
"directSource": "Direkte kilde"
|
||||
},
|
||||
"play": {
|
||||
"metadata": {
|
||||
"name": "play",
|
||||
"description": "Legg til en låt eller spilleliste i køen ved søkespørring eller URL.",
|
||||
"options": {
|
||||
"query": {
|
||||
"name": "spørring",
|
||||
"description": "Søkespørring ved tekst eller URL."
|
||||
}
|
||||
}
|
||||
},
|
||||
"addedToQueueTitle": "{{icon}} **Lagt til i køen**",
|
||||
"playlistAddedTitle": "{{icon}} **Lagt til spilleliste i køen**",
|
||||
"playlistAddedTrackCount_one": "Og **1** til låt... Bruk {{queueCommand}} for å se alle.",
|
||||
"playlistAddedTrackCount": "Og **{{count}}** flere låter... Bruk {{queueCommand}} for å se alle.",
|
||||
"playlistTooLarge": "{{icon}} **Spilleliste for stor**\nDenne spillelisten er for stor til å legges til i køen.\n\nMaksimalt antall låter som kan legges til i køen er **{{count}}**.",
|
||||
"trackNotFound": "{{icon}} **Ingen låter funnet**\nIngen resultater funnet for **{{query}}**.\n\nHvis du angav en URL, vær sikker på at den er gyldig og offentlig."
|
||||
},
|
||||
"queue": {
|
||||
"metadata": {
|
||||
"name": "queue",
|
||||
"description": "Vis låter som har blitt lagt til i køen.",
|
||||
"options": {
|
||||
"page": {
|
||||
"name": "side",
|
||||
"description": "Sidenummer for å vise for køen."
|
||||
}
|
||||
}
|
||||
},
|
||||
"tracksInQueueTitle": "{{icon}} **Låter i køen**",
|
||||
"emptyQueue": "Køen er tom, legg til noen låter med {{playCommand}}!",
|
||||
"estimatedDuration": "Estimert tid igjen: {{duration}}",
|
||||
"estimatedReallyLongTime": "Estimert tid igjen: Veldig lang tid",
|
||||
"invalidPageNumber_one": "{{icon}} **Oi sann!**\nSide **`{{page}}`** er ikke et gyldig sidenummer.\n\nDet er bare **`1`** side i køen.",
|
||||
"invalidPageNumber": "{{icon}} **Oi sann!**\nSide **`{{page}}`** er ikke et gyldig sidenummer.\n\nDet er totalt bare **`{{count}}`** sider i køen."
|
||||
},
|
||||
"reload": {
|
||||
"metadata": {
|
||||
"name": "reload",
|
||||
"description": "Last inn bot-kommandoer, autocompletion og component interaksjoner på nytt på tvers av shards."
|
||||
},
|
||||
"reloadedCommands": "{{icon}} **Kommandoer lastet inn på nytt**",
|
||||
"unableToReload": "{{icon}} **Oi sann!**\n_Hmm..._ Det ser ut til at jeg ikke klarer å laste inn interaksjoner og kommandoer på tvers av shards."
|
||||
},
|
||||
"remove": {
|
||||
"noTracksRemoved": "{{icon}} **Ingen låter fjernet**\nDet ble ikke fjernet noen låter fra køen. Vennligst sjekk om alternativet du valgte har låter som kan fjernes.",
|
||||
"removedTrack": "{{icon}} **Fjernet låt**",
|
||||
"removedTracks": "{{icon}} **Fjernet låter**\n**`{{count}}`** låter ble fjernet fra køen.",
|
||||
"startPositionHigherThanEndPosition": "{{icon}} **Oi sann!**\nStartposisjon **`{{start}}`** er høyere enn siste posisjon **`{{end}}`** i køen. Vennligst spesifiser et gyldig område.\n\nVis låter lagt til i køen med {{queueCommand}}.",
|
||||
"trackPositionHigherThanQueueLength_one": "{{icon}} **Oi sann!**\nPosisjon **`{{position}}`** er ikke en gyldig køposisjon. Det er bare **`1`** låt i køen.\n\nVis låter lagt til i køen med {{queueCommand}}.",
|
||||
"trackPositionHigherThanQueueLength": "{{icon}} **Oi sann!**\nPosisjon **`{{position}}`** er ikke en gyldig køposisjon. Det er bare **`{{count}}`** låter i køen.\n\nVis låter lagt til i køen med {{queueCommand}}."
|
||||
},
|
||||
"seek": {
|
||||
"metadata": {
|
||||
"name": "seek",
|
||||
"description": "Spol til tidsposisjon i nåværende låt.",
|
||||
"options": {
|
||||
"duration": {
|
||||
"name": "varighet",
|
||||
"description": "Tidsstempel i format 00:00:00 (TT:mm:ss)."
|
||||
}
|
||||
}
|
||||
},
|
||||
"correctFormatInstruction": "{{icon}} **Oi sann!**\nDu anga et ugyldig varighetsformat, **`{{wrongDuration}}`**.\nVennligst bruk formatet **`TT:mm:ss`**, **`mm:ss`** eller **`ss`**.\n\n**Eksempler:**\n- **`/seek`** **`1:24:12`** - Spol til 1 time, 24 minutter og 12 sekunder.\n- **`/seek`** **`3:27`** - Spol til 3 minutter og 27 sekunder.\n- **`/seek`** **`42`** - Spol til 42 sekunder.",
|
||||
"durationLongerThanTrackDuration": "{{icon}} **Oi sann!**\nDu anga **`{{wrongDuration}}`**, som er et tidsstempel lengre enn varigheten av nåværende låt.\n\nVennligst prøv et tidsstempel som er mindre enn varigheten til låten (**{{trackDuration}}**).",
|
||||
"seekingToTimestamp": "{{icon}} **Spoler til tidsposisjon**\nSpoler til **`{{duration}}`** i nåværende låt."
|
||||
},
|
||||
"shards": {
|
||||
"metadata": {
|
||||
"name": "shards",
|
||||
"description": "Vis informasjon om alle tilkoblede shards.",
|
||||
"options": {
|
||||
"sort": {
|
||||
"name": "sorter",
|
||||
"description": "Hva shards skal sorteres etter.",
|
||||
"choices": {
|
||||
"none": "Ingen (Shard ID)",
|
||||
"memory": "Minnebruk",
|
||||
"connections": "Taleforbindelser",
|
||||
"tracks": "Låter",
|
||||
"listeners": "Lyttere",
|
||||
"guilds": "Servere",
|
||||
"members": "Medlemmer"
|
||||
}
|
||||
},
|
||||
"page": {
|
||||
"name": "side",
|
||||
"description": "Sidenummer for å vise for shards."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"shuffle": {
|
||||
"metadata": {
|
||||
"name": "shuffle",
|
||||
"description": "Tilfeldig stokk om rekkefølgen til alle låter i køen."
|
||||
},
|
||||
"shuffledTracks": "{{icon}} **Stokket om rekkefølge**\n**{{count}}** låter i køen har blitt stokket om.\n\nVis den nye kørekkefølgen med {{queueCommand}}."
|
||||
},
|
||||
"skip": {
|
||||
"metadata": {
|
||||
"name": "skip",
|
||||
"description": "Hopp over låt til neste eller angitt posisjon i køen.",
|
||||
"options": {
|
||||
"position": {
|
||||
"name": "posisjon",
|
||||
"description": "Posisjon i køen for låt som skal hoppes til."
|
||||
}
|
||||
}
|
||||
},
|
||||
"emptyQueue": "{{icon}} **Oi sann!**\nKøen er tom, legg til noen låter med {{playCommand}}!",
|
||||
"skippedTrack": "{{icon}} **Hoppet over låt**",
|
||||
"trackPositionHigherThanQueueLength_one": "{{icon}} **Oi sann!**\nDet er bare **1** låt i køen. Du kan ikke hoppe til posisijon **{{position}}** i køen.\n\nVis låter lagt til i køen med {{queueCommand}}.",
|
||||
"trackPositionHigherThanQueueLength": "{{icon}} **Oi sann!**\nDet er bare **{{count}}** låter i køen. Du kan ikke hoppe til posisjon **{{position}}** i køen.\n\nVis låter lagt til i køen med {{queueCommand}}."
|
||||
},
|
||||
"status": {
|
||||
"metadata": {
|
||||
"name": "status",
|
||||
"description": "Vis driftsstatus for botten."
|
||||
}
|
||||
},
|
||||
"stop": {
|
||||
"metadata": {
|
||||
"name": "stop",
|
||||
"description": "Tøm køen og slutt å spille lyd."
|
||||
},
|
||||
"stoppedPlaying": "{{icon}} **Stoppet å spille**\nStoppet å spille lyd og tømte køen.\n\nFor å spille mer musikk, bruk kommandoen {{playCommand}}!"
|
||||
},
|
||||
"systemstatus": {
|
||||
"metadata": {
|
||||
"name": "systemstatus",
|
||||
"description": "Vis driftsstatus for botten med ytterligere teknisk informasjon."
|
||||
}
|
||||
},
|
||||
"volume": {
|
||||
"metadata": {
|
||||
"name": "volume",
|
||||
"description": "Vis eller endre avspillingsvolumet for låter.",
|
||||
"options": {
|
||||
"percentage": {
|
||||
"name": "prosent",
|
||||
"description": "Volumprosent: Fra 1% til 100%."
|
||||
}
|
||||
}
|
||||
},
|
||||
"invalidVolumeRange": "{{icon}} **Oi sann!**\nDu kan ikke sette volumet til **`{{wrongVolume}}%`**, vennligst velg en verdi mellom **`1%`** og **`100%`**.",
|
||||
"volumeChanged": "{{icon}} **Volum endret**\nAvspillingsvolumet er endret til **`{{volume}}%`**.",
|
||||
"volumeInformation": "{{icon}} **Avspillingsvolum**\nAvspillingsvolumet er for øyeblikket satt til **`{{volume}}`**.",
|
||||
"volumeMuted": "{{icon}} **Lyd dempet**\nAvspillingslyden er dempet, fordi volumet ble satt til **`0%`**."
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"responses": {
|
||||
"paused": "Pauset låt",
|
||||
"resumed": "Gjenopptok låt"
|
||||
}
|
||||
},
|
||||
"musicPlayerCommon": {
|
||||
"controls": {
|
||||
"stop": "Stopp",
|
||||
"previous": "Forrige",
|
||||
"pause": "Pause",
|
||||
"resume": "Gjenoppta",
|
||||
"skip": "Hopp over"
|
||||
},
|
||||
"footerPageNumber_one": "Side {{page}} av {{pageCount}} (1 låt)",
|
||||
"footerPageNumber": "Side {{page}} av {{pageCount}} ({{count}} låter)",
|
||||
"loopingInfo": "{{icon}} **Looping aktivert**\nLoop-modus er satt til **`{{loopMode}}`**. Du kan endre det med {{loopCommand}}.\n",
|
||||
"nowPausedTitle": "{{icon}} **For øyeblikket pauset**",
|
||||
"nowPlayingTitle": "{{icon}} **Spiller nå**",
|
||||
"playingLive": "{{icon}} **`DIREKTE`** - Spiller kontinuerlig fra direktekilde.",
|
||||
"queueRepeatMode": {
|
||||
"off": "Deaktivert",
|
||||
"track": "Låt",
|
||||
"queue": "Kø",
|
||||
"autoplay": "Autoplay"
|
||||
},
|
||||
"requestedBy": "**Forespurt av:** {{user}}",
|
||||
"unavailableAuthor": "Ikke tilgjengelig",
|
||||
"unavailableDuration": "_Ingen varighet tilgjengelig._",
|
||||
"unavailableRequestedBy": "Ikke tilgjengelig",
|
||||
"unavailableTrackTitle": "Tittel ikke tilgjengelig",
|
||||
"unavailableTrackUrl": "**Ikke tilgjengelig**",
|
||||
"unavailableSource": "Ikke tilgjengelig",
|
||||
"voiceChannelInfo": "Kanal: {{channel}} ({{bitrate}}kbps)"
|
||||
},
|
||||
"statistics": {
|
||||
"botStatus": {
|
||||
"title": "{{icon}} **Bot status**",
|
||||
"joinedServers": "**{{count}}** Tilkoblede servere",
|
||||
"joinedServers_one": "**1** Tilkoblet server",
|
||||
"totalMembers": "**{{count}}** Totalt antall medlemmer",
|
||||
"releaseVersion": "**{{version}}** Utgivelsesversjon"
|
||||
},
|
||||
"queueStatus": {
|
||||
"title": "{{icon}} **Køstatus**",
|
||||
"voiceConnections": "**{{count}}** Taleforbindelser",
|
||||
"voiceConnections_one": "**1** Taleforbindelse",
|
||||
"tracksInQueues": "**{{count}}** Låter i køer",
|
||||
"tracksInQueues_one": "**1** Låt i køer",
|
||||
"usersListening": "**{{count}}** Lyttere",
|
||||
"usersListening_one": "**1** Lytter"
|
||||
},
|
||||
"systemStatus": {
|
||||
"title": "{{icon}} **Systemstatus**",
|
||||
"uptime": "**{{value}}** Oppetid",
|
||||
"cpu": "**{{value, number(minimumFractionDigits: 2)}}%** CPU-bruk",
|
||||
"cpuDetailed": "**{{usage}}% @ {{cores}} kjerner** CPU-bruk",
|
||||
"memory": "**{{value, number}} MB** Minnebruk",
|
||||
"memoryDetailed": "**{{used, number}} / {{total, number}} MB** Minnebruk",
|
||||
"platform": "**{{value}}** Plattform"
|
||||
},
|
||||
"discordStatus": {
|
||||
"title": "{{icon}} **Discord-status**",
|
||||
"apiLatency": "**{{value, number}} ms** Discord API forsinkelse"
|
||||
},
|
||||
"dependencies": {
|
||||
"title": "{{icon}} **Avhengigheter**"
|
||||
}
|
||||
},
|
||||
"validation": {
|
||||
"cannotJoinVoiceOrTalk": "{{icon}} **Oi sann!**\nJeg har ikke tillatelse til å spille lyd i talekanalen {{channel}}.\n\nVær sikker på at jeg har **`Koble til`** og **`Snakke`** tillatelsene i denne talekanalen.",
|
||||
"cannotSendMessageInChannel": "{{icon}} **Oi sann!**\nJeg har ikke tillatelse til å sende meldingssvar i kanalen {{channel}}.\n\nVær sikker på at jeg har **`Se Kanal`** tillatelsen i denne tekstkanalen.",
|
||||
"historyDoesNotExist": "{{icon}} **Oi sann!**\nDet er ingen låter i historikken og ingenting spilles av for øyeblikket. Legg først til noen låter med {{playCommand}}!",
|
||||
"notInSameVoiceChannel": "{{icon}} **Ikke i samme talekanal**\nDu må være i samme talekanal som meg for å utføre denne handlingen.\n\n**Talekanal:** {{channel}}",
|
||||
"notInVoiceChannel": "{{icon}} **Ikke i en talekanal**\nDu må være i en talekanal for å utføre denne handlingen.",
|
||||
"notValidGuildId": "{{icon}} **Oi sann!**\nIngen tillatelse til å utføre denne handlingen.\n\nKommandoen {{command}} kan ikke utføres på denne serveren.",
|
||||
"queueDoesNotExist": "{{icon}} **Oi sann!**\nDet er ingen låter i køen og ingenting spilles av for øyeblikket. Legg først til noen låter med {{playCommand}}!",
|
||||
"queueIsEmpty": "{{icon}} **Oi sann!\nDet er ingen låter lagt til i køen. Legg først til noen låter med {{playCommand}}!",
|
||||
"queueNoCurrentTrack": "{{icon}} **Oi sann!**\nDet spilles ingenting av for øyeblikket. Legg først til noen låter med {{playCommand}}!",
|
||||
"trackNotPlayingAnymore": "{{icon}} **Oi sann!**\nDenne låten har blitt hoppet over allerede eller spiller ikke lenger."
|
||||
}
|
||||
}
|
||||
Vendored
+413
@@ -0,0 +1,413 @@
|
||||
interface Resources {
|
||||
bot: {
|
||||
autocomplete: {
|
||||
trackName: '{{title}} [Author: {{author}}]';
|
||||
};
|
||||
commands: {
|
||||
back: {
|
||||
metadata: {
|
||||
name: 'back';
|
||||
description: 'Go back to previous track or specified position in history.';
|
||||
options: {
|
||||
position: {
|
||||
name: 'position';
|
||||
description: 'The position in history to go back to.';
|
||||
};
|
||||
};
|
||||
};
|
||||
trackHistoryEmpty: '{{icon}} **Oops!**\nThe history is empty, add some tracks with {{playCommand}}!';
|
||||
trackPositionHigherThanHistoryLength_one: '{{icon}} **Oops!**\nThere is only **1** track in the history. You cannot go back to track **{{backPosition}}**.\n\nView tracks added in the history with {{historyCommand}}.';
|
||||
trackPositionHigherThanHistoryLength: '{{icon}} **Oops!**\nThere are only **{{count}}** tracks in the history. You cannot go back to track **{{backPosition}}**.\n\nView tracks added in the history with {{historyCommand}}.';
|
||||
trackRecovered: '{{icon}} **Recovered track**\n{{track}}';
|
||||
};
|
||||
filters: {
|
||||
metadata: {
|
||||
name: 'filters';
|
||||
description: 'Toggle various audio filters.';
|
||||
options: {
|
||||
type: {
|
||||
name: 'type';
|
||||
description: 'Audio filter type to use.';
|
||||
choices: {
|
||||
ffmpeg: 'FFmpeg';
|
||||
biquad: 'Biquad';
|
||||
equalizer: 'Equalizer';
|
||||
disable: 'Disable';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
allFiltersDisabled: '{{icon}} **Disabled filters**\nAll audio filters have been disabled.';
|
||||
disableAllFiltersButton: 'Disable all filters';
|
||||
nowUsingFilters: '{{icon}} **Filters toggled**\nNow using these {{mode}} filters:';
|
||||
selectFilterPlaceholder: 'Select a filter from the menu.';
|
||||
selectFilterPlaceholderMany: 'Select one or multiple filters.';
|
||||
toggleFilterInstructions: '**Toggle filters ({{provider}})**\nEnable or disable audio filters for playback from the menu.';
|
||||
};
|
||||
guilds: {
|
||||
metadata: {
|
||||
name: 'guilds';
|
||||
description: 'Show the top 25 guilds by member count.';
|
||||
};
|
||||
topGuildsByMemberCount: '{{icon}} **Top {{count}} guilds by member count ({{totalCount}} total)**';
|
||||
totalMembers: '**Total members:** **`{{count}`**';
|
||||
};
|
||||
help: {
|
||||
metadata: {
|
||||
name: 'help';
|
||||
description: 'Show the list of bot commands.';
|
||||
};
|
||||
addBotButton: 'Add bot';
|
||||
listTitle: '{{icon}} **List of commands**';
|
||||
supportServerButton: 'Support server';
|
||||
};
|
||||
history: {
|
||||
metadata: {
|
||||
name: 'history';
|
||||
description: 'Show history of tracks that have been played.';
|
||||
options: {
|
||||
page: {
|
||||
name: 'page';
|
||||
description: 'Page number to display for the history.';
|
||||
};
|
||||
};
|
||||
};
|
||||
emptyHistory: 'The history is empty, add some tracks with {{playCommand}}!';
|
||||
invalidPageNumber_one: '{{icon}} **Oops!**\nPage **`{{page}}`** is not a valid page number.\n\nThere is only **`1`** page in the history.';
|
||||
invalidPageNumber: '{{icon}} **Oops!**\nPage **`{{page}}`** is not a valid page number.\n\nThere are only a total of **`{{count}}`** pages in the history.';
|
||||
tracksInHistoryTitle: '{{icon}} **Tracks in history**';
|
||||
};
|
||||
join: {
|
||||
metadata: {
|
||||
name: 'join';
|
||||
description: 'The bot will join the voice channel if not already in one.';
|
||||
};
|
||||
alreadyConnected: '{{icon}} **Oops!**\nI am already connected to the {{channel}} voice channel.\n\nTo disconnect me from the channel, use the {{leaveCommand}} command.';
|
||||
couldNotJoin: '{{icon}} **Oops!**\nCould not join voice channel, please try again.';
|
||||
joinedChannel: '{{icon}} **Joined channel**\nConnected to voice channel: {{channel}}\n\nTo add tracks, use the {{playCommand}} command!';
|
||||
};
|
||||
leave: {
|
||||
metadata: {
|
||||
name: 'leave';
|
||||
description: 'Clear the queue and remove bot from voice channel.';
|
||||
};
|
||||
leavingChannel: '{{icon}} **Leaving channel**\nCleared the track queue and left voice channel.\n\nTo play more music, use the {{playCommand}} command!';
|
||||
};
|
||||
loop: {
|
||||
metadata: {
|
||||
name: 'loop';
|
||||
description: 'Toggle looping a track, the whole queue or autoplay.';
|
||||
options: {
|
||||
mode: {
|
||||
name: 'mode';
|
||||
description: 'Loop mode: Track, queue, autoplay or disabled.';
|
||||
choices: {
|
||||
'0': 'Off';
|
||||
'1': 'Track';
|
||||
'2': 'Queue';
|
||||
'3': 'Autoplay';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
alreadySet: '{{icon}} **Oops!**\nLoop mode is already **`{{mode}}`**.';
|
||||
loopModeInformation: '{{icon}} **Current loop mode**\nThe looping mode is currently set to **`{{mode}}`**.';
|
||||
modeChanged: '{{icon}} **Loop mode changed**\nChanging loop mode from **`{{fromName}}`** to **`{{toName}}`**.';
|
||||
willAutoplay: 'When the queue is empty, similar tracks will start playing!';
|
||||
willNoLongerPlay: 'The {{mode}} will no longer play on repeat!';
|
||||
willNowPlay: 'The {{mode}} will now play on repeat!';
|
||||
};
|
||||
lyrics: {
|
||||
metadata: {
|
||||
name: 'lyrics';
|
||||
description: 'Search Genius lyrics for current or specified track.';
|
||||
options: {
|
||||
query: {
|
||||
name: 'query';
|
||||
description: 'Search query by text or URL.';
|
||||
};
|
||||
};
|
||||
};
|
||||
autocompleteSearchResult: '{{title}} [Artist: {{artist}}]';
|
||||
lyricsEmbed: '{{icon}} **Showing lyrics**\n**Track: [{{trackTitle}}]({{trackUrl}})**\n**Artist: [{{artistName}}]({{artistUrl}})**';
|
||||
noLyricsFound: '{{icon}} **No lyrics found**\nThere were no Genius lyrics found for track **{{query}}**.';
|
||||
};
|
||||
move: {
|
||||
metadata: {
|
||||
name: 'move';
|
||||
description: 'Move a track to a specified position in queue.';
|
||||
options: {
|
||||
from: {
|
||||
name: 'from';
|
||||
description: 'The position of the track to move.';
|
||||
};
|
||||
to: {
|
||||
name: 'to';
|
||||
description: 'The position to move the track to.';
|
||||
};
|
||||
};
|
||||
};
|
||||
trackMoved: '{{icon}} **Moved track**\n{track}\n\nTrack has been moved from position **`{{fromPosition}}`** to position **`{{toPosition}}`**.';
|
||||
trackPositionHigherThanQueueLength_one: '{{icon}} **Oops!**\nYou cannot move the track in position **`{{fromPosition}}`** to position **`{{toPosition}}`**. There is only **`1`** track in the queue.\n\nView tracks added to the queue with {{queueCommand}}.';
|
||||
trackPositionHigherThanQueueLength: '{{icon}} **Oops!**\nYou cannot move the track in position **`{{fromPosition}}`** to position **`{{toPosition}}`**. There are only **`{{count}}`** tracks in the queue.\n\nView tracks added to the queue with {{queueCommand}}.';
|
||||
};
|
||||
nowplaying: {
|
||||
metadata: {
|
||||
name: 'nowplaying';
|
||||
description: 'Show information about the current track.';
|
||||
};
|
||||
embedFields: {
|
||||
author: '**Artist**';
|
||||
plays: '**Plays**';
|
||||
source: '**Track source**';
|
||||
};
|
||||
otherTracksInQueue_one: '1 other track in the queue...';
|
||||
otherTracksInQueue: '{{count}} other tracks in the queue...';
|
||||
playCount_zero: 'Unknown';
|
||||
playCount: '{{count, number}}';
|
||||
};
|
||||
pause: {
|
||||
metadata: {
|
||||
name: 'pause';
|
||||
description: 'Toggle pause for the current track.';
|
||||
};
|
||||
pauseConfirmation: '{{icon}} **Paused track**';
|
||||
resumeConfirmation: '{{icon}} **Resumed track**';
|
||||
directSource: 'Direct source';
|
||||
};
|
||||
play: {
|
||||
metadata: {
|
||||
name: 'play';
|
||||
description: 'Add a track or playlist to the queue by search query or URL.';
|
||||
options: {
|
||||
query: {
|
||||
name: 'query';
|
||||
description: 'Search query by text or URL.';
|
||||
};
|
||||
};
|
||||
};
|
||||
addedToQueueTitle: '{{icon}} **Added to queue**';
|
||||
playlistAddedTitle: '{{icon}} **Added playlist to queue**';
|
||||
playlistAddedTrackCount_one: 'And **1** more track... Use {{queueCommand}} to view all.';
|
||||
playlistAddedTrackCount: 'And **{{count}}** more tracks... Use {{queueCommand}} to view all.';
|
||||
playlistTooLarge: '{{icon}} **Playlist too large**\nThis playlist is too large to be added to the queue.\n\nThe maximum amount of tracks that can be added to the queue is **{{count}}**.';
|
||||
trackNotFound: '{{icon}} **No track found\nNo results found for **{{query}}**.\n\nIf you specified a URL, please make sure it is valid and public.';
|
||||
};
|
||||
queue: {
|
||||
metadata: {
|
||||
name: 'queue';
|
||||
description: 'Show tracks that have been added to the queue.';
|
||||
options: {
|
||||
page: {
|
||||
name: 'page';
|
||||
description: 'Page number to display for the queue.';
|
||||
};
|
||||
};
|
||||
};
|
||||
tracksInQueueTitle: '{{icon}} **Tracks in queue**';
|
||||
emptyQueue: 'The queue is empty, add some tracks with {{playCommand}}!';
|
||||
estimatedDuration: 'Estimated duration: {{duration}}';
|
||||
estimatedReallyLongTime: 'Estimated duration: A really long time';
|
||||
invalidPageNumber_one: '{{icon}} **Oops!**\nPage **`{{page}}`** is not a valid page number.\n\nThere is only **`1`** page in the queue.';
|
||||
invalidPageNumber: '{{icon}} **Oops!**\nPage **`{{page}}`** is not a valid page number.\n\nThere are only a total of **`{{count}}`** pages in the queue.';
|
||||
};
|
||||
reload: {
|
||||
metadata: {
|
||||
name: 'reload';
|
||||
description: 'Reload slash command, autocomplete and component interactions across shards.';
|
||||
};
|
||||
reloadedCommands: '{{icon}} **Reloaded commands**';
|
||||
unableToReload: '{{icon}} **Oops!**\n_Hmm..._ It seems I am unable to reload the interaction module across shards.';
|
||||
};
|
||||
remove: {
|
||||
noTracksRemoved: '{{icon}} **No tracks removed**\nThere were no tracks removed from the queue. Please check if the option you selected has tracks to remove.';
|
||||
removedTrack: '{{icon}} **Removed track**';
|
||||
removedTracks: '{{icon}} **Removed tracks**\n**`{{count}}`** tracks were removed from the queue.';
|
||||
startPositionHigherThanEndPosition: '{{icon}} **Oops!**\nStart position **`{{start}}`** is higher than end position **`{{end}}`**. Please specify a valid range.\n\nView tracks added to the queue with {{queueCommand}}.';
|
||||
trackPositionHigherThanQueueLength_one: '{{icon}} **Oops!**\nPosition **`{{position}}`** is not a valid track position. There is only a total of **`1`** track in the queue.\n\nView the tracks added to the queue with {{queueCommand}}.';
|
||||
trackPositionHigherThanQueueLength: '{{icon}} **Oops!**\nPosition **`{{position}}`** is not a valid track position. There are only a total of **`{{count}}`** tracks in the queue.\n\nView the tracks added to the queue with {{queueCommand}}.';
|
||||
};
|
||||
seek: {
|
||||
metadata: {
|
||||
name: 'seek';
|
||||
description: 'Seek to a position in the current track.';
|
||||
options: {
|
||||
duration: {
|
||||
name: 'duration';
|
||||
description: 'Timestamp in format 00:00:00 (HH:mm:ss).';
|
||||
};
|
||||
};
|
||||
};
|
||||
correctFormatInstruction: '{{icon}} **Oops!**\nYou entered an invalid duration format, **`{{wrongDuration}}`**.\nPlease use the format **`HH:mm:ss`**, **`mm:ss`** or **`ss`**.\n\n**Examples:**\n- **`/seek`** **`1:24:12`** - Seek to 1 hour, 24 minutes and 12 seconds.\n- **`/seek`** **`3:27`** - Seek to 3 minutes and 27 seconds.\n- **`/seek`** **`42`** - Seek to 42 seconds.';
|
||||
durationLongerThanTrackDuration: '{{icon}} **Oops!**\nYou entered **`{{wrongDuration}}`**, which is a timestamp longer than the duration of the current track.\n\nPlease try a timestamp that is less than the duration of the track (**{{trackDuration}}**).';
|
||||
seekingToTimestamp: '{{icon}} **Seeking to timestamp**\nSeeking to **`{{duration}}`** in current track.';
|
||||
};
|
||||
shards: {
|
||||
metadata: {
|
||||
name: 'shards';
|
||||
description: 'Show information about all connected shards.';
|
||||
options: {
|
||||
sort: {
|
||||
name: 'sort';
|
||||
description: 'What to sort the shards by.';
|
||||
choices: {
|
||||
none: 'None (Shard ID)';
|
||||
memory: 'Memory usage';
|
||||
connections: 'Voice Connections';
|
||||
tracks: 'Tracks';
|
||||
listeners: 'Listeners';
|
||||
guilds: 'Guilds';
|
||||
members: 'Members';
|
||||
};
|
||||
};
|
||||
page: {
|
||||
name: 'page';
|
||||
description: 'Page number to display for the shards.';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
shuffle: {
|
||||
metadata: {
|
||||
name: 'shuffle';
|
||||
description: 'Randomly shuffle all tracks in the queue.';
|
||||
};
|
||||
shuffledTracks: '{{icon}} **Shuffled queue tracks**\nThe **{{count}}** tracks in the queue have been shuffled.\n\nView the new queue order with {{queueCommand}}.';
|
||||
};
|
||||
skip: {
|
||||
metadata: {
|
||||
name: 'skip';
|
||||
description: 'Skip track to next or specified position in queue.';
|
||||
options: {
|
||||
position: {
|
||||
name: 'position';
|
||||
description: 'The position in queue to skip to.';
|
||||
};
|
||||
};
|
||||
};
|
||||
emptyQueue: '{{icon}} **Oops!**\nThe queue is empty, add some tracks with {{playCommand}}!';
|
||||
skippedTrack: '{{icon}} **Skipped track**';
|
||||
trackPositionHigherThanQueueLength_one: '{{icon}} **Oops!**\nThere is only **1** track in the queue. You cannot skip to track **{{position}}**.\n\nView tracks added to the queue with {{queueCommand}}.';
|
||||
trackPositionHigherThanQueueLength: '{{icon}} **Oops!**\nThere are only **{{count}}** tracks in the queue. You cannot skip to track **{{position}}**.\n\nView tracks added to the queue with {{queueCommand}}.';
|
||||
};
|
||||
status: {
|
||||
metadata: {
|
||||
name: 'status';
|
||||
description: 'Show operational status of the bot.';
|
||||
};
|
||||
};
|
||||
stop: {
|
||||
metadata: {
|
||||
name: 'stop';
|
||||
description: 'Clear the queue and stop playing audio.';
|
||||
};
|
||||
stoppedPlaying: '{{icon}} **Stopped playing**\nStopped playing the audio and cleared the track queue.\n\nTo play more music, use the {{playCommand}} command!';
|
||||
};
|
||||
systemstatus: {
|
||||
metadata: {
|
||||
name: 'systemstatus';
|
||||
description: 'Show operational status of the bot with additional technical information.';
|
||||
};
|
||||
};
|
||||
volume: {
|
||||
metadata: {
|
||||
name: 'volume';
|
||||
description: 'Show or change the playback volume for tracks.';
|
||||
options: {
|
||||
percentage: {
|
||||
name: 'percentage';
|
||||
description: 'Volume percentage: From 1% to 100%.';
|
||||
};
|
||||
};
|
||||
};
|
||||
invalidVolumeRange: '{{icon}} **Oops!**\nYou cannot set the volume to **`{{wrongVolume}}%`**, please pick a value between **`1%`** and **`100%`**.';
|
||||
volumeChanged: '{{icon}} **Volume changed**\nPlayback volume has been changed to **`{{volume}}%`**.';
|
||||
volumeInformation: '{{icon}} **Playback volume**\nThe playback volume is currently set to **`{{volume}}`**.';
|
||||
volumeMuted: '{{icon}} **Audio muted**\nPlayback audio has been muted, because the volume was set to **`0%`**.';
|
||||
};
|
||||
};
|
||||
components: {
|
||||
responses: {
|
||||
paused: 'Paused track';
|
||||
resumed: 'Resumed track';
|
||||
};
|
||||
};
|
||||
musicPlayerCommon: {
|
||||
controls: {
|
||||
stop: 'Stop';
|
||||
previous: 'Previous';
|
||||
pause: 'Pause';
|
||||
resume: 'Resume';
|
||||
skip: 'Skip';
|
||||
};
|
||||
footerPageNumber_one: 'Page {{page}} of {{pageCount}} (1 track)';
|
||||
footerPageNumber: 'Page {{page}} of {{pageCount}} ({{count}} tracks)';
|
||||
loopingInfo: '{{icon}} **Looping**\nLoop mode is set to **`{{loopMode}}`**. You can change it with {{loopCommand}}.';
|
||||
nowPausedTitle: '{{icon}} **Currently paused**';
|
||||
nowPlayingTitle: '{{icon}} **Now playing**';
|
||||
playingLive: '{{icon}} **`LIVE`** - Playing continuously from live source.';
|
||||
queueRepeatMode: {
|
||||
off: 'Disabled';
|
||||
track: 'Track';
|
||||
queue: 'Queue';
|
||||
autoplay: 'Autoplay';
|
||||
};
|
||||
requestedBy: '**Requested by:** {{user}}';
|
||||
unavailableAuthor: 'Unavailable';
|
||||
unavailableDuration: '_No duration available._';
|
||||
unavailableRequestedBy: 'Unavailable';
|
||||
unavailableTrackTitle: 'Title unavailable';
|
||||
unavailableTrackUrl: '**Unavailable**';
|
||||
unavailableSource: 'Unavailable';
|
||||
voiceChannelInfo: 'Channel: {{channel}} ({{bitrate}}kbps)';
|
||||
};
|
||||
statistics: {
|
||||
botStatus: {
|
||||
title: '{{icon}} **Bot status**';
|
||||
joinedServers: '**{{count}}** Joined servers';
|
||||
joinedServers_one: '**1** Joined server';
|
||||
totalMembers: '**{{count}}** Total members';
|
||||
releaseVersion: '**{{version}}** Release version';
|
||||
};
|
||||
queueStatus: {
|
||||
title: '{{icon}} **Queue status**';
|
||||
voiceConnections: '**{{count}}** Voice connections';
|
||||
voiceConnections_one: '**1** Voice connection';
|
||||
tracksInQueues: '**{{count}}** Tracks in queues';
|
||||
tracksInQueues_one: '**1** Track in queues';
|
||||
usersListening: '**{{count}}** Users listening';
|
||||
usersListening_one: '**1** User listening';
|
||||
};
|
||||
systemStatus: {
|
||||
title: '{{icon}} **System status**';
|
||||
uptime: '**{{value}}** Uptime';
|
||||
cpu: '**{{value, number(minimumFractionDigits: 2)}}%** CPU usage';
|
||||
cpuDetailed: '**{{usage}}% @ {{cores}} cores** CPU usage';
|
||||
memory: '**{{value, number}} MB** Memory usage';
|
||||
memoryDetailed: '**{{used, number}} / {{total, number}} MB** Memory usage';
|
||||
platform: '**{{value}}** Platform';
|
||||
};
|
||||
discordStatus: {
|
||||
title: '{{icon}} **Discord status**';
|
||||
apiLatency: '**{{value, number}} ms** Discord API latency';
|
||||
};
|
||||
dependencies: {
|
||||
title: '{{icon}} **Dependencies**';
|
||||
};
|
||||
};
|
||||
validation: {
|
||||
cannotJoinVoiceOrTalk: '{{icon}} **Oops!**\nI do not have permission to play audio in the voice channel {{channel}}.\n\nPlease make sure I have the **`Connect`** and **`Speak`** permissions in this voice channel.';
|
||||
cannotSendMessageInChannel: '{{icon}} **Oops!**\nI do not have permission to send message replies in the channel {{channel}}.\n\nPlease make sure I have the **`View Channel`** permission in this text channel.';
|
||||
historyDoesNotExist: '{{icon}} **Oops!**\nThere are no tracks in the history and nothing currently playing. First add some tracks with {{playCommand}}!';
|
||||
notInSameVoiceChannel: '{{icon}} **Not in same voice channel**\nYou need to be in the same voice channel as me to perform this action.\n\n**Voice channel:** {{channel}}';
|
||||
notInVoiceChannel: '{{icon}} **Not in a voice channel**\nYou need to be in a voice channel to perform this action.';
|
||||
notValidGuildId: '{{icon}} **Oops!**\nNo permission to perform this action.\n\nThe command {{command}} cannot be executed in this server.';
|
||||
queueDoesNotExist: '{{icon}} **Oops!**\nThere are no tracks in the queue and nothing currently playing. First add some tracks with {{playCommand}}!';
|
||||
queueIsEmpty: '{{icon}} **Oops!\nThere are no tracks added to the queue. First add some tracks with {{playCommand}}!';
|
||||
queueNoCurrentTrack: '{{icon}} **Oops!**\nThere is nothing currently playing. First add some tracks with {{playCommand}}!';
|
||||
trackNotPlayingAnymore: '{{icon}} **Oops!**\nThis track has been skipped or is no longer playing.';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export default Resources;
|
||||
Generated
+58
@@ -17,6 +17,8 @@
|
||||
"discord-voip": "^0.1.3",
|
||||
"discord.js": "^14.14.1",
|
||||
"dotenv": "^16.3.1",
|
||||
"i18next": "^23.7.9",
|
||||
"i18next-fs-backend": "^2.3.1",
|
||||
"mediaplex": "^0.0.9",
|
||||
"node-os-utils": "^1.3.7",
|
||||
"pino": "^8.16.2",
|
||||
@@ -34,6 +36,7 @@
|
||||
"eslint": "^8.55.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-prettier": "^5.0.1",
|
||||
"i18next-resources-for-ts": "^1.4.0",
|
||||
"jest": "^29.7.0",
|
||||
"prettier": "^3.1.1",
|
||||
"ts-jest": "^29.1.1",
|
||||
@@ -647,6 +650,17 @@
|
||||
"@babel/core": "^7.0.0-0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/runtime": {
|
||||
"version": "7.23.6",
|
||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.6.tgz",
|
||||
"integrity": "sha512-zHd0eUrf5GZoOWVCXp6koAKQTfZV07eit6bGPmJgnZdnSAvvZee6zniW2XMF7Cmc4ISOOnPy3QaSiIJGJkVEDQ==",
|
||||
"dependencies": {
|
||||
"regenerator-runtime": "^0.14.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/template": {
|
||||
"version": "7.22.15",
|
||||
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz",
|
||||
@@ -4036,6 +4050,45 @@
|
||||
"node": ">=10.17.0"
|
||||
}
|
||||
},
|
||||
"node_modules/i18next": {
|
||||
"version": "23.7.11",
|
||||
"resolved": "https://registry.npmjs.org/i18next/-/i18next-23.7.11.tgz",
|
||||
"integrity": "sha512-A/vOkw8vY99YHU9A1Td3I1dcTiYaPnwBWzrpVzfXUXSYgogK3cmBcmop/0cnXPc6QpUWIyqaugKNxRUEZVk9Nw==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://locize.com"
|
||||
},
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://locize.com/i18next.html"
|
||||
},
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/i18next-fs-backend": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/i18next-fs-backend/-/i18next-fs-backend-2.3.1.tgz",
|
||||
"integrity": "sha512-tvfXskmG/9o+TJ5Fxu54sSO5OkY6d+uMn+K6JiUGLJrwxAVfer+8V3nU8jq3ts9Pe5lXJv4b1N7foIjJ8Iy2Gg=="
|
||||
},
|
||||
"node_modules/i18next-resources-for-ts": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/i18next-resources-for-ts/-/i18next-resources-for-ts-1.4.0.tgz",
|
||||
"integrity": "sha512-NesjHO2/4/ogSl5JPD5r1YnfsJLop0J9CKfxCEuwSLNoJY3o7HhXSpnOMFI3HavlyWtKvX9u0XB8qnWBq684pQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.23.2"
|
||||
},
|
||||
"bin": {
|
||||
"i18next-resources-for-ts": "bin/i18next-resources-for-ts.js"
|
||||
}
|
||||
},
|
||||
"node_modules/ieee754": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
|
||||
@@ -6145,6 +6198,11 @@
|
||||
"node": ">= 12.13.0"
|
||||
}
|
||||
},
|
||||
"node_modules/regenerator-runtime": {
|
||||
"version": "0.14.0",
|
||||
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.0.tgz",
|
||||
"integrity": "sha512-srw17NI0TUWHuGa5CFGGmhfNIeja30WMBfbslPNhf6JrqQlLN5gcrvig1oqPxiVaXb0oW0XRKtH6Nngs5lKCIA=="
|
||||
},
|
||||
"node_modules/require-directory": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
|
||||
|
||||
+12
-1
@@ -34,7 +34,15 @@
|
||||
"deploy": "node ./dist/utils/deploySlashCommands.js",
|
||||
"deploy-pretty": "node ./dist/utils/deploySlashCommands.js | pino-pretty --ignore environment,source,module,action,name,context,executionId,executionTime,shardId,guildId,interactionType",
|
||||
"eslint": "eslint ./src",
|
||||
"build": "tsc"
|
||||
"build": "tsc",
|
||||
"toc": "i18next-resources-for-ts interface -i ./locales/en -o ./locales/resources.d.ts"
|
||||
},
|
||||
"nodemonConfig": {
|
||||
"ignore": [
|
||||
"src/**",
|
||||
"logs/**"
|
||||
],
|
||||
"execMap": {}
|
||||
},
|
||||
"dependencies": {
|
||||
"@discord-player/extractor": "^4.4.5",
|
||||
@@ -45,6 +53,8 @@
|
||||
"discord-voip": "^0.1.3",
|
||||
"discord.js": "^14.14.1",
|
||||
"dotenv": "^16.3.1",
|
||||
"i18next": "^23.7.9",
|
||||
"i18next-fs-backend": "^2.3.1",
|
||||
"mediaplex": "^0.0.9",
|
||||
"node-os-utils": "^1.3.7",
|
||||
"pino": "^8.16.2",
|
||||
@@ -62,6 +72,7 @@
|
||||
"eslint": "^8.55.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-prettier": "^5.0.1",
|
||||
"i18next-resources-for-ts": "^1.4.0",
|
||||
"jest": "^29.7.0",
|
||||
"prettier": "^3.1.1",
|
||||
"ts-jest": "^29.1.1",
|
||||
|
||||
+28
-45
@@ -26,6 +26,7 @@ import {
|
||||
BaseSlashCommandReturnType
|
||||
} from '../types/interactionTypes';
|
||||
import { Validator, ValidatorParams } from '../types/utilTypes';
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
abstract class BaseInteraction {
|
||||
embedOptions: EmbedOptions;
|
||||
@@ -72,18 +73,18 @@ abstract class BaseInteraction {
|
||||
return durationFormat;
|
||||
}
|
||||
|
||||
protected getFormattedTrackUrl(track: Track): string {
|
||||
const trackTitle = track.title ?? 'Title unavailable';
|
||||
protected getFormattedTrackUrl(track: Track, translator: TFunction): string {
|
||||
const trackTitle = track.title ?? translator('musicPlayerCommon.unavailableTrackTitle');
|
||||
const trackUrl = track.url ?? track.raw.url;
|
||||
if (!trackTitle || !trackUrl) {
|
||||
return '**Unavailable**';
|
||||
return translator('musicPlayerCommon.unavailableTrackUrl');
|
||||
}
|
||||
return `**[${trackTitle}](${trackUrl})**`;
|
||||
}
|
||||
|
||||
protected getDisplayTrackDurationAndUrl(track: Track): string {
|
||||
protected getDisplayTrackDurationAndUrl(track: Track, translator: TFunction): string {
|
||||
const formattedDuration = this.getFormattedDuration(track);
|
||||
const formattedUrl = this.getFormattedTrackUrl(track);
|
||||
const formattedUrl = this.getFormattedTrackUrl(track, translator);
|
||||
|
||||
return `${formattedDuration} ${formattedUrl}`;
|
||||
}
|
||||
@@ -116,24 +117,27 @@ abstract class BaseInteraction {
|
||||
|
||||
protected getFooterDisplayPageInfo(
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue | GuildQueueHistory
|
||||
queue: GuildQueue | GuildQueueHistory,
|
||||
translator: TFunction
|
||||
): EmbedFooterData {
|
||||
if (!queue.tracks.data.length) {
|
||||
return { text: 'Page 1 of 1 (0 tracks)' };
|
||||
}
|
||||
|
||||
const pageIndex: number = (interaction.options.getInteger('page') || 1) - 1;
|
||||
const totalPages: number = Math.ceil(queue.tracks.data.length / 10) || 1;
|
||||
return {
|
||||
text: `Page ${pageIndex + 1} of ${totalPages} (${queue.tracks.data.length} tracks)`
|
||||
text: translator('musicPlayerCommon.footerPageNumber', {
|
||||
page: pageIndex + 1,
|
||||
pageCount: totalPages,
|
||||
count: queue.tracks.data.length
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
protected getDisplayTrackRequestedBy = (track: Track): string => {
|
||||
return track.requestedBy ? `<@${track.requestedBy.id}>` : 'Unavailable';
|
||||
protected getDisplayTrackRequestedBy = (track: Track, translator: TFunction): string => {
|
||||
return track.requestedBy
|
||||
? `<@${track.requestedBy.id}>`
|
||||
: translator('musicPlayerCommon.unavailableRequestedBy');
|
||||
};
|
||||
|
||||
protected getDisplayQueueProgressBar(queue: GuildQueue): string {
|
||||
protected getDisplayQueueProgressBar(queue: GuildQueue, translator: TFunction): string {
|
||||
const timestamp: PlayerTimestamp = queue.node.getTimestamp()!;
|
||||
let progressBar: string = `**\`${timestamp.current.label}\`** ${queue.node.createProgressBar({
|
||||
queue: false,
|
||||
@@ -145,43 +149,18 @@ abstract class BaseInteraction {
|
||||
})} **\`${timestamp.total.label}\`**`;
|
||||
|
||||
if (Number(queue.currentTrack?.raw.duration) === 0 || queue.currentTrack?.duration === '0:00') {
|
||||
progressBar = '_No duration available._';
|
||||
progressBar = translator('musicPlayerCommon.unavailableDuration');
|
||||
}
|
||||
|
||||
if (queue.currentTrack?.raw.live) {
|
||||
progressBar = `${this.embedOptions.icons.liveTrack} **\`LIVE\`** - Playing continuously from live source.`;
|
||||
progressBar = translator('musicPlayerCommon.playingLive', {
|
||||
icon: this.embedOptions.icons.liveTrack
|
||||
});
|
||||
}
|
||||
|
||||
return progressBar;
|
||||
}
|
||||
|
||||
protected getDisplayRepeatMode(repeatMode: number, state: string = 'info'): string {
|
||||
let loopModeUserString: string;
|
||||
let icon: string;
|
||||
|
||||
switch (repeatMode) {
|
||||
case 1:
|
||||
loopModeUserString = 'track';
|
||||
icon = state === 'info' ? this.embedOptions.icons.loop : this.embedOptions.icons.looping;
|
||||
break;
|
||||
case 2:
|
||||
loopModeUserString = 'queue';
|
||||
icon = state === 'info' ? this.embedOptions.icons.loop : this.embedOptions.icons.looping;
|
||||
break;
|
||||
case 3:
|
||||
loopModeUserString = 'autoplay';
|
||||
icon = state === 'info' ? this.embedOptions.icons.autoplay : this.embedOptions.icons.autoplaying;
|
||||
break;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
||||
return (
|
||||
`**${icon} Looping**\n` +
|
||||
`Loop mode is set to **\`${loopModeUserString}\`**. You can change it with **\`/loop\`**.\n\n`
|
||||
);
|
||||
}
|
||||
|
||||
abstract execute(
|
||||
params: BaseInteractionParams
|
||||
): Promise<Message<boolean> | ApplicationCommandOptionChoiceData | void>;
|
||||
@@ -210,11 +189,15 @@ abstract class BaseInteractionWithEmbedResponse extends BaseInteraction {
|
||||
|
||||
protected getEmbedQueueAuthor(
|
||||
interaction: MessageComponentInteraction | ChatInputCommandInteraction,
|
||||
queue: GuildQueue
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
): EmbedAuthorOptions {
|
||||
const bitrate = queue.channel ? queue.channel.bitrate / 1000 : 0;
|
||||
return {
|
||||
name: `Channel: ${queue.channel!.name} (${bitrate}kbps)`,
|
||||
name: translator('musicPlayerCommon.voiceChannelInfo', {
|
||||
channel: queue.channel!.name,
|
||||
bitrate
|
||||
}),
|
||||
iconURL: interaction.guild!.iconURL() || this.embedOptions.info.fallbackIconUrl
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Track } from 'discord-player';
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
export function shouldUseLastQuery(query: string, lastQuery?: string, timestamp?: number): boolean {
|
||||
return Boolean(
|
||||
@@ -10,7 +11,10 @@ export function isQueryTooShort(query: string): boolean {
|
||||
return query.length < 3;
|
||||
}
|
||||
|
||||
export function getTrackName(track: Track): string {
|
||||
const name = `${track.title} [Author: ${track.author}]`;
|
||||
export function getTrackName(track: Track, translator: TFunction): string {
|
||||
const name = translator('autocomplete.trackName', {
|
||||
title: track.title,
|
||||
author: track.author
|
||||
});
|
||||
return name.length > 100 ? name.slice(0, 100) : name;
|
||||
}
|
||||
@@ -1,3 +1,7 @@
|
||||
import { QueueRepeatMode } from 'discord-player';
|
||||
import { TFunction } from 'i18next';
|
||||
import { EmbedOptions } from '../types/configTypes';
|
||||
|
||||
export function formatDuration(durationMs: number): string {
|
||||
const durationDate: Date = new Date(0);
|
||||
durationDate.setMilliseconds(durationMs);
|
||||
@@ -17,3 +21,55 @@ export function formatDuration(durationMs: number): string {
|
||||
return `${durationSeconds}s`;
|
||||
}
|
||||
}
|
||||
|
||||
export function formatSlashCommand(commandName: string, translator: TFunction): string {
|
||||
const translatedName = translator(`commands.${commandName}.metadata.name`, {
|
||||
defaultValue: commandName
|
||||
});
|
||||
return `**\`/${translatedName}\`**`;
|
||||
}
|
||||
|
||||
export function formatRepeatMode(repeatMode: QueueRepeatMode, translator: TFunction): string {
|
||||
switch (repeatMode) {
|
||||
case QueueRepeatMode.AUTOPLAY:
|
||||
return translator('musicPlayerCommon.queueRepeatMode.autoplay');
|
||||
case QueueRepeatMode.OFF:
|
||||
return translator('musicPlayerCommon.queueRepeatMode.off');
|
||||
case QueueRepeatMode.TRACK:
|
||||
return translator('musicPlayerCommon.queueRepeatMode.track');
|
||||
case QueueRepeatMode.QUEUE:
|
||||
return translator('musicPlayerCommon.queueRepeatMode.queue');
|
||||
}
|
||||
}
|
||||
|
||||
export function formatRepeatModeDetailed(
|
||||
repeatMode: QueueRepeatMode,
|
||||
embedOptions: EmbedOptions,
|
||||
translator: TFunction,
|
||||
state: string = 'info'
|
||||
) {
|
||||
let icon: string;
|
||||
|
||||
switch (repeatMode) {
|
||||
case QueueRepeatMode.TRACK:
|
||||
icon = state === 'info' ? embedOptions.icons.loop : embedOptions.icons.looping;
|
||||
break;
|
||||
case QueueRepeatMode.QUEUE:
|
||||
icon = state === 'info' ? embedOptions.icons.loop : embedOptions.icons.looping;
|
||||
break;
|
||||
case QueueRepeatMode.AUTOPLAY:
|
||||
icon = state === 'info' ? embedOptions.icons.autoplay : embedOptions.icons.autoplaying;
|
||||
break;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
||||
return (
|
||||
'\n' +
|
||||
translator('musicPlayerCommon.loopingInfo', {
|
||||
icon,
|
||||
loopMode: formatRepeatMode(repeatMode, translator),
|
||||
loopCommand: formatSlashCommand('loop', translator)
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
import assert from 'assert';
|
||||
import {
|
||||
APIApplicationCommandOption,
|
||||
ApplicationCommandOptionType,
|
||||
BaseInteraction,
|
||||
Locale,
|
||||
SlashCommandBuilder
|
||||
} from 'discord.js';
|
||||
import { lstatSync, readdirSync } from 'fs';
|
||||
import i18n from 'i18next';
|
||||
import i18nextFsBackend, { FsBackendOptions } from 'i18next-fs-backend';
|
||||
import { join } from 'path';
|
||||
|
||||
const translatorInstance = i18n.createInstance();
|
||||
const localeDir = join(__dirname, '..', '..', 'locales');
|
||||
translatorInstance.use(i18nextFsBackend).init<FsBackendOptions>({
|
||||
initImmediate: false,
|
||||
fallbackLng: 'en',
|
||||
preload: readdirSync(localeDir).filter((fileName) => {
|
||||
const joinedPath = join(localeDir, fileName);
|
||||
const isDirectory = lstatSync(joinedPath).isDirectory();
|
||||
return isDirectory;
|
||||
}),
|
||||
ns: 'bot',
|
||||
defaultNS: 'bot',
|
||||
backend: {
|
||||
loadPath: join(localeDir, '{{lng}}', '{{ns}}.json'),
|
||||
addPath: join(localeDir, '{{lng}}', '{{ns}}.missing.json')
|
||||
},
|
||||
interpolation: {
|
||||
escapeValue: false
|
||||
}
|
||||
});
|
||||
|
||||
export function useServerTranslator(interaction: BaseInteraction) {
|
||||
return translatorInstance.getFixedT(interaction.guildLocale ?? 'en');
|
||||
}
|
||||
|
||||
export function useUserTranslator(interaction: BaseInteraction) {
|
||||
return translatorInstance.getFixedT(interaction.locale ?? 'en');
|
||||
}
|
||||
|
||||
export const DISCORD_LOCALES = Object.values(Locale);
|
||||
|
||||
export type CommandMetadata = {
|
||||
name?: string;
|
||||
description?: string;
|
||||
options?: Record<
|
||||
string,
|
||||
{
|
||||
name?: string;
|
||||
description?: string;
|
||||
choices?: Record<string, string>;
|
||||
}
|
||||
>;
|
||||
};
|
||||
|
||||
type DeepMutable<T> = { -readonly [P in keyof T]: DeepMutable<T[P]> };
|
||||
export function localizeCommand(command: Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>) {
|
||||
const jsonCommand = command as DeepMutable<typeof command>;
|
||||
|
||||
assert(jsonCommand.name, `Command /${command.name} must have a name using setName.`);
|
||||
const metadataKey = `commands.${jsonCommand.name}.metadata`;
|
||||
const englishData = translatorInstance.getResource('en', 'bot', metadataKey) as CommandMetadata | undefined;
|
||||
assert(englishData, `Command /${command.name} must have English localization data.`);
|
||||
|
||||
// Localizing the top-level command...
|
||||
jsonCommand.description = englishData.description ?? '!MISSING DESCRIPTION!';
|
||||
/* eslint-disable camelcase */
|
||||
jsonCommand.name_localizations = {};
|
||||
/* eslint-disable camelcase */
|
||||
jsonCommand.description_localizations = {};
|
||||
for (const locale of DISCORD_LOCALES) {
|
||||
const localeData = translatorInstance.getResource(locale, 'bot', metadataKey) as CommandMetadata | undefined;
|
||||
if (locale.startsWith('en') || !localeData) {
|
||||
continue;
|
||||
}
|
||||
if (localeData.name) {
|
||||
jsonCommand.name_localizations[locale] = localeData.name;
|
||||
}
|
||||
if (localeData.description) {
|
||||
jsonCommand.description_localizations[locale] = localeData.description;
|
||||
}
|
||||
}
|
||||
|
||||
// Localizing the command options...
|
||||
if (jsonCommand.options.length > 0) {
|
||||
assert(englishData.options, `Command /${command.name} must have option localizations.`);
|
||||
for (const unwritableOption of jsonCommand.options) {
|
||||
const option = unwritableOption as never as APIApplicationCommandOption;
|
||||
assert(option.name, `Option in /${command.name} must have a name using setName.`);
|
||||
|
||||
const englishOptionData = englishData.options[option.name];
|
||||
option.description = englishOptionData.description ?? '!MISSING DESCRIPTION!';
|
||||
|
||||
option.name_localizations = {};
|
||||
option.description_localizations = {};
|
||||
if (
|
||||
(option.type === ApplicationCommandOptionType.String ||
|
||||
option.type === ApplicationCommandOptionType.Integer) &&
|
||||
option.choices
|
||||
) {
|
||||
assert(
|
||||
englishOptionData.choices,
|
||||
`Option ${option.name} in /${command.name} must have choice localizations.`
|
||||
);
|
||||
for (const choice of option.choices) {
|
||||
choice.name_localizations = {};
|
||||
assert(
|
||||
choice.value !== undefined && choice.value !== null,
|
||||
`Choice in option ${option.name} in /${command.name} must have a value.`
|
||||
);
|
||||
const stringifiedValue = choice.value.toString();
|
||||
assert(
|
||||
englishOptionData.choices[stringifiedValue],
|
||||
`Choice ${choice.value} of option ${option.name} in /${command.name} must have an English localization.`
|
||||
);
|
||||
choice.name = englishOptionData.choices[stringifiedValue];
|
||||
}
|
||||
}
|
||||
for (const locale of DISCORD_LOCALES) {
|
||||
const localeOptionData = (
|
||||
translatorInstance.getResource(locale, 'bot', metadataKey) as CommandMetadata | undefined
|
||||
)?.options?.[option.name];
|
||||
|
||||
if (locale.startsWith('en') || !localeOptionData) {
|
||||
continue;
|
||||
}
|
||||
if (localeOptionData.name) {
|
||||
option.name_localizations[locale] = localeOptionData.name;
|
||||
}
|
||||
if (localeOptionData.description) {
|
||||
option.description_localizations[locale] = localeOptionData.description;
|
||||
}
|
||||
|
||||
if (
|
||||
localeOptionData.choices &&
|
||||
(option.type === ApplicationCommandOptionType.String ||
|
||||
option.type === ApplicationCommandOptionType.Integer) &&
|
||||
option.choices
|
||||
) {
|
||||
for (const choice of option.choices) {
|
||||
const localizedChoice = localeOptionData.choices[choice.value];
|
||||
if (!localizedChoice) {
|
||||
continue;
|
||||
}
|
||||
choice.name_localizations![locale] = localizedChoice;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return jsonCommand as SlashCommandBuilder;
|
||||
}
|
||||
+48
-24
@@ -2,54 +2,78 @@ import osu from 'node-os-utils';
|
||||
import { ExtendedClient } from '../types/clientTypes';
|
||||
import { fetchTotalGuildStatistics, fetchTotalPlayerStatistics } from '../utils/shardUtils';
|
||||
import { getUptimeFormatted } from '../utils/system/getUptimeFormatted';
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
export async function getBotStatistics(client: ExtendedClient, version: string): Promise<string> {
|
||||
export async function getBotStatistics(
|
||||
client: ExtendedClient,
|
||||
version: string,
|
||||
translator: TFunction
|
||||
): Promise<string> {
|
||||
const releaseVersion: string = version;
|
||||
const { totalGuildCount, totalMemberCount } = await fetchTotalGuildStatistics(client);
|
||||
|
||||
return (
|
||||
`**${totalGuildCount.toLocaleString('en-US')}** Joined servers\n` +
|
||||
`**${totalMemberCount.toLocaleString('en-US')}** Total members\n` +
|
||||
`**v${releaseVersion}** Release version`
|
||||
translator('statistics.botStatus.joinedServers', {
|
||||
count: totalGuildCount
|
||||
}) +
|
||||
'\n' +
|
||||
translator('statistics.botStatus.totalMembers', {
|
||||
count: totalMemberCount
|
||||
}) +
|
||||
'\n' +
|
||||
translator('statistics.botStatus.releaseVersion', {
|
||||
version: `v${releaseVersion}`
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export async function getPlayerStatistics(client: ExtendedClient): Promise<string> {
|
||||
export async function getPlayerStatistics(client: ExtendedClient, translator: TFunction): Promise<string> {
|
||||
const { totalVoiceConnections, totalTracksInQueues, totalListeners } = await fetchTotalPlayerStatistics(client);
|
||||
|
||||
return (
|
||||
`**${totalVoiceConnections.toLocaleString('en-US')}** Voice connections\n` +
|
||||
`**${totalTracksInQueues.toLocaleString('en-US')}** Tracks in queues\n` +
|
||||
`**${totalListeners.toLocaleString('en-US')}** Users listening`
|
||||
translator('statistics.queueStatus.voiceConnections', {
|
||||
count: totalVoiceConnections
|
||||
}) +
|
||||
'\n' +
|
||||
translator('statistics.queueStatus.tracksInQueues', {
|
||||
count: totalTracksInQueues
|
||||
}) +
|
||||
'\n' +
|
||||
translator('statistics.queueStatus.usersListening', {
|
||||
count: totalListeners
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export async function getSystemStatus(executionId: string, extended: boolean): Promise<string> {
|
||||
export async function getSystemStatus(executionId: string, extended: boolean, translator: TFunction): Promise<string> {
|
||||
const uptimeString: string = getUptimeFormatted({ executionId });
|
||||
const usedMemoryInMB: number = Math.ceil((await osu.mem.info()).usedMemMb);
|
||||
const cpuUsage: number = await osu.cpu.usage();
|
||||
if (!extended) {
|
||||
const uptimeString: string = getUptimeFormatted({ executionId });
|
||||
const usedMemoryInMB: string = Math.ceil((await osu.mem.info()).usedMemMb).toLocaleString('en-US');
|
||||
const cpuUsage: number = await osu.cpu.usage();
|
||||
|
||||
return (
|
||||
`**${uptimeString}** Uptime\n` + `**${cpuUsage}%** CPU usage\n` + `**${usedMemoryInMB} MB** Memory usage`
|
||||
translator('statistics.systemStatus.uptime', { value: uptimeString }) +
|
||||
'\n' +
|
||||
translator('statistics.systemStatus.cpu', { value: cpuUsage }) +
|
||||
'\n' +
|
||||
translator('statistics.systemStatus.memory', { value: usedMemoryInMB })
|
||||
);
|
||||
}
|
||||
|
||||
const uptimeString: string = getUptimeFormatted({ executionId });
|
||||
const totalMemoryInMb: string = Math.ceil((await osu.mem.info()).totalMemMb).toLocaleString('en-US');
|
||||
const totalMemoryInMb: number = Math.ceil((await osu.mem.info()).totalMemMb);
|
||||
const cpuCores: number = osu.cpu.count();
|
||||
const platform: string = osu.os.platform();
|
||||
const usedMemoryInMB: string = Math.ceil((await osu.mem.info()).usedMemMb).toLocaleString('en-US');
|
||||
const cpuUsage: number = await osu.cpu.usage();
|
||||
|
||||
return (
|
||||
`**${platform}** Platform\n` +
|
||||
`**${uptimeString}** Uptime\n` +
|
||||
`**${cpuUsage}% @ ${cpuCores} cores** CPU usage\n` +
|
||||
`**${usedMemoryInMB} / ${totalMemoryInMb} MB** Memory usage`
|
||||
translator('statistics.systemStatus.platform', { value: platform }) +
|
||||
'\n' +
|
||||
translator('statistics.systemStatus.uptime', { value: uptimeString }) +
|
||||
'\n' +
|
||||
translator('statistics.systemStatus.cpuDetailed', { usage: cpuUsage, cores: cpuCores }) +
|
||||
'\n' +
|
||||
translator('statistics.systemStatus.memoryDetailed', { used: usedMemoryInMB, total: totalMemoryInMb })
|
||||
);
|
||||
}
|
||||
|
||||
export function getDiscordStatus(client: ExtendedClient): string {
|
||||
return `**${client!.ws.ping} ms** Discord API latency`;
|
||||
export function getDiscordStatus(client: ExtendedClient, translator: TFunction): string {
|
||||
return translator('statistics.discordStatus.apiLatency', { value: client.ws.ping });
|
||||
}
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
// .ENV file is loaded automatically by dotenv
|
||||
// .ENV file is loaded auomaically by doenv
|
||||
import 'dotenv/config';
|
||||
|
||||
// Only after loading .ENV file, we can load other modules
|
||||
import config from 'config';
|
||||
import { Client, Shard, ShardEvents, ShardingManager, ShardingManagerOptions } from 'discord.js';
|
||||
|
||||
@@ -5,7 +5,8 @@ import { Logger } from 'pino';
|
||||
import { BaseAutocompleteInteraction } from '../../classes/interactions';
|
||||
import { getTrackName, isQueryTooShort, shouldUseLastQuery } from '../../common/autocompleteUtils';
|
||||
import { BaseAutocompleteParams, BaseAutocompleteReturnType, RecentQuery } from '../../types/interactionTypes';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { useUserTranslator } from '../../common/localeUtil';
|
||||
class LyricsAutocomplete extends BaseAutocompleteInteraction {
|
||||
private recentQueries = new Map<string, RecentQuery>();
|
||||
|
||||
@@ -15,6 +16,7 @@ class LyricsAutocomplete extends BaseAutocompleteInteraction {
|
||||
|
||||
async execute({ executionId, interaction }: BaseAutocompleteParams): BaseAutocompleteReturnType {
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useUserTranslator(interaction);
|
||||
|
||||
const query: string = interaction.options.getString('query', true);
|
||||
const { lastQuery, result, timestamp } = this.recentQueries.get(interaction.user.id) || {};
|
||||
@@ -29,7 +31,7 @@ class LyricsAutocomplete extends BaseAutocompleteInteraction {
|
||||
return interaction.respond([]);
|
||||
}
|
||||
|
||||
const autocompleteChoices = await this.getAutocompleteChoices(query, logger);
|
||||
const autocompleteChoices = await this.getAutocompleteChoices(query, logger, translator);
|
||||
|
||||
if (!autocompleteChoices || autocompleteChoices.length === 0) {
|
||||
logger.debug(`Responding with empty results for query '${query}'`);
|
||||
@@ -44,21 +46,23 @@ class LyricsAutocomplete extends BaseAutocompleteInteraction {
|
||||
|
||||
private async getAutocompleteChoices(
|
||||
query: string,
|
||||
logger: Logger
|
||||
logger: Logger,
|
||||
translator: TFunction
|
||||
): Promise<ApplicationCommandOptionChoiceData<string>[]> {
|
||||
const genius = lyricsExtractor();
|
||||
const lyricsResult: LyricsData = (await genius.search(query).catch(() => null)) as LyricsData;
|
||||
|
||||
if (!lyricsResult) {
|
||||
return this.getAutocompleteChoicesFallback(query, logger);
|
||||
return this.getAutocompleteChoicesFallback(query, logger, translator);
|
||||
} else {
|
||||
return this.getAutocompleteChoicesFromLyricsResult(lyricsResult);
|
||||
return this.getAutocompleteChoicesFromLyricsResult(lyricsResult, translator);
|
||||
}
|
||||
}
|
||||
|
||||
private async getAutocompleteChoicesFallback(
|
||||
query: string,
|
||||
logger: Logger
|
||||
logger: Logger,
|
||||
translator: TFunction
|
||||
): Promise<ApplicationCommandOptionChoiceData<string>[]> {
|
||||
logger.debug(`No Genius lyrics found for query '${query}', using player.search() as fallback.`);
|
||||
|
||||
@@ -66,24 +70,28 @@ class LyricsAutocomplete extends BaseAutocompleteInteraction {
|
||||
const searchResults: SearchResult = await player.search(query);
|
||||
|
||||
return searchResults.tracks.slice(0, 1).map((track) => ({
|
||||
name: getTrackName(track),
|
||||
name: getTrackName(track, translator),
|
||||
value: track.title.slice(0, 100)
|
||||
}));
|
||||
}
|
||||
|
||||
private getAutocompleteChoicesFromLyricsResult(
|
||||
lyricsResult: LyricsData
|
||||
lyricsResult: LyricsData,
|
||||
translator: TFunction
|
||||
): ApplicationCommandOptionChoiceData<string>[] {
|
||||
return [
|
||||
{
|
||||
name: this.getLyricsResultName(lyricsResult),
|
||||
name: this.getLyricsResultName(lyricsResult, translator),
|
||||
value: lyricsResult.title.slice(0, 100)
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
private getLyricsResultName(lyricsResult: LyricsData): string {
|
||||
return `${lyricsResult.title} [Artist: ${lyricsResult.artist.name}]`.slice(0, 100);
|
||||
private getLyricsResultName(lyricsResult: LyricsData, translator: TFunction): string {
|
||||
return translator('commands.lyrics.autocompleteSearchResult', {
|
||||
title: lyricsResult.title,
|
||||
artist: lyricsResult.artist.name
|
||||
});
|
||||
}
|
||||
|
||||
private updateRecentQuery(
|
||||
|
||||
@@ -3,6 +3,8 @@ import { ApplicationCommandOptionChoiceData } from 'discord.js';
|
||||
import { BaseAutocompleteInteraction } from '../../classes/interactions';
|
||||
import { getTrackName, isQueryTooShort, shouldUseLastQuery } from '../../common/autocompleteUtils';
|
||||
import { BaseAutocompleteParams, BaseAutocompleteReturnType, RecentQuery } from '../../types/interactionTypes';
|
||||
import { TFunction } from 'i18next';
|
||||
import { useUserTranslator } from '../../common/localeUtil';
|
||||
|
||||
class PlayAutocomplete extends BaseAutocompleteInteraction {
|
||||
private recentQueries = new Map<string, RecentQuery>();
|
||||
@@ -14,6 +16,7 @@ class PlayAutocomplete extends BaseAutocompleteInteraction {
|
||||
async execute(params: BaseAutocompleteParams): BaseAutocompleteReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useUserTranslator(interaction);
|
||||
|
||||
const query: string = interaction.options.getString('query', true);
|
||||
|
||||
@@ -29,8 +32,10 @@ class PlayAutocomplete extends BaseAutocompleteInteraction {
|
||||
return interaction.respond([]);
|
||||
}
|
||||
|
||||
const autocompleteChoices: ApplicationCommandOptionChoiceData<string>[] =
|
||||
await this.getAutocompleteChoices(query);
|
||||
const autocompleteChoices: ApplicationCommandOptionChoiceData<string>[] = await this.getAutocompleteChoices(
|
||||
query,
|
||||
translator
|
||||
);
|
||||
|
||||
if (!autocompleteChoices || autocompleteChoices.length === 0) {
|
||||
logger.debug(`Responding with empty results for query '${query}'`);
|
||||
@@ -43,11 +48,14 @@ class PlayAutocomplete extends BaseAutocompleteInteraction {
|
||||
return interaction.respond(autocompleteChoices);
|
||||
}
|
||||
|
||||
private async getAutocompleteChoices(query: string): Promise<ApplicationCommandOptionChoiceData<string>[]> {
|
||||
private async getAutocompleteChoices(
|
||||
query: string,
|
||||
translator: TFunction
|
||||
): Promise<ApplicationCommandOptionChoiceData<string>[]> {
|
||||
const player: Player = useMainPlayer()!;
|
||||
const searchResults: SearchResult = await player.search(query);
|
||||
return searchResults.tracks.slice(0, 5).map((track) => ({
|
||||
name: getTrackName(track),
|
||||
name: getTrackName(track, translator),
|
||||
value: track.url
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
APIMessageActionRowComponent,
|
||||
ButtonBuilder,
|
||||
ButtonStyle,
|
||||
ChatInputCommandInteraction,
|
||||
Collection,
|
||||
ComponentType,
|
||||
EmbedBuilder,
|
||||
@@ -13,19 +14,25 @@ import {
|
||||
} from 'discord.js';
|
||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||
import { CommandMetadata, localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { ExtendedClient } from '../../../types/clientTypes';
|
||||
import i18n from 'i18next';
|
||||
import i18nextFsBackend, { FsBackendOptions } from 'i18next-fs-backend';
|
||||
import { join } from 'path';
|
||||
import { lstatSync, readdirSync } from 'fs';
|
||||
|
||||
class HelpCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder().setName('help').setDescription('Show the list of bot commands.');
|
||||
const data = localizeCommand(new SlashCommandBuilder().setName('help'));
|
||||
super(data);
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, client, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const commandEmbedString = await this.getCommandEmbedString(client!);
|
||||
const commandEmbedString = await this.getCommandEmbedString(client!, interaction);
|
||||
|
||||
const components: APIMessageActionRowComponent[] = [];
|
||||
|
||||
@@ -34,7 +41,7 @@ class HelpCommand extends BaseSlashCommandInteraction {
|
||||
.setURL(this.botOptions.serverInviteUrl)
|
||||
.setStyle(ButtonStyle.Link)
|
||||
.setEmoji(this.embedOptions.icons.support)
|
||||
.setLabel('Support server')
|
||||
.setLabel(translator('commands.help.supportServerButton'))
|
||||
.toJSON();
|
||||
components.push(supportServerButton);
|
||||
}
|
||||
@@ -44,7 +51,7 @@ class HelpCommand extends BaseSlashCommandInteraction {
|
||||
.setURL(this.botOptions.botInviteUrl)
|
||||
.setStyle(ButtonStyle.Link)
|
||||
.setEmoji(this.embedOptions.icons.bot)
|
||||
.setLabel('Add bot')
|
||||
.setLabel(translator('commands.help.addBotButton'))
|
||||
.toJSON();
|
||||
components.push(addBotButton);
|
||||
}
|
||||
@@ -58,7 +65,13 @@ class HelpCommand extends BaseSlashCommandInteraction {
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(`${this.embedOptions.icons.rule} **List of commands**\n` + commandEmbedString)
|
||||
.setDescription(
|
||||
translator('commands.help.listTitle', {
|
||||
icon: this.embedOptions.icons.rule
|
||||
}) +
|
||||
'\n' +
|
||||
commandEmbedString
|
||||
)
|
||||
.setColor(this.embedOptions.colors.info)
|
||||
],
|
||||
components: components.length > 0 ? [embedActionRow] : []
|
||||
@@ -76,22 +89,57 @@ class HelpCommand extends BaseSlashCommandInteraction {
|
||||
return nonSystemCommands;
|
||||
}
|
||||
|
||||
private async getCommandEmbedString(client: ExtendedClient): Promise<string> {
|
||||
private async getCommandEmbedString(
|
||||
client: ExtendedClient,
|
||||
interaction: ChatInputCommandInteraction
|
||||
): Promise<string> {
|
||||
const commandCollection = this.getNonSystemCommands(client!);
|
||||
|
||||
const commandStringList = commandCollection.map((command: BaseSlashCommandInteraction) => {
|
||||
return this.getCommandString(command);
|
||||
return this.getCommandString(command, interaction);
|
||||
});
|
||||
|
||||
const commandString = commandStringList.join('\n');
|
||||
return commandString;
|
||||
}
|
||||
|
||||
private getCommandString(command: BaseSlashCommandInteraction): string {
|
||||
private getCommandString(command: BaseSlashCommandInteraction, interaction: ChatInputCommandInteraction): string {
|
||||
// TODO: Clean up this mess and create a common factory for translator instances.
|
||||
const commandName = command.data.name;
|
||||
const metadataKey = `commands.${commandName}.metadata`;
|
||||
const translatorInstance = i18n.createInstance();
|
||||
const localeDir = join(__dirname, '..', '..', '..', '..', 'locales');
|
||||
translatorInstance.use(i18nextFsBackend).init<FsBackendOptions>({
|
||||
initImmediate: false,
|
||||
fallbackLng: 'en',
|
||||
preload: readdirSync(localeDir).filter((fileName) => {
|
||||
const joinedPath = join(localeDir, fileName);
|
||||
const isDirectory = lstatSync(joinedPath).isDirectory();
|
||||
return isDirectory;
|
||||
}),
|
||||
ns: 'bot',
|
||||
defaultNS: 'bot',
|
||||
backend: {
|
||||
loadPath: join(localeDir, '{{lng}}', '{{ns}}.json'),
|
||||
addPath: join(localeDir, '{{lng}}', '{{ns}}.missing.json')
|
||||
},
|
||||
interpolation: {
|
||||
escapeValue: false
|
||||
}
|
||||
});
|
||||
|
||||
const locale = interaction.guildLocale ?? 'en';
|
||||
let translatedData: CommandMetadata | undefined = undefined;
|
||||
translatedData = translatorInstance.getResource(locale, 'bot', metadataKey) as CommandMetadata | undefined;
|
||||
|
||||
const commandParams: string = this.getCommandParams(command);
|
||||
|
||||
const beta: string = command.isBeta ? `${this.embedOptions.icons.beta} ` : '';
|
||||
const newCommand: string = command.isNew ? `${this.embedOptions.icons.new} ` : '';
|
||||
return `- **\`/${command.data.name}\`** ${commandParams}- ${beta}${newCommand}${command.data.description}`;
|
||||
|
||||
return `- **\`/${translatedData?.name ?? command.data.name}\`** ${commandParams}- ${beta}${newCommand}${
|
||||
translatedData?.description ?? command.data.description
|
||||
}`;
|
||||
}
|
||||
|
||||
private getCommandParams(command: BaseSlashCommandInteraction): string {
|
||||
|
||||
@@ -4,41 +4,53 @@ import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||
import { getBotStatistics, getDiscordStatus, getPlayerStatistics, getSystemStatus } from '../../../common/statusUtils';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
|
||||
class StatusCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder().setName('status').setDescription('Show operational status of the bot.');
|
||||
const data = localizeCommand(new SlashCommandBuilder().setName('status'));
|
||||
super(data);
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction, client } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const [botStatisticsEmbedString, playerStatisticsEmbedString, systemStatusEmbedString] = await Promise.all([
|
||||
getBotStatistics(client!, version),
|
||||
getPlayerStatistics(client!),
|
||||
getSystemStatus(executionId, false)
|
||||
getBotStatistics(client!, version, translator),
|
||||
getPlayerStatistics(client!, translator),
|
||||
getSystemStatus(executionId, false, translator)
|
||||
]);
|
||||
const discordStatus = getDiscordStatus(client!);
|
||||
const discordStatusEmbedString = getDiscordStatus(client!, translator);
|
||||
|
||||
logger.debug('Responding with info embed.');
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(`**${this.embedOptions.icons.bot} Bot status**\n` + botStatisticsEmbedString)
|
||||
.setDescription(
|
||||
translator('statistics.botStatus.title', { icon: this.embedOptions.icons.bot }) +
|
||||
'\n' +
|
||||
botStatisticsEmbedString
|
||||
)
|
||||
.addFields(
|
||||
{
|
||||
name: `**${this.embedOptions.icons.queue} Queue status**`,
|
||||
name: translator('statistics.queueStatus.title', {
|
||||
icon: this.embedOptions.icons.queue
|
||||
}),
|
||||
value: playerStatisticsEmbedString
|
||||
},
|
||||
{
|
||||
name: `**${this.embedOptions.icons.server} System status**`,
|
||||
name: translator('statistics.systemStatus.title', {
|
||||
icon: this.embedOptions.icons.server
|
||||
}),
|
||||
value: systemStatusEmbedString
|
||||
},
|
||||
{
|
||||
name: `**${this.embedOptions.icons.discord} Discord status**`,
|
||||
value: discordStatus
|
||||
name: translator('statistics.discordStatus.title', {
|
||||
icon: this.embedOptions.icons.discord
|
||||
}),
|
||||
value: discordStatusEmbedString
|
||||
}
|
||||
)
|
||||
.setColor(this.embedOptions.colors.info)
|
||||
|
||||
@@ -5,21 +5,24 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ
|
||||
import { checkHistoryExists, checkQueueCurrentTrack } from '../../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
import { Logger } from 'pino';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { formatSlashCommand } from '../../../common/formattingUtils';
|
||||
|
||||
class BackCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName('back')
|
||||
.setDescription('Go back to previous track or specified position in history.')
|
||||
.addIntegerOption((option) =>
|
||||
option.setName('position').setDescription('The position in history to go back to.').setMinValue(1)
|
||||
);
|
||||
const data = localizeCommand(
|
||||
new SlashCommandBuilder()
|
||||
.setName('back')
|
||||
.addIntegerOption((option) => option.setName('position').setMinValue(1))
|
||||
);
|
||||
super(data);
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const history: GuildQueueHistory = useHistory(interaction.guild!.id)!;
|
||||
|
||||
@@ -33,9 +36,9 @@ class BackCommand extends BaseSlashCommandInteraction {
|
||||
const backToTrackInput: number = interaction.options.getInteger('position')!;
|
||||
|
||||
if (backToTrackInput) {
|
||||
return await this.handleBackToTrackPosition(logger, interaction, history, backToTrackInput);
|
||||
return await this.handleBackToTrackPosition(logger, interaction, history, backToTrackInput, translator);
|
||||
} else {
|
||||
return await this.handleBackToPreviousTrack(logger, interaction, history);
|
||||
return await this.handleBackToPreviousTrack(logger, interaction, history, translator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,37 +46,43 @@ class BackCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
history: GuildQueueHistory,
|
||||
backtoTrackPosition: number
|
||||
backtoTrackPosition: number,
|
||||
translator: TFunction
|
||||
) {
|
||||
if (backtoTrackPosition > history.tracks.data.length) {
|
||||
return await this.handleTrackPositionHigherThanQueueLength(
|
||||
return await this.handleTrackPositionHigherThanHistoryLength(
|
||||
backtoTrackPosition,
|
||||
history,
|
||||
logger,
|
||||
interaction
|
||||
interaction,
|
||||
translator
|
||||
);
|
||||
} else {
|
||||
await history.back();
|
||||
const recoveredTrack: Track = history.currentTrack! ?? history.tracks.data[backtoTrackPosition - 1];
|
||||
logger.debug('Went back to specified track position in history.');
|
||||
return await this.respondWithSuccessEmbed(recoveredTrack, interaction);
|
||||
return await this.respondWithSuccessEmbed(recoveredTrack, interaction, translator);
|
||||
}
|
||||
}
|
||||
|
||||
private async handleTrackPositionHigherThanQueueLength(
|
||||
private async handleTrackPositionHigherThanHistoryLength(
|
||||
backToTrackPosition: number,
|
||||
history: GuildQueueHistory,
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
) {
|
||||
logger.debug('Specified track position was higher than total tracks.');
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
||||
`There are only **\`${history.tracks.data.length}\`** tracks in the history. You cannot go back to track **\`${backToTrackPosition}\`**.\n\n` +
|
||||
'View tracks added in the history with **`/history`**.'
|
||||
translator('commands.back.trackPositionHigherThanHistoryLength', {
|
||||
icon: this.embedOptions.icons.warning,
|
||||
count: history.tracks.data.length,
|
||||
backPosition: backToTrackPosition,
|
||||
historyCommand: formatSlashCommand('history', translator)
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
]
|
||||
@@ -83,40 +92,53 @@ class BackCommand extends BaseSlashCommandInteraction {
|
||||
private async handleBackToPreviousTrack(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
history: GuildQueueHistory
|
||||
history: GuildQueueHistory,
|
||||
translator: TFunction
|
||||
) {
|
||||
if (history.tracks.data.length === 0) {
|
||||
return await this.handleNoTracksInHistory(logger, interaction);
|
||||
return await this.handleNoTracksInHistory(logger, interaction, translator);
|
||||
}
|
||||
|
||||
await history.back();
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
const currentTrack: Track = queue.currentTrack!;
|
||||
logger.debug('Recovered track from history.');
|
||||
return await this.respondWithSuccessEmbed(currentTrack, interaction);
|
||||
return await this.respondWithSuccessEmbed(currentTrack, interaction, translator);
|
||||
}
|
||||
private async handleNoTracksInHistory(logger: Logger, interaction: ChatInputCommandInteraction) {
|
||||
private async handleNoTracksInHistory(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
) {
|
||||
logger.debug('No tracks in history.');
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
||||
'The history is empty, add some tracks with **`/play`**!'
|
||||
translator('commands.back.trackHistoryEmpty', {
|
||||
icon: this.embedOptions.icons.warning,
|
||||
playCommand: formatSlashCommand('play', translator)
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
private async respondWithSuccessEmbed(recoveredTrack: Track, interaction: ChatInputCommandInteraction) {
|
||||
private async respondWithSuccessEmbed(
|
||||
recoveredTrack: Track,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
) {
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.back} Recovered track**\n` +
|
||||
`${this.getDisplayTrackDurationAndUrl(recoveredTrack)}`
|
||||
translator('commands.back.trackRecovered', {
|
||||
icon: this.embedOptions.icons.back,
|
||||
track: this.getDisplayTrackDurationAndUrl(recoveredTrack, translator)
|
||||
})
|
||||
)
|
||||
.setThumbnail(this.getTrackThumbnailUrl(recoveredTrack))
|
||||
.setColor(this.embedOptions.colors.success)
|
||||
|
||||
@@ -26,6 +26,8 @@ import {
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
const ffmpegFilterOptions: FFmpegFilterOptions = config.get('ffmpegFilterOptions');
|
||||
const biquadFilterOptions: BiquadFilterOptions = config.get('biquadFilterOptions');
|
||||
@@ -33,27 +35,29 @@ const equalizerFilterOptions: EqualizerFilterOptions = config.get('equalizerFilt
|
||||
|
||||
class FiltersCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName('filters')
|
||||
.setDescription('Toggle various audio filters.')
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName('type')
|
||||
.setDescription('Audio filter type to use.')
|
||||
.setRequired(false)
|
||||
.addChoices(
|
||||
{ name: 'FFmpeg', value: 'ffmpeg' },
|
||||
{ name: 'Biquad', value: 'biquad' },
|
||||
{ name: 'Equalizer', value: 'equalizer' },
|
||||
{ name: 'Disable', value: 'disable' }
|
||||
)
|
||||
);
|
||||
// TODO: Implement system for localized filter names and descriptions
|
||||
const data = localizeCommand(
|
||||
new SlashCommandBuilder()
|
||||
.setName('filters')
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName('type')
|
||||
.setRequired(false)
|
||||
.addChoices(
|
||||
{ value: 'ffmpeg', name: ' ' },
|
||||
{ value: 'biquad', name: ' ' },
|
||||
{ value: 'equalizer', name: ' ' },
|
||||
{ value: 'disable', name: ' ' }
|
||||
)
|
||||
)
|
||||
);
|
||||
super(data);
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
@@ -68,20 +72,21 @@ class FiltersCommand extends BaseSlashCommandInteraction {
|
||||
|
||||
switch (filterProvider) {
|
||||
case 'ffmpeg':
|
||||
return await this.handleFfmpegFilters(logger, interaction, queue);
|
||||
return await this.handleFfmpegFilters(logger, interaction, queue, translator);
|
||||
case 'biquad':
|
||||
return await this.handleBiquadFilters(logger, interaction, queue);
|
||||
return await this.handleBiquadFilters(logger, interaction, queue, translator);
|
||||
case 'equalizer':
|
||||
return await this.handleEqualizerFilters(logger, interaction);
|
||||
return await this.handleEqualizerFilters(logger, interaction, translator);
|
||||
case 'disable':
|
||||
return await this.disableAllFiltersAndRespondWithSuccess(logger, interaction, queue);
|
||||
return await this.disableAllFiltersAndRespondWithSuccess(logger, interaction, queue, translator);
|
||||
}
|
||||
}
|
||||
|
||||
private async handleFfmpegFilters(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue<unknown>
|
||||
queue: GuildQueue<unknown>,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
logger.debug('Handling ffmpeg filters.');
|
||||
const filterOptions: StringSelectMenuOptionBuilder[] = [];
|
||||
@@ -103,13 +108,14 @@ class FiltersCommand extends BaseSlashCommandInteraction {
|
||||
);
|
||||
});
|
||||
|
||||
return await this.sendFiltersEmbed(logger, interaction, 'ffmpeg', filterOptions);
|
||||
return await this.sendFiltersEmbed(logger, interaction, 'ffmpeg', filterOptions, translator);
|
||||
}
|
||||
|
||||
private async handleBiquadFilters(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue<unknown>
|
||||
queue: GuildQueue<unknown>,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
logger.debug('Handling biquad filters.');
|
||||
const filterOptions: StringSelectMenuOptionBuilder[] = [];
|
||||
@@ -130,10 +136,14 @@ class FiltersCommand extends BaseSlashCommandInteraction {
|
||||
);
|
||||
});
|
||||
|
||||
return await this.sendFiltersEmbed(logger, interaction, 'biquad', filterOptions);
|
||||
return await this.sendFiltersEmbed(logger, interaction, 'biquad', filterOptions, translator);
|
||||
}
|
||||
|
||||
private async handleEqualizerFilters(logger: Logger, interaction: ChatInputCommandInteraction): Promise<Message> {
|
||||
private async handleEqualizerFilters(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
logger.debug('Handling biquad filters.');
|
||||
const filterOptions: StringSelectMenuOptionBuilder[] = [];
|
||||
|
||||
@@ -148,24 +158,26 @@ class FiltersCommand extends BaseSlashCommandInteraction {
|
||||
);
|
||||
});
|
||||
|
||||
return await this.sendFiltersEmbed(logger, interaction, 'equalizer', filterOptions);
|
||||
return await this.sendFiltersEmbed(logger, interaction, 'equalizer', filterOptions, translator);
|
||||
}
|
||||
|
||||
private async sendFiltersEmbed(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
filterProvider: string,
|
||||
filterOptions: StringSelectMenuOptionBuilder[]
|
||||
filterOptions: StringSelectMenuOptionBuilder[],
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
const actionRows = this.buildFilterActionRows(filterOptions, filterProvider);
|
||||
const actionRows = this.buildFilterActionRows(filterOptions, filterProvider, translator);
|
||||
|
||||
logger.debug('Sending info embed with action row components.');
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**Toggle filters (${filterProvider})**\n` +
|
||||
'Enable or disable audio filters for playback from the menu.'
|
||||
translator('commands.filters.toggleFilterInstructions', {
|
||||
provider: filterProvider
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.info)
|
||||
],
|
||||
@@ -175,12 +187,15 @@ class FiltersCommand extends BaseSlashCommandInteraction {
|
||||
|
||||
private buildFilterActionRows(
|
||||
filterOptions: StringSelectMenuOptionBuilder[],
|
||||
filterProvider: string
|
||||
filterProvider: string,
|
||||
translator: TFunction
|
||||
): APIActionRowComponent<APIMessageActionRowComponent>[] {
|
||||
const filterSelect: APIStringSelectComponent = new StringSelectMenuBuilder()
|
||||
.setCustomId(`filters-select-menu_${filterProvider}`)
|
||||
.setPlaceholder(
|
||||
filterProvider === 'ffmpeg' ? 'Select one or multiple filters.' : 'Select a filter from the menu.'
|
||||
filterProvider === 'ffmpeg'
|
||||
? translator('commands.filters.selectFilterPlaceholderMany')
|
||||
: translator('commands.filters.selectFilterPlaceholder')
|
||||
)
|
||||
.setMinValues(0)
|
||||
.setMaxValues(1)
|
||||
@@ -199,7 +214,7 @@ class FiltersCommand extends BaseSlashCommandInteraction {
|
||||
.toJSON();
|
||||
|
||||
if (this.embedOptions.components.showButtonLabels) {
|
||||
disableButton.label = 'Disable all filters';
|
||||
disableButton.label = translator('commands.filters.disableAllFiltersButton');
|
||||
}
|
||||
|
||||
const disableFiltersActionRow: APIActionRowComponent<APIMessageActionRowComponent> = {
|
||||
@@ -213,7 +228,8 @@ class FiltersCommand extends BaseSlashCommandInteraction {
|
||||
private async disableAllFiltersAndRespondWithSuccess(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
if (queue.filters.ffmpeg.filters.length > 0) {
|
||||
queue.filters.ffmpeg.setFilters(false);
|
||||
@@ -235,8 +251,9 @@ class FiltersCommand extends BaseSlashCommandInteraction {
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.success} Disabled filters**\n` +
|
||||
'All audio filters have been disabled.'
|
||||
translator('commands.filters.allFiltersDisabled', {
|
||||
icon: this.embedOptions.icons.success
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.success)
|
||||
],
|
||||
|
||||
@@ -16,21 +16,24 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||
import { checkHistoryExists } from '../../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { formatRepeatModeDetailed, formatSlashCommand } from '../../../common/formattingUtils';
|
||||
|
||||
class HistoryCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName('history')
|
||||
.setDescription('Show history of tracks that have been played.')
|
||||
.addIntegerOption((option) =>
|
||||
option.setName('page').setDescription('Page number to display for the history').setMinValue(1)
|
||||
);
|
||||
const data = localizeCommand(
|
||||
new SlashCommandBuilder()
|
||||
.setName('history')
|
||||
.addIntegerOption((option) => option.setName('page').setMinValue(1))
|
||||
);
|
||||
super(data);
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const history: GuildQueueHistory = useHistory(interaction.guild!.id)!;
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
@@ -45,10 +48,10 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
||||
const totalPages: number = this.getTotalPages(history);
|
||||
|
||||
if (pageIndex > totalPages - 1) {
|
||||
return await this.handleInvalidPage(logger, interaction, pageIndex, totalPages);
|
||||
return await this.handleInvalidPage(logger, interaction, pageIndex, totalPages, translator);
|
||||
}
|
||||
|
||||
const historyTracksListString: string = this.getHistoryTracksListString(history, pageIndex);
|
||||
const historyTracksListString: string = this.getHistoryTracksListString(history, pageIndex, translator);
|
||||
|
||||
const currentTrack: Track = history.currentTrack!;
|
||||
if (currentTrack) {
|
||||
@@ -58,11 +61,19 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
||||
queue,
|
||||
history,
|
||||
currentTrack,
|
||||
historyTracksListString
|
||||
historyTracksListString,
|
||||
translator
|
||||
);
|
||||
}
|
||||
|
||||
return await this.handleNoCurrentTrack(logger, interaction, queue, history, historyTracksListString);
|
||||
return await this.handleNoCurrentTrack(
|
||||
logger,
|
||||
interaction,
|
||||
queue,
|
||||
history,
|
||||
historyTracksListString,
|
||||
translator
|
||||
);
|
||||
}
|
||||
|
||||
private async handleCurrentTrack(
|
||||
@@ -71,7 +82,8 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
||||
queue: GuildQueue,
|
||||
history: GuildQueueHistory,
|
||||
currentTrack: Track,
|
||||
historyTracksListString: string
|
||||
historyTracksListString: string,
|
||||
translator: TFunction
|
||||
) {
|
||||
logger.debug('History exists with current track, gathering information.');
|
||||
|
||||
@@ -100,9 +112,11 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
||||
components.push(skipButton);
|
||||
|
||||
if (this.embedOptions.components.showButtonLabels) {
|
||||
previousButton.label = 'Previous';
|
||||
playPauseButton.label = queue.node.isPaused() ? 'Resume' : 'Pause';
|
||||
skipButton.label = 'Skip';
|
||||
previousButton.label = translator('musicPlayerCommon.controls.previous');
|
||||
playPauseButton.label = queue.node.isPaused()
|
||||
? translator('musicPlayerCommon.controls.resume')
|
||||
: translator('musicPlayerCommon.controls.pause');
|
||||
skipButton.label = translator('musicPlayerCommon.controls.skip');
|
||||
}
|
||||
|
||||
const embedActionRow: APIActionRowComponent<APIMessageActionRowComponent> = {
|
||||
@@ -114,18 +128,23 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedQueueAuthor(interaction, queue))
|
||||
.setAuthor(this.getEmbedQueueAuthor(interaction, queue, translator))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.audioPlaying} Now playing**\n` +
|
||||
`${this.getFormattedTrackUrl(currentTrack)}\n` +
|
||||
`**Requested by:** ${this.getDisplayTrackRequestedBy(currentTrack)}\n` +
|
||||
`${this.getDisplayQueueProgressBar(queue)}\n\n` +
|
||||
`${this.getDisplayRepeatMode(queue.repeatMode)}` +
|
||||
`**${this.embedOptions.icons.queue} Tracks in history**\n` +
|
||||
this.getDisplayTrackPlayingStatus(queue, translator) +
|
||||
'\n' +
|
||||
`${this.getFormattedTrackUrl(currentTrack, translator)}\n` +
|
||||
`${translator('musicPlayerCommon.requestedBy', {
|
||||
user: this.getDisplayTrackRequestedBy(currentTrack, translator)
|
||||
})}\n` +
|
||||
`${this.getDisplayQueueProgressBar(queue, translator)}\n` +
|
||||
`${formatRepeatModeDetailed(queue.repeatMode, this.embedOptions, translator)}\n` +
|
||||
`${translator('commands.history.tracksInHistoryTitle', {
|
||||
icon: this.embedOptions.icons.queue
|
||||
})}\n` +
|
||||
historyTracksListString
|
||||
)
|
||||
.setThumbnail(this.getTrackThumbnailUrl(currentTrack))
|
||||
.setFooter(this.getDisplayFullFooterInfo(interaction, history))
|
||||
.setFooter(this.getDisplayFullFooterInfo(interaction, history, translator))
|
||||
.setColor(this.embedOptions.colors.info)
|
||||
],
|
||||
components: [embedActionRow]
|
||||
@@ -133,12 +152,19 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
private getDisplayTrackPlayingStatus = (queue: GuildQueue, translator: TFunction): string => {
|
||||
return queue.node.isPaused()
|
||||
? translator('musicPlayerCommon.nowPausedTitle', { icon: this.embedOptions.icons.paused })
|
||||
: translator('musicPlayerCommon.nowPlayingTitle', { icon: this.embedOptions.icons.audioPlaying });
|
||||
};
|
||||
|
||||
private async handleNoCurrentTrack(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
history: GuildQueueHistory,
|
||||
historyTracksListString: string
|
||||
historyTracksListString: string,
|
||||
translator: TFunction
|
||||
) {
|
||||
logger.debug('History exists but there is no current track.');
|
||||
|
||||
@@ -146,13 +172,15 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedQueueAuthor(interaction, queue))
|
||||
.setAuthor(this.getEmbedQueueAuthor(interaction, queue, translator))
|
||||
.setDescription(
|
||||
`${this.getDisplayRepeatMode(queue.repeatMode)}` +
|
||||
`**${this.embedOptions.icons.queue} Tracks in history**\n` +
|
||||
translator('commands.history.tracksInHistoryTitle', {
|
||||
icon: this.embedOptions.icons.queue
|
||||
}) +
|
||||
'\n' +
|
||||
historyTracksListString
|
||||
)
|
||||
.setFooter(this.getDisplayFullFooterInfo(interaction, history))
|
||||
.setFooter(this.getDisplayFullFooterInfo(interaction, history, translator))
|
||||
.setColor(this.embedOptions.colors.info)
|
||||
]
|
||||
});
|
||||
@@ -162,7 +190,8 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
pageIndex: number,
|
||||
totalPages: number
|
||||
totalPages: number,
|
||||
translator: TFunction
|
||||
) {
|
||||
logger.debug('Specified page was higher than total pages.');
|
||||
|
||||
@@ -171,9 +200,11 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
||||
`Page **\`${pageIndex + 1}\`** is not a valid page number.\n\n` +
|
||||
`There are only a total of **\`${totalPages}\`** pages in the history.`
|
||||
translator('commands.history.invalidPageNumber', {
|
||||
icon: this.embedOptions.icons.warning,
|
||||
page: pageIndex + 1,
|
||||
count: totalPages
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
]
|
||||
@@ -189,24 +220,27 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
||||
return Math.ceil(history.tracks.data.length / 10) || 1;
|
||||
}
|
||||
|
||||
private getHistoryTracksListString(history: GuildQueueHistory, pageIndex: number): string {
|
||||
private getHistoryTracksListString(history: GuildQueueHistory, pageIndex: number, translator: TFunction): string {
|
||||
if (!history || history.tracks.data.length === 0) {
|
||||
return 'The history is empty, add some tracks with **`/play`**!';
|
||||
return translator('commands.history.emptyHistory', {
|
||||
playCommand: formatSlashCommand('play', translator)
|
||||
});
|
||||
}
|
||||
|
||||
return history.tracks.data
|
||||
.slice(pageIndex * 10, pageIndex * 10 + 10)
|
||||
.map((track, index) => {
|
||||
return `**${pageIndex * 10 + index + 1}.** ${this.getDisplayTrackDurationAndUrl(track)}`;
|
||||
return `**${pageIndex * 10 + index + 1}.** ${this.getDisplayTrackDurationAndUrl(track, translator)}`;
|
||||
})
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
private getDisplayFullFooterInfo(
|
||||
interaction: ChatInputCommandInteraction,
|
||||
history: GuildQueueHistory
|
||||
history: GuildQueueHistory,
|
||||
translator: TFunction
|
||||
): EmbedFooterData {
|
||||
const pagination = this.getFooterDisplayPageInfo(interaction, history);
|
||||
const pagination = this.getFooterDisplayPageInfo(interaction, history, translator);
|
||||
|
||||
const fullFooterData = {
|
||||
text: `${pagination.text}`
|
||||
|
||||
@@ -5,35 +5,37 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ
|
||||
import { checkInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
import { checkVoicePermissionJoinAndTalk } from '../../../utils/validation/permissionValidator';
|
||||
import { Logger } from 'pino';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { formatSlashCommand } from '../../../common/formattingUtils';
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
class JoinCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName('join')
|
||||
.setDescription('The bot will join the voice channel if not already in one.');
|
||||
const data = localizeCommand(new SlashCommandBuilder().setName('join'));
|
||||
super(data);
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
await this.runValidators({ interaction, executionId }, [checkInVoiceChannel, checkVoicePermissionJoinAndTalk]);
|
||||
|
||||
const existingQueue = useQueue(interaction.guild!.id);
|
||||
|
||||
if (existingQueue) {
|
||||
return await this.handleExisitingQueue(interaction, existingQueue);
|
||||
return await this.handleExisitingQueue(interaction, existingQueue, translator);
|
||||
}
|
||||
|
||||
const queue = this.createQueue(interaction);
|
||||
if (!queue) {
|
||||
return await this.handleCouldNotConnect(interaction);
|
||||
return await this.handleCouldNotConnect(interaction, translator);
|
||||
}
|
||||
|
||||
await this.connectToVoiceChannel(logger, queue, interaction);
|
||||
if (!queue.dispatcher) {
|
||||
return await this.handleCouldNotConnect(interaction);
|
||||
return await this.handleCouldNotConnect(interaction, translator);
|
||||
}
|
||||
|
||||
logger.debug('Responding with success embed.');
|
||||
@@ -42,9 +44,11 @@ class JoinCommand extends BaseSlashCommandInteraction {
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.success} Joined channel**\n` +
|
||||
`Connected to voice channel: <#${queue.dispatcher.channel.id}>\n\n` +
|
||||
'To add tracks, use the **`/play`** command!'
|
||||
translator('commands.join.joinedChannel', {
|
||||
icon: this.embedOptions.icons.success,
|
||||
channel: `<#${queue.dispatcher.channel.id}>`,
|
||||
playCommand: formatSlashCommand('play', translator)
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.success)
|
||||
]
|
||||
@@ -83,32 +87,42 @@ class JoinCommand extends BaseSlashCommandInteraction {
|
||||
}
|
||||
}
|
||||
|
||||
private async handleCouldNotConnect(interaction: ChatInputCommandInteraction): Promise<Message> {
|
||||
private async handleCouldNotConnect(
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
||||
'Could not join voice channel, please try again.'
|
||||
translator('commands.join.couldNotJoin', {
|
||||
icon: this.embedOptions.icons.warning
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
private async handleExisitingQueue(interaction: ChatInputCommandInteraction, queue: GuildQueue): Promise<Message> {
|
||||
private async handleExisitingQueue(
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
const connectedChannel = queue.dispatcher?.channel;
|
||||
const channelMention = connectedChannel?.id ? `<#${connectedChannel.id}>` : 'Unknown';
|
||||
const channelMention = connectedChannel?.id ? `<#${connectedChannel.id}>` : '<#0>';
|
||||
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
||||
`I am already connected to voice channel ${channelMention}.\n\n` +
|
||||
'To disconnect me from the channel, use the **`/leave`** command.'
|
||||
translator('commands.join.alreadyConnected', {
|
||||
icon: this.embedOptions.icons.warning,
|
||||
channel: channelMention,
|
||||
leaveCommand: formatSlashCommand('leave', translator)
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
]
|
||||
|
||||
@@ -4,18 +4,19 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { formatSlashCommand } from '../../../common/formattingUtils';
|
||||
|
||||
class LeaveCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName('leave')
|
||||
.setDescription('Clear the queue and remove bot from voice channel.');
|
||||
const data = localizeCommand(new SlashCommandBuilder().setName('leave'));
|
||||
super(data);
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
@@ -34,9 +35,10 @@ class LeaveCommand extends BaseSlashCommandInteraction {
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.success} Leaving channel**\n` +
|
||||
'Cleared the track queue and left voice channel.\n\n' +
|
||||
'To play more music, use the **`/play`** command!'
|
||||
translator('commands.leave.leavingChannel', {
|
||||
icon: this.embedOptions.icons.success,
|
||||
playCommand: formatSlashCommand('play', translator)
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.success)
|
||||
]
|
||||
|
||||
@@ -11,30 +11,34 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { formatRepeatMode } from '../../../common/formattingUtils';
|
||||
|
||||
class LoopCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName('loop')
|
||||
.setDescription('Toggle looping a track, the whole queue or autoplay.')
|
||||
.addIntegerOption(() =>
|
||||
new SlashCommandIntegerOption()
|
||||
.setName('mode')
|
||||
.setDescription('Loop mode: Track, queue, autoplay or disabled.')
|
||||
.setRequired(false)
|
||||
.addChoices(
|
||||
{ name: 'Track', value: QueueRepeatMode.TRACK },
|
||||
{ name: 'Queue', value: QueueRepeatMode.QUEUE },
|
||||
{ name: 'Autoplay', value: QueueRepeatMode.AUTOPLAY },
|
||||
{ name: 'Disabled', value: QueueRepeatMode.OFF }
|
||||
)
|
||||
);
|
||||
const data = localizeCommand(
|
||||
new SlashCommandBuilder()
|
||||
.setName('loop')
|
||||
.addIntegerOption(() =>
|
||||
new SlashCommandIntegerOption()
|
||||
.setName('mode')
|
||||
.setRequired(false)
|
||||
.addChoices(
|
||||
{ value: QueueRepeatMode.TRACK, name: ' ' },
|
||||
{ value: QueueRepeatMode.QUEUE, name: ' ' },
|
||||
{ value: QueueRepeatMode.AUTOPLAY, name: ' ' },
|
||||
{ value: QueueRepeatMode.OFF, name: ' ' }
|
||||
)
|
||||
)
|
||||
);
|
||||
super(data);
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
@@ -48,34 +52,44 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
||||
const currentRepeatMode: QueueRepeatMode = queue.repeatMode;
|
||||
|
||||
if (!userInputRepeatMode && userInputRepeatMode !== 0) {
|
||||
return await this.handleNoInputMode(logger, interaction, currentRepeatMode);
|
||||
return await this.handleNoInputMode(logger, interaction, currentRepeatMode, translator);
|
||||
}
|
||||
|
||||
if (userInputRepeatMode === currentRepeatMode) {
|
||||
return await this.handleSameMode(logger, interaction, userInputRepeatMode);
|
||||
return await this.handleSameMode(logger, interaction, userInputRepeatMode, translator);
|
||||
}
|
||||
|
||||
return await this.handleChangeMode(logger, interaction, queue, currentRepeatMode, userInputRepeatMode);
|
||||
return await this.handleChangeMode(
|
||||
logger,
|
||||
interaction,
|
||||
queue,
|
||||
currentRepeatMode,
|
||||
userInputRepeatMode,
|
||||
translator
|
||||
);
|
||||
}
|
||||
|
||||
private async handleNoInputMode(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
currentRepeatMode: QueueRepeatMode
|
||||
currentRepeatMode: QueueRepeatMode,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
logger.debug('No repeat mode was provided, responding with current repeat mode.');
|
||||
|
||||
const repeatModeEmbedIcon =
|
||||
currentRepeatMode === 3 ? this.embedOptions.icons.autoplay : this.embedOptions.icons.loop;
|
||||
const repeatModeEmbedName = this.getRepeatModeEmbedName(currentRepeatMode);
|
||||
const repeatModeEmbedName = formatRepeatMode(currentRepeatMode, translator);
|
||||
|
||||
logger.debug('Responding with info embed.');
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${repeatModeEmbedIcon} Current loop mode**\n` +
|
||||
`The looping mode is currently set to **\`${repeatModeEmbedName}\`**.`
|
||||
translator('commands.loop.loopModeInformation', {
|
||||
icon: repeatModeEmbedIcon,
|
||||
mode: repeatModeEmbedName
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.info)
|
||||
]
|
||||
@@ -85,17 +99,20 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
||||
private async handleSameMode(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
currentRepeatMode: QueueRepeatMode
|
||||
currentRepeatMode: QueueRepeatMode,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
const repeatModeEmbedName = this.getRepeatModeEmbedName(currentRepeatMode);
|
||||
const repeatModeEmbedName = formatRepeatMode(currentRepeatMode, translator);
|
||||
logger.debug(`Loop mode is already set to '${repeatModeEmbedName}'.`);
|
||||
logger.debug('Responding with warning embed.');
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
||||
`Loop mode is already **\`${repeatModeEmbedName}\`**.`
|
||||
translator('commands.loop.alreadySet', {
|
||||
icon: this.embedOptions.icons.warning,
|
||||
mode: repeatModeEmbedName
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
]
|
||||
@@ -107,10 +124,15 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
fromRepeatMode: QueueRepeatMode,
|
||||
toRepeatMode: QueueRepeatMode
|
||||
toRepeatMode: QueueRepeatMode,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
const newRepeatModeEmbedName = this.getRepeatModeEmbedName(toRepeatMode);
|
||||
const getChangedRepeatModeEmbedReply = this.getChangedRepeatModeEmbedReply(fromRepeatMode, toRepeatMode);
|
||||
const newRepeatModeEmbedName = formatRepeatMode(toRepeatMode, translator);
|
||||
const getChangedRepeatModeEmbedReply = this.getChangedRepeatModeEmbedReply(
|
||||
fromRepeatMode,
|
||||
toRepeatMode,
|
||||
translator
|
||||
);
|
||||
|
||||
queue.setRepeatMode(toRepeatMode);
|
||||
logger.debug(`Loop mode changed to '${newRepeatModeEmbedName}'.`);
|
||||
@@ -126,35 +148,37 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
||||
});
|
||||
}
|
||||
|
||||
private getRepeatModeEmbedName(repeatMode: QueueRepeatMode): string {
|
||||
const repeatModeEmbedString: { [key in QueueRepeatMode]: string } = {
|
||||
[QueueRepeatMode.OFF]: 'disabled',
|
||||
[QueueRepeatMode.TRACK]: 'track',
|
||||
[QueueRepeatMode.QUEUE]: 'queue',
|
||||
[QueueRepeatMode.AUTOPLAY]: 'autoplay'
|
||||
};
|
||||
|
||||
return repeatModeEmbedString[repeatMode];
|
||||
}
|
||||
|
||||
private getChangedRepeatModeEmbedReply(fromRepeatMode: QueueRepeatMode, toRepeatMode: QueueRepeatMode): string {
|
||||
const fromRepeatModeEmbedName = this.getRepeatModeEmbedName(fromRepeatMode);
|
||||
const toRepeatModeEmbedName = this.getRepeatModeEmbedName(toRepeatMode);
|
||||
private getChangedRepeatModeEmbedReply(
|
||||
fromRepeatMode: QueueRepeatMode,
|
||||
toRepeatMode: QueueRepeatMode,
|
||||
translator: TFunction
|
||||
): string {
|
||||
const fromRepeatModeEmbedName = formatRepeatMode(fromRepeatMode, translator);
|
||||
const toRepeatModeEmbedName = formatRepeatMode(toRepeatMode, translator);
|
||||
|
||||
let repeatModeIcon = this.embedOptions.icons.looping;
|
||||
let newRepeatModeMessage = `The ${toRepeatModeEmbedName} will now play on repeat!`;
|
||||
let newRepeatModeMessage: string = translator('commands.loop.willNowPlay', {
|
||||
mode: toRepeatModeEmbedName
|
||||
});
|
||||
|
||||
if (toRepeatMode === QueueRepeatMode.OFF) {
|
||||
repeatModeIcon = this.embedOptions.icons.success;
|
||||
newRepeatModeMessage = `The ${fromRepeatModeEmbedName} will no longer play on repeat!`;
|
||||
newRepeatModeMessage = translator('commands.loop.willNoLongerPlay', {
|
||||
mode: fromRepeatModeEmbedName
|
||||
});
|
||||
} else if (toRepeatMode === QueueRepeatMode.AUTOPLAY) {
|
||||
repeatModeIcon = this.embedOptions.icons.autoplaying;
|
||||
newRepeatModeMessage = 'When the queue is empty, similar tracks will start playing!';
|
||||
newRepeatModeMessage = translator('commands.loop.willAutoplay');
|
||||
}
|
||||
|
||||
return (
|
||||
`**${repeatModeIcon} Loop mode changed**\n` +
|
||||
`Changing loop mode from **\`${fromRepeatModeEmbedName}\`** to **\`${toRepeatModeEmbedName}\`**.\n\n` +
|
||||
translator('commands.loop.modeChanged', {
|
||||
icon: repeatModeIcon,
|
||||
fromName: fromRepeatModeEmbedName,
|
||||
toName: toRepeatModeEmbedName
|
||||
}) +
|
||||
'\n' +
|
||||
'\n' +
|
||||
newRepeatModeMessage
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,27 +6,25 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
class LyricsCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName('lyrics')
|
||||
.setDescription('Search Genius lyrics for current or specified track.')
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName('query')
|
||||
.setDescription('Search query by text or URL.')
|
||||
.setRequired(false)
|
||||
.setMinLength(2)
|
||||
.setMaxLength(500)
|
||||
.setAutocomplete(true)
|
||||
);
|
||||
const data = localizeCommand(
|
||||
new SlashCommandBuilder()
|
||||
.setName('lyrics')
|
||||
.addStringOption((option) =>
|
||||
option.setName('query').setRequired(false).setMinLength(2).setMaxLength(500).setAutocomplete(true)
|
||||
)
|
||||
);
|
||||
super(data);
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
const query: string = interaction.options.getString('query')!;
|
||||
@@ -54,14 +52,14 @@ class LyricsCommand extends BaseSlashCommandInteraction {
|
||||
|
||||
if (!finalLyricsData) {
|
||||
logger.debug('No matching lyrics found.');
|
||||
return await this.sendNoLyricsFoundEmbed(logger, interaction, geniusSearchQuery);
|
||||
return await this.sendNoLyricsFoundEmbed(logger, interaction, geniusSearchQuery, translator);
|
||||
}
|
||||
|
||||
if (finalLyricsData.lyrics.length > 3800) {
|
||||
return await this.sendMultipleLyricsMessages(logger, interaction, finalLyricsData);
|
||||
return await this.sendMultipleLyricsMessages(logger, interaction, finalLyricsData, translator);
|
||||
}
|
||||
|
||||
return await this.sendLyricsEmbed(logger, interaction, finalLyricsData);
|
||||
return await this.sendLyricsEmbed(logger, interaction, finalLyricsData, translator);
|
||||
}
|
||||
|
||||
private getGeniusSearchQuery(logger: Logger, query: string, queue: GuildQueue): string {
|
||||
@@ -159,15 +157,18 @@ class LyricsCommand extends BaseSlashCommandInteraction {
|
||||
private async sendNoLyricsFoundEmbed(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
geniusSearchQuery: string
|
||||
geniusSearchQuery: string,
|
||||
translator: TFunction
|
||||
) {
|
||||
logger.debug('Responding with warning embed.');
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} No lyrics found**\n` +
|
||||
`There was no Genius lyrics found for track **${geniusSearchQuery}**.`
|
||||
translator('commands.lyrics.noLyricsFound', {
|
||||
icon: this.embedOptions.icons.warning,
|
||||
query: geniusSearchQuery
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
]
|
||||
@@ -177,7 +178,8 @@ class LyricsCommand extends BaseSlashCommandInteraction {
|
||||
private async sendMultipleLyricsMessages(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
geniusLyricsResult: LyricsData
|
||||
geniusLyricsResult: LyricsData,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
logger.debug('Lyrics text too long, splitting into multiple messages.');
|
||||
const messageCount: number = Math.ceil(geniusLyricsResult.lyrics.length / 3800);
|
||||
@@ -185,9 +187,13 @@ class LyricsCommand extends BaseSlashCommandInteraction {
|
||||
embedList.push(
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.queue} Showing lyrics**\n` +
|
||||
`**Track: [${geniusLyricsResult.title}](${geniusLyricsResult.url})**\n` +
|
||||
`**Artist: [${geniusLyricsResult.artist.name}](${geniusLyricsResult.artist.url})**\n\n`
|
||||
translator('commands.lyrics.lyricsEmbed', {
|
||||
icon: this.embedOptions.icons.queue,
|
||||
trackTitle: geniusLyricsResult.title,
|
||||
trackUrl: geniusLyricsResult.url,
|
||||
artistName: geniusLyricsResult.artist.name,
|
||||
artistUrl: geniusLyricsResult.artist.url
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.info)
|
||||
);
|
||||
@@ -208,16 +214,23 @@ class LyricsCommand extends BaseSlashCommandInteraction {
|
||||
private async sendLyricsEmbed(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
geniusLyricsResult: LyricsData
|
||||
geniusLyricsResult: LyricsData,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
logger.debug('Responding with info embed.');
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.queue} Showing lyrics**\n` +
|
||||
`**Track: [${geniusLyricsResult.title}](${geniusLyricsResult.url})**\n` +
|
||||
`**Artist: [${geniusLyricsResult.artist.name}](${geniusLyricsResult.artist.url})**\n\n` +
|
||||
translator('commands.lyrics.lyricsEmbed', {
|
||||
icon: this.embedOptions.icons.queue,
|
||||
trackTitle: geniusLyricsResult.title,
|
||||
trackUrl: geniusLyricsResult.url,
|
||||
artistName: geniusLyricsResult.artist.name,
|
||||
artistUrl: geniusLyricsResult.artist.url
|
||||
}) +
|
||||
'\n' +
|
||||
'\n' +
|
||||
`\`\`\`fix\n${geniusLyricsResult.lyrics}\`\`\``
|
||||
)
|
||||
.setColor(this.embedOptions.colors.info)
|
||||
|
||||
@@ -5,32 +5,25 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ
|
||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
import { Logger } from 'pino';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { formatSlashCommand } from '../../../common/formattingUtils';
|
||||
|
||||
class MoveCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName('move')
|
||||
.setDescription('Move a track to a specified position in queue.')
|
||||
.addIntegerOption((option) =>
|
||||
option
|
||||
.setName('from')
|
||||
.setDescription('The position of the track to move')
|
||||
.setMinValue(1)
|
||||
.setRequired(true)
|
||||
)
|
||||
.addIntegerOption((option) =>
|
||||
option
|
||||
.setName('to')
|
||||
.setDescription('The position to move the track to')
|
||||
.setMinValue(1)
|
||||
.setRequired(true)
|
||||
);
|
||||
const data = localizeCommand(
|
||||
new SlashCommandBuilder()
|
||||
.setName('move')
|
||||
.addIntegerOption((option) => option.setName('from').setMinValue(1).setRequired(true))
|
||||
.addIntegerOption((option) => option.setName('to').setMinValue(1).setRequired(true))
|
||||
);
|
||||
super(data);
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
@@ -43,7 +36,14 @@ class MoveCommand extends BaseSlashCommandInteraction {
|
||||
|
||||
const fromPositionInput: number = interaction.options.getInteger('from')!;
|
||||
const toPositionInput: number = interaction.options.getInteger('to')!;
|
||||
return await this.handleMoveTrackToPosition(logger, interaction, queue, fromPositionInput, toPositionInput);
|
||||
return await this.handleMoveTrackToPosition(
|
||||
logger,
|
||||
interaction,
|
||||
queue,
|
||||
fromPositionInput,
|
||||
toPositionInput,
|
||||
translator
|
||||
);
|
||||
}
|
||||
|
||||
private async handleMoveTrackToPosition(
|
||||
@@ -51,7 +51,8 @@ class MoveCommand extends BaseSlashCommandInteraction {
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
fromPosition: number,
|
||||
toPosition: number
|
||||
toPosition: number,
|
||||
translator: TFunction
|
||||
) {
|
||||
if (fromPosition > queue.tracks.data.length || toPosition > queue.tracks.data.length) {
|
||||
logger.debug('One of the specified track positions was higher than total tracks.');
|
||||
@@ -60,13 +61,14 @@ class MoveCommand extends BaseSlashCommandInteraction {
|
||||
toPosition,
|
||||
queue,
|
||||
logger,
|
||||
interaction
|
||||
interaction,
|
||||
translator
|
||||
);
|
||||
} else {
|
||||
const trackToMove: Track = queue.tracks.data[fromPosition - 1];
|
||||
queue.node.move(trackToMove, toPosition - 1);
|
||||
logger.debug(`Moved track from position ${fromPosition} to position ${toPosition} in queue`);
|
||||
return await this.respondWithSuccessEmbed(trackToMove, interaction, fromPosition, toPosition);
|
||||
return await this.respondWithSuccessEmbed(trackToMove, interaction, fromPosition, toPosition, translator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,16 +77,21 @@ class MoveCommand extends BaseSlashCommandInteraction {
|
||||
toPosition: number,
|
||||
queue: GuildQueue,
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
) {
|
||||
logger.debug('One of the specified track positions was higher than total tracks.');
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
||||
`You cannot move track in position **\`${fromPosition}\`** to position **\`${toPosition}\`**. There are only **\`${queue.tracks.data.length}\`** tracks in the queue.\n\n` +
|
||||
'View tracks added to the queue with **`/queue`**.'
|
||||
translator('commands.move.trackPositionHigherThanQueueLength', {
|
||||
icon: this.embedOptions.icons.warning,
|
||||
fromPosition,
|
||||
toPosition,
|
||||
count: queue.tracks.data.length,
|
||||
queueCommand: formatSlashCommand('queue', translator)
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
]
|
||||
@@ -95,16 +102,20 @@ class MoveCommand extends BaseSlashCommandInteraction {
|
||||
movedTrack: Track,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
fromPosition: number,
|
||||
toPosition: number
|
||||
toPosition: number,
|
||||
translator: TFunction
|
||||
) {
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.moved} Moved track**\n` +
|
||||
`${this.getDisplayTrackDurationAndUrl(movedTrack)}\n\n` +
|
||||
`Track has been moved from position **\`${fromPosition}\`** to position **\`${toPosition}\`**.`
|
||||
translator('commands.move.trackMoved', {
|
||||
icon: this.embedOptions.icons.moved,
|
||||
track: this.getDisplayTrackDurationAndUrl(movedTrack, translator),
|
||||
fromPosition,
|
||||
toPosition
|
||||
})
|
||||
)
|
||||
.setThumbnail(this.getTrackThumbnailUrl(movedTrack))
|
||||
.setColor(this.embedOptions.colors.success)
|
||||
|
||||
@@ -14,18 +14,20 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType, TrackMetadata } from '../../../types/interactionTypes';
|
||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { formatRepeatModeDetailed } from '../../../common/formattingUtils';
|
||||
|
||||
class NowPlayingCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName('nowplaying')
|
||||
.setDescription('Show information about the current track.');
|
||||
const data = localizeCommand(new SlashCommandBuilder().setName('nowplaying'));
|
||||
super(data);
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
@@ -38,11 +40,15 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
|
||||
|
||||
const tracksInQueueCount: number = queue.tracks.data.length;
|
||||
const currentTrack: Track = queue.currentTrack!;
|
||||
const displayTrackUrl: string = this.getFormattedTrackUrl(currentTrack);
|
||||
const displayTrackRequestedBy: string = this.getDisplayTrackRequestedBy(currentTrack);
|
||||
const displayTrackPlayingStatus: string = this.getDisplayTrackPlayingStatus(queue);
|
||||
const displayQueueRepeatMode: string = this.getDisplayQueueRepeatMode(queue);
|
||||
const displayEmbedProgressBar: string = this.getDisplayQueueProgressBar(queue);
|
||||
const displayTrackUrl: string = this.getFormattedTrackUrl(currentTrack, translator);
|
||||
const displayTrackRequestedBy: string = this.getDisplayTrackRequestedBy(currentTrack, translator);
|
||||
const displayTrackPlayingStatus: string = this.getDisplayTrackPlayingStatus(queue, translator);
|
||||
const displayQueueRepeatMode: string = formatRepeatModeDetailed(
|
||||
queue.repeatMode,
|
||||
this.embedOptions,
|
||||
translator
|
||||
);
|
||||
const displayEmbedProgressBar: string = this.getDisplayQueueProgressBar(queue, translator);
|
||||
|
||||
const components: APIMessageActionRowComponent[] = [];
|
||||
|
||||
@@ -69,9 +75,11 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
|
||||
components.push(skipButton);
|
||||
|
||||
if (this.embedOptions.components.showButtonLabels) {
|
||||
previousButton.label = 'Previous';
|
||||
playPauseButton.label = queue.node.isPaused() ? 'Resume' : 'Pause';
|
||||
skipButton.label = 'Skip';
|
||||
previousButton.label = translator('musicPlayerCommon.controls.previous');
|
||||
playPauseButton.label = queue.node.isPaused()
|
||||
? translator('musicPlayerCommon.controls.resume')
|
||||
: translator('musicPlayerCommon.controls.pause');
|
||||
skipButton.label = translator('musicPlayerCommon.controls.skip');
|
||||
}
|
||||
|
||||
const embedActionRow: APIActionRowComponent<APIMessageActionRowComponent> = {
|
||||
@@ -83,17 +91,21 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedQueueAuthor(interaction, queue))
|
||||
.setAuthor(this.getEmbedQueueAuthor(interaction, queue, translator))
|
||||
.setDescription(
|
||||
`${displayTrackPlayingStatus}\n` +
|
||||
`${displayTrackUrl}\n` +
|
||||
`**Requested by:** ${displayTrackRequestedBy}\n` +
|
||||
`${displayEmbedProgressBar}\n\n ` +
|
||||
`${translator('musicPlayerCommon.requestedBy', {
|
||||
user: displayTrackRequestedBy
|
||||
})}\n` +
|
||||
`${displayEmbedProgressBar}\n` +
|
||||
`${displayQueueRepeatMode}\n\n`
|
||||
)
|
||||
.addFields(this.getEmbedFields(currentTrack))
|
||||
.addFields(this.getEmbedFields(currentTrack, translator))
|
||||
.setFooter({
|
||||
text: tracksInQueueCount ? `${tracksInQueueCount} other tracks in the queue...` : ' '
|
||||
text: tracksInQueueCount
|
||||
? translator('commands.nowplaying.otherTracksInQueue', { count: tracksInQueueCount })
|
||||
: ' '
|
||||
})
|
||||
.setThumbnail(this.getTrackThumbnailUrl(queue.currentTrack!))
|
||||
.setColor(this.embedOptions.colors.info)
|
||||
@@ -102,37 +114,34 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
|
||||
});
|
||||
}
|
||||
|
||||
private getDisplayPlays(currentTrack: Track | undefined): string {
|
||||
private getDisplayPlays(currentTrack: Track | undefined, translator: TFunction): string {
|
||||
const trackMetadata = currentTrack?.metadata as TrackMetadata;
|
||||
|
||||
let displayPlays: string =
|
||||
(currentTrack?.views || trackMetadata?.bridge?.views || 0).toLocaleString('en-US') ?? '0';
|
||||
|
||||
if (displayPlays === '0') {
|
||||
displayPlays = 'Unavailable';
|
||||
}
|
||||
|
||||
return displayPlays;
|
||||
return translator('commands.nowplaying.playCount', {
|
||||
count: currentTrack?.views || trackMetadata?.bridge?.views || 0
|
||||
});
|
||||
}
|
||||
|
||||
private getDisplayTrackAuthor(currentTrack: Track | undefined): string {
|
||||
let author: string = currentTrack?.author ? currentTrack.author : 'Unavailable';
|
||||
if (author === 'cdn.discordapp.com') {
|
||||
author = 'Unavailable';
|
||||
private getDisplayTrackAuthor(currentTrack: Track | undefined, translator: TFunction): string {
|
||||
let author = currentTrack?.author;
|
||||
if (!author || author === 'cdn.discordapp.com') {
|
||||
author = translator('musicPlayerCommon.unavailableAuthor');
|
||||
}
|
||||
return author;
|
||||
}
|
||||
|
||||
private getTrackSourceString(currentTrack: Track): string {
|
||||
private getTrackSourceString(currentTrack: Track, translator: TFunction): string {
|
||||
const sourceStringsFormatted: Map<string, string> = new Map([
|
||||
['youtube', 'YouTube'],
|
||||
['soundcloud', 'SoundCloud'],
|
||||
['spotify', 'Spotify'],
|
||||
['apple_music', 'Apple Music'],
|
||||
['arbitrary', 'Direct source']
|
||||
['arbitrary', translator('commands.pause.directSource')]
|
||||
]);
|
||||
|
||||
return sourceStringsFormatted.get(currentTrack.raw.source!) ?? 'Unavailable';
|
||||
return (
|
||||
sourceStringsFormatted.get(currentTrack.raw.source!) ?? translator('musicPlayerCommon.unavailableSource')
|
||||
);
|
||||
}
|
||||
|
||||
private getTrackSourceIcon(currentTrack: Track): string {
|
||||
@@ -147,59 +156,34 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
|
||||
return sourceIcons.get(currentTrack.raw.source!) ?? '';
|
||||
}
|
||||
|
||||
private getDisplayTrackSource(currentTrack: Track) {
|
||||
const trackSource: string = this.getTrackSourceString(currentTrack) ?? 'Unavailable';
|
||||
private getDisplayTrackSource(currentTrack: Track, translator: TFunction) {
|
||||
const trackSource: string = this.getTrackSourceString(currentTrack, translator);
|
||||
const trackSourceIcon: string = this.getTrackSourceIcon(currentTrack) ?? '';
|
||||
|
||||
return `**${trackSourceIcon} [${trackSource}](${currentTrack.raw.url ?? currentTrack.url})**`;
|
||||
}
|
||||
|
||||
private getRepeatModeString(repeatMode: number): string {
|
||||
const loopModesFormatted: Map<number, string> = new Map([
|
||||
[0, 'disabled'],
|
||||
[1, 'track'],
|
||||
[2, 'queue'],
|
||||
[3, 'autoplay']
|
||||
]);
|
||||
|
||||
return loopModesFormatted.get(repeatMode)!;
|
||||
}
|
||||
|
||||
private getDisplayQueueRepeatMode = (queue: GuildQueue): string => {
|
||||
const repeatMode: number = queue.repeatMode;
|
||||
if (repeatMode === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const loopModeUserString: string = this.getRepeatModeString(repeatMode);
|
||||
const icon = repeatMode === 3 ? this.embedOptions.icons.autoplay : this.embedOptions.icons.loop;
|
||||
return (
|
||||
`**${icon} Looping**\n` +
|
||||
`Loop mode is set to **\`${loopModeUserString}\`**. You can change it with **\`/loop\`**.`
|
||||
);
|
||||
};
|
||||
|
||||
private getDisplayTrackPlayingStatus = (queue: GuildQueue): string => {
|
||||
private getDisplayTrackPlayingStatus = (queue: GuildQueue, translator: TFunction): string => {
|
||||
return queue.node.isPaused()
|
||||
? '**Currently Paused**'
|
||||
: `**${this.embedOptions.icons.audioPlaying} Now Playing**`;
|
||||
? translator('musicPlayerCommon.nowPausedTitle', { icon: this.embedOptions.icons.paused })
|
||||
: translator('musicPlayerCommon.nowPlayingTitle', { icon: this.embedOptions.icons.audioPlaying });
|
||||
};
|
||||
|
||||
private getEmbedFields = (currentTrack: Track): EmbedField[] => {
|
||||
private getEmbedFields = (currentTrack: Track, translator: TFunction): EmbedField[] => {
|
||||
const fields: EmbedField[] = [
|
||||
{
|
||||
name: '**Author**',
|
||||
value: this.getDisplayTrackAuthor(currentTrack),
|
||||
name: translator('commands.nowplaying.embedFields.author'),
|
||||
value: this.getDisplayTrackAuthor(currentTrack, translator),
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: '**Plays**',
|
||||
value: this.getDisplayPlays(currentTrack),
|
||||
name: translator('commands.nowplaying.embedFields.plays'),
|
||||
value: this.getDisplayPlays(currentTrack, translator),
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: '**Track source**',
|
||||
value: this.getDisplayTrackSource(currentTrack),
|
||||
name: translator('commands.nowplaying.embedFields.source'),
|
||||
value: this.getDisplayTrackSource(currentTrack, translator),
|
||||
inline: true
|
||||
}
|
||||
];
|
||||
|
||||
@@ -5,16 +5,18 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
|
||||
class PauseCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder().setName('pause').setDescription('Toggle pause for the current track.');
|
||||
const data = localizeCommand(new SlashCommandBuilder().setName('pause'));
|
||||
super(data);
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
@@ -35,9 +37,16 @@ class PauseCommand extends BaseSlashCommandInteraction {
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.pauseResumed} ${
|
||||
queue.node.isPaused() ? 'Paused Track' : 'Resumed track'
|
||||
}**\n ${this.getDisplayTrackDurationAndUrl(currentTrack)}`
|
||||
translator(
|
||||
queue.node.isPaused()
|
||||
? 'commands.pause.pauseConfirmation'
|
||||
: 'commands.pause.resumeConfirmation',
|
||||
{
|
||||
icon: this.embedOptions.icons.success
|
||||
}
|
||||
) +
|
||||
'\n' +
|
||||
this.getDisplayTrackDurationAndUrl(currentTrack, translator)
|
||||
)
|
||||
.setThumbnail(currentTrack.thumbnail)
|
||||
.setColor(this.embedOptions.colors.success)
|
||||
|
||||
@@ -6,27 +6,26 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ
|
||||
import { checkVoicePermissionJoinAndTalk } from '../../../utils/validation/permissionValidator';
|
||||
import { transformQuery } from '../../../utils/validation/searchQueryValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { formatSlashCommand } from '../../../common/formattingUtils';
|
||||
|
||||
class PlayCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName('play')
|
||||
.setDescription('Add a track or playlist to the queue by search query or URL.')
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName('query')
|
||||
.setDescription('Search query by text or URL')
|
||||
.setRequired(true)
|
||||
.setMinLength(2)
|
||||
.setMaxLength(500)
|
||||
.setAutocomplete(true)
|
||||
);
|
||||
const data = localizeCommand(
|
||||
new SlashCommandBuilder()
|
||||
.setName('play')
|
||||
.addStringOption((option) =>
|
||||
option.setName('query').setRequired(true).setMinLength(2).setMaxLength(500).setAutocomplete(true)
|
||||
)
|
||||
);
|
||||
super(data);
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
await this.runValidators({ interaction, executionId }, [checkInVoiceChannel]);
|
||||
|
||||
@@ -43,14 +42,14 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
||||
|
||||
const searchResult = await this.searchTrack(player, transformedQuery, interaction, logger);
|
||||
if (!searchResult || searchResult.tracks.length === 0) {
|
||||
return await this.handleNoResultsFound(transformedQuery, interaction, logger);
|
||||
return await this.handleNoResultsFound(transformedQuery, interaction, logger, translator);
|
||||
}
|
||||
|
||||
queue = useQueue(interaction.guild!.id)!;
|
||||
const queueSize = queue?.size ?? 0;
|
||||
|
||||
if ((searchResult.playlist! && searchResult.tracks.length) > this.playerOptions.maxQueueSize - queueSize) {
|
||||
return await this.handlePlaylistTooLarge(searchQuery, interaction, logger);
|
||||
return await this.handlePlaylistTooLarge(searchQuery, interaction, logger, translator);
|
||||
}
|
||||
|
||||
const track: Track | void = await this.addResultsToPlayer(
|
||||
@@ -67,7 +66,7 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
||||
throw new Error('Failed to add track to player.');
|
||||
}
|
||||
|
||||
return await this.handleResultAddedToQueue(track, searchResult, interaction, logger);
|
||||
return await this.handleResultAddedToQueue(track, searchResult, interaction, logger, translator);
|
||||
}
|
||||
|
||||
private async searchTrack(
|
||||
@@ -149,18 +148,39 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
||||
track: Track,
|
||||
searchResult: SearchResult,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
logger: Logger
|
||||
logger: Logger,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
logger.debug('Result found and added with player.play(), added to queue.');
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
const trackUrl = this.getDisplayTrackDurationAndUrl(track);
|
||||
const trackUrl = this.getDisplayTrackDurationAndUrl(track, translator);
|
||||
|
||||
let message = `${this.embedOptions.icons.success} **Added to queue**\n${trackUrl}`;
|
||||
let message =
|
||||
translator('commands.play.addedToQueueTitle', {
|
||||
icon: this.embedOptions.icons.success
|
||||
}) +
|
||||
'\n' +
|
||||
trackUrl;
|
||||
if (searchResult.playlist) {
|
||||
const otherTracksString = `And **${searchResult.tracks.length}** more tracks... **\`/queue\`** to view all.`;
|
||||
message = `${this.embedOptions.icons.success} **Added playlist to queue**\n${trackUrl}\n\n${otherTracksString}`;
|
||||
message =
|
||||
translator('commands.play.playlistAddedTitle', {
|
||||
icon: this.embedOptions.icons.success
|
||||
}) +
|
||||
'\n' +
|
||||
trackUrl +
|
||||
'\n' +
|
||||
'\n' +
|
||||
translator('commands.play.playlistAddedTrackCount', {
|
||||
count: searchResult.tracks.length,
|
||||
queueCommand: formatSlashCommand('queue', translator)
|
||||
});
|
||||
} else if (queue.currentTrack === track && queue.tracks.data.length === 0) {
|
||||
message = `**${this.embedOptions.icons.audioStartedPlaying} Now playing**\n${trackUrl}`;
|
||||
message =
|
||||
translator('musicPlayerCommon.nowPlayingTitle', {
|
||||
icon: this.embedOptions.icons.audioStartedPlaying
|
||||
}) +
|
||||
'\n' +
|
||||
trackUrl;
|
||||
}
|
||||
|
||||
logger.debug('Responding with success embed.');
|
||||
@@ -178,7 +198,8 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
||||
private async handleNoResultsFound(
|
||||
transformedQuery: string,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
logger: Logger
|
||||
logger: Logger,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
logger.debug(`No results found for query: '${transformedQuery}'`);
|
||||
|
||||
@@ -187,9 +208,10 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} No track found**\n` +
|
||||
`No results found for **\`${transformedQuery}\`**.\n\n` +
|
||||
'If you specified a URL, please make sure it is valid and public.'
|
||||
translator('commands.play.trackNotFound', {
|
||||
icon: this.embedOptions.icons.warning,
|
||||
query: transformedQuery
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
]
|
||||
@@ -199,7 +221,8 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
||||
private async handlePlaylistTooLarge(
|
||||
query: string,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
logger: Logger
|
||||
logger: Logger,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
logger.debug(`Playlist found but would exceed max queue size. Query: '${query}'.`);
|
||||
|
||||
@@ -208,9 +231,10 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Playlist too large**\n` +
|
||||
'This playlist is too large to be added to the queue.\n\n' +
|
||||
`The maximum amount of tracks that can be added to the queue is **${this.playerOptions.maxQueueSize}**.`
|
||||
translator('commands.play.playlistTooLarge', {
|
||||
icon: this.embedOptions.icons.warning,
|
||||
count: this.playerOptions.maxQueueSize
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
]
|
||||
|
||||
@@ -16,22 +16,24 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
import { formatDuration } from '../../../common/formattingUtils';
|
||||
import { formatDuration, formatRepeatModeDetailed, formatSlashCommand } from '../../../common/formattingUtils';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
class QueueCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName('queue')
|
||||
.setDescription('Show tracks that have been added to the queue.')
|
||||
.addIntegerOption((option) =>
|
||||
option.setName('page').setDescription('Page number to display for the queue').setMinValue(1)
|
||||
);
|
||||
const data = localizeCommand(
|
||||
new SlashCommandBuilder()
|
||||
.setName('queue')
|
||||
.addIntegerOption((option) => option.setName('page').setMinValue(1))
|
||||
);
|
||||
super(data);
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
@@ -45,17 +47,24 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
||||
const totalPages: number = this.getTotalPages(queue);
|
||||
|
||||
if (pageIndex > totalPages - 1) {
|
||||
return await this.handleInvalidPage(logger, interaction, pageIndex, totalPages);
|
||||
return await this.handleInvalidPage(logger, interaction, pageIndex, totalPages, translator);
|
||||
}
|
||||
|
||||
const queueTracksListString: string = this.getQueueTracksListString(queue, pageIndex);
|
||||
const queueTracksListString: string = this.getQueueTracksListString(queue, pageIndex, translator);
|
||||
|
||||
const currentTrack: Track = queue.currentTrack!;
|
||||
if (currentTrack) {
|
||||
return await this.handleCurrentTrack(logger, interaction, queue, currentTrack, queueTracksListString);
|
||||
return await this.handleCurrentTrack(
|
||||
logger,
|
||||
interaction,
|
||||
queue,
|
||||
currentTrack,
|
||||
queueTracksListString,
|
||||
translator
|
||||
);
|
||||
}
|
||||
|
||||
return await this.handleNoCurrentTrack(logger, interaction, queue, queueTracksListString);
|
||||
return await this.handleNoCurrentTrack(logger, interaction, queue, queueTracksListString, translator);
|
||||
}
|
||||
|
||||
private async handleCurrentTrack(
|
||||
@@ -63,7 +72,8 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
currentTrack: Track,
|
||||
queueTracksListString: string
|
||||
queueTracksListString: string,
|
||||
translator: TFunction
|
||||
) {
|
||||
logger.debug('Queue exists with current track, gathering information.');
|
||||
|
||||
@@ -92,9 +102,11 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
||||
components.push(skipButton);
|
||||
|
||||
if (this.embedOptions.components.showButtonLabels) {
|
||||
previousButton.label = 'Previous';
|
||||
playPauseButton.label = queue.node.isPaused() ? 'Resume' : 'Pause';
|
||||
skipButton.label = 'Skip';
|
||||
previousButton.label = translator('musicPlayerCommon.controls.previous');
|
||||
playPauseButton.label = queue.node.isPaused()
|
||||
? translator('musicPlayerCommon.controls.resume')
|
||||
: translator('musicPlayerCommon.controls.pause');
|
||||
skipButton.label = translator('musicPlayerCommon.controls.skip');
|
||||
}
|
||||
|
||||
const embedActionRow: APIActionRowComponent<APIMessageActionRowComponent> = {
|
||||
@@ -106,18 +118,25 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedQueueAuthor(interaction, queue))
|
||||
.setAuthor(this.getEmbedQueueAuthor(interaction, queue, translator))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.audioPlaying} Now playing**\n` +
|
||||
`${this.getFormattedTrackUrl(currentTrack)}\n` +
|
||||
`**Requested by:** ${this.getDisplayTrackRequestedBy(currentTrack)}\n` +
|
||||
`${this.getDisplayQueueProgressBar(queue)}\n\n` +
|
||||
`${this.getDisplayRepeatMode(queue.repeatMode)}` +
|
||||
`**${this.embedOptions.icons.queue} Tracks in queue**\n` +
|
||||
this.getDisplayTrackPlayingStatus(queue, translator) +
|
||||
'\n' +
|
||||
this.getFormattedTrackUrl(currentTrack, translator) +
|
||||
'\n' +
|
||||
translator('musicPlayerCommon.requestedBy', {
|
||||
user: this.getDisplayTrackRequestedBy(currentTrack, translator)
|
||||
}) +
|
||||
'\n' +
|
||||
`${this.getDisplayQueueProgressBar(queue, translator)}\n` +
|
||||
`${formatRepeatModeDetailed(queue.repeatMode, this.embedOptions, translator)}\n` +
|
||||
`${translator('commands.queue.tracksInQueueTitle', {
|
||||
icon: this.embedOptions.icons.queue
|
||||
})}\n` +
|
||||
queueTracksListString
|
||||
)
|
||||
.setThumbnail(this.getTrackThumbnailUrl(currentTrack))
|
||||
.setFooter(this.getDisplayFullFooterInfo(interaction, queue))
|
||||
.setFooter(this.getDisplayFullFooterInfo(interaction, queue, translator))
|
||||
.setColor(this.embedOptions.colors.info)
|
||||
],
|
||||
components: [embedActionRow]
|
||||
@@ -125,11 +144,18 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
private getDisplayTrackPlayingStatus = (queue: GuildQueue, translator: TFunction): string => {
|
||||
return queue.node.isPaused()
|
||||
? translator('musicPlayerCommon.nowPausedTitle', { icon: this.embedOptions.icons.paused })
|
||||
: translator('musicPlayerCommon.nowPlayingTitle', { icon: this.embedOptions.icons.audioPlaying });
|
||||
};
|
||||
|
||||
private async handleNoCurrentTrack(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
queueTracksListString: string
|
||||
queueTracksListString: string,
|
||||
translator: TFunction
|
||||
) {
|
||||
logger.debug('Queue exists but there is no current track.');
|
||||
|
||||
@@ -137,13 +163,15 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedQueueAuthor(interaction, queue))
|
||||
.setAuthor(this.getEmbedQueueAuthor(interaction, queue, translator))
|
||||
.setDescription(
|
||||
`${this.getDisplayRepeatMode(queue.repeatMode)}` +
|
||||
`**${this.embedOptions.icons.queue} Tracks in queue**\n` +
|
||||
`${formatRepeatModeDetailed(queue.repeatMode, this.embedOptions, translator)}` +
|
||||
`${translator('commands.queue.tracksInQueueTitle', {
|
||||
icon: this.embedOptions.icons.queue
|
||||
})}\n` +
|
||||
queueTracksListString
|
||||
)
|
||||
.setFooter(this.getDisplayFullFooterInfo(interaction, queue))
|
||||
.setFooter(this.getDisplayFullFooterInfo(interaction, queue, translator))
|
||||
.setColor(this.embedOptions.colors.info)
|
||||
]
|
||||
});
|
||||
@@ -153,7 +181,8 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
pageIndex: number,
|
||||
totalPages: number
|
||||
totalPages: number,
|
||||
translator: TFunction
|
||||
) {
|
||||
logger.debug('Specified page was higher than total pages.');
|
||||
|
||||
@@ -162,9 +191,11 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
||||
`Page **\`${pageIndex + 1}\`** is not a valid page number.\n\n` +
|
||||
`There are only a total of **\`${totalPages}\`** pages in the queue.`
|
||||
translator('commands.queue.invalidPageNumber', {
|
||||
icon: this.embedOptions.icons.warning,
|
||||
page: pageIndex + 1,
|
||||
count: totalPages
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
]
|
||||
@@ -180,22 +211,26 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
||||
return Math.ceil(queue.tracks.data.length / 10) || 1;
|
||||
}
|
||||
|
||||
private getQueueTracksListString(queue: GuildQueue, pageIndex: number): string {
|
||||
private getQueueTracksListString(queue: GuildQueue, pageIndex: number, translator: TFunction): string {
|
||||
if (!queue || queue.tracks.data.length === 0) {
|
||||
return 'The queue is empty, add some tracks with **`/play`**!';
|
||||
return translator('commands.queue.emptyQueue', {
|
||||
playCommand: formatSlashCommand('play', translator)
|
||||
});
|
||||
}
|
||||
|
||||
return queue.tracks.data
|
||||
.slice(pageIndex * 10, pageIndex * 10 + 10)
|
||||
.map((track, index) => {
|
||||
return `**${pageIndex * 10 + index + 1}.** ${this.getDisplayTrackDurationAndUrl(track)}`;
|
||||
return `**${pageIndex * 10 + index + 1}.** ${this.getDisplayTrackDurationAndUrl(track, translator)}`;
|
||||
})
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
private getDisplayQueueTotalDuration(queue: GuildQueue): string {
|
||||
private getDisplayQueueTotalDuration(queue: GuildQueue, translator: TFunction): string {
|
||||
if (queue.tracks.data.length > 1000) {
|
||||
return 'Estimated duration: A really long time';
|
||||
return translator('commands.queue.estimatedReallyLongTime', {
|
||||
playCommand: formatSlashCommand('play', translator)
|
||||
});
|
||||
}
|
||||
|
||||
let queueDurationMs: number = queue.estimatedDuration;
|
||||
@@ -204,15 +239,23 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
||||
}
|
||||
|
||||
if (queueDurationMs < 0) {
|
||||
return 'Estimated duration: A really long time';
|
||||
return translator('commands.queue.estimatedReallyLongTime', {
|
||||
playCommand: formatSlashCommand('play', translator)
|
||||
});
|
||||
}
|
||||
|
||||
return `Estimated duration: ${formatDuration(queueDurationMs)}`;
|
||||
return translator('commands.queue.estimatedDuration', {
|
||||
duration: formatDuration(queueDurationMs)
|
||||
});
|
||||
}
|
||||
|
||||
private getDisplayFullFooterInfo(interaction: ChatInputCommandInteraction, queue: GuildQueue): EmbedFooterData {
|
||||
const pagination = this.getFooterDisplayPageInfo(interaction, queue);
|
||||
const totalDuration = this.getDisplayQueueTotalDuration(queue);
|
||||
private getDisplayFullFooterInfo(
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
): EmbedFooterData {
|
||||
const pagination = this.getFooterDisplayPageInfo(interaction, queue, translator);
|
||||
const totalDuration = this.getDisplayQueueTotalDuration(queue, translator);
|
||||
|
||||
const fullFooterData = {
|
||||
text: `${pagination.text} - ${totalDuration}`
|
||||
|
||||
@@ -5,9 +5,13 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ
|
||||
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
import { Logger } from 'pino';
|
||||
import { TFunction } from 'i18next';
|
||||
import { useServerTranslator } from '../../../common/localeUtil';
|
||||
import { formatSlashCommand } from '../../../common/formattingUtils';
|
||||
|
||||
class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
// TODO: Add subcommand localization support
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName('remove')
|
||||
.setDescription('Remove tracks from the queue')
|
||||
@@ -62,6 +66,7 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
@@ -75,21 +80,26 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
|
||||
switch (subcommand) {
|
||||
case 'track':
|
||||
return await this.handleRemovedTrack(logger, interaction, queue);
|
||||
return await this.handleRemovedTrack(logger, interaction, queue, translator);
|
||||
case 'range':
|
||||
return await this.handleRemoveRange(logger, interaction, queue);
|
||||
return await this.handleRemoveRange(logger, interaction, queue, translator);
|
||||
case 'queue':
|
||||
return await this.handleRemoveQueue(logger, interaction, queue);
|
||||
return await this.handleRemoveQueue(logger, interaction, queue, translator);
|
||||
case 'user':
|
||||
return await this.handleRemoveUserTracks(logger, interaction, queue);
|
||||
return await this.handleRemoveUserTracks(logger, interaction, queue, translator);
|
||||
case 'duplicates':
|
||||
return await this.handleRemoveDuplicates(logger, interaction, queue);
|
||||
return await this.handleRemoveDuplicates(logger, interaction, queue, translator);
|
||||
default:
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
private async handleRemoveUserTracks(logger: Logger, interaction: ChatInputCommandInteraction, queue: GuildQueue) {
|
||||
private async handleRemoveUserTracks(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
) {
|
||||
const targetUser = interaction.options.getUser('target')!;
|
||||
const removedTracks: Track[] = [];
|
||||
queue.tracks.data.forEach((track) => {
|
||||
@@ -102,15 +112,20 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
});
|
||||
|
||||
if (removedTracks.length === 0) {
|
||||
return await this.handleNoTracksRemoved(logger, interaction);
|
||||
return await this.handleNoTracksRemoved(logger, interaction, translator);
|
||||
}
|
||||
|
||||
logger.debug(`Removed ${removedTracks.length} tracks from queue added by a user.`);
|
||||
|
||||
return await this.handleResponseRemovedTracks(logger, interaction, removedTracks.length);
|
||||
return await this.handleResponseRemovedTracks(logger, interaction, removedTracks.length, translator);
|
||||
}
|
||||
|
||||
private async handleRemoveDuplicates(logger: Logger, interaction: ChatInputCommandInteraction, queue: GuildQueue) {
|
||||
private async handleRemoveDuplicates(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
) {
|
||||
const removedTracks: Track[] = [];
|
||||
const uniqueTrackUrls = new Set<string>();
|
||||
queue.tracks.data.forEach((track) => {
|
||||
@@ -125,20 +140,25 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
});
|
||||
|
||||
if (removedTracks.length === 0) {
|
||||
return await this.handleNoTracksRemoved(logger, interaction);
|
||||
return await this.handleNoTracksRemoved(logger, interaction, translator);
|
||||
}
|
||||
|
||||
logger.debug(`Removed ${removedTracks.length} duplicate tracks from queue.`);
|
||||
|
||||
return await this.handleResponseRemovedTracks(logger, interaction, removedTracks.length);
|
||||
return await this.handleResponseRemovedTracks(logger, interaction, removedTracks.length, translator);
|
||||
}
|
||||
|
||||
private async handleRemoveRange(logger: Logger, interaction: ChatInputCommandInteraction, queue: GuildQueue) {
|
||||
private async handleRemoveRange(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
) {
|
||||
const start: number = interaction.options.getInteger('start')!;
|
||||
const end: number = interaction.options.getInteger('end')!;
|
||||
|
||||
if (start > queue.tracks.data.length || end > queue.tracks.data.length) {
|
||||
return await this.handleTrackPositionHigherThanQueueLength(logger, interaction, start, queue);
|
||||
return await this.handleTrackPositionHigherThanQueueLength(logger, interaction, start, queue, translator);
|
||||
} else if (start > end) {
|
||||
logger.debug('Start position is higher than end position.');
|
||||
|
||||
@@ -147,9 +167,12 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
||||
`Start position **\`${start}\`** is higher than end position **\`${end}\`**. Please specify a valid range.` +
|
||||
'\n\nView tracks added to the queue with **`/queue`**.'
|
||||
translator('commands.remove.startPositionHigherThanEndPosition', {
|
||||
icon: this.embedOptions.icons.warning,
|
||||
start,
|
||||
end,
|
||||
queueCommand: formatSlashCommand('queue', translator)
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
]
|
||||
@@ -166,32 +189,48 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
}
|
||||
|
||||
if (removedTracks.length === 0) {
|
||||
return await this.handleNoTracksRemoved(logger, interaction);
|
||||
return await this.handleNoTracksRemoved(logger, interaction, translator);
|
||||
}
|
||||
|
||||
logger.debug(`Removed ${removedTracks.length} tracks from queue.`);
|
||||
|
||||
return await this.handleResponseRemovedTracks(logger, interaction, removedTracks.length);
|
||||
return await this.handleResponseRemovedTracks(logger, interaction, removedTracks.length, translator);
|
||||
}
|
||||
|
||||
private async handleRemoveQueue(logger: Logger, interaction: ChatInputCommandInteraction, queue: GuildQueue) {
|
||||
private async handleRemoveQueue(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
) {
|
||||
const queueLength = queue.tracks.data.length;
|
||||
queue.clear();
|
||||
|
||||
if (queueLength === 0) {
|
||||
return await this.handleNoTracksRemoved(logger, interaction);
|
||||
return await this.handleNoTracksRemoved(logger, interaction, translator);
|
||||
}
|
||||
|
||||
logger.debug('Cleared the queue and removed all tracks.');
|
||||
|
||||
return await this.handleResponseRemovedTracks(logger, interaction, queueLength);
|
||||
return await this.handleResponseRemovedTracks(logger, interaction, queueLength, translator);
|
||||
}
|
||||
|
||||
private async handleRemovedTrack(logger: Logger, interaction: ChatInputCommandInteraction, queue: GuildQueue) {
|
||||
private async handleRemovedTrack(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
) {
|
||||
const trackPositionInput: number = interaction.options.getInteger('position')!;
|
||||
|
||||
if (trackPositionInput > queue.tracks.data.length) {
|
||||
return await this.handleTrackPositionHigherThanQueueLength(logger, interaction, trackPositionInput, queue);
|
||||
return await this.handleTrackPositionHigherThanQueueLength(
|
||||
logger,
|
||||
interaction,
|
||||
trackPositionInput,
|
||||
queue,
|
||||
translator
|
||||
);
|
||||
}
|
||||
|
||||
const removedTrack: Track = queue.node.remove(trackPositionInput - 1)!;
|
||||
@@ -203,9 +242,11 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.success} Removed track**\n${this.getDisplayTrackDurationAndUrl(
|
||||
removedTrack
|
||||
)}`
|
||||
translator('commands.remove.removedTrack', {
|
||||
icon: this.embedOptions.icons.success
|
||||
}) +
|
||||
'\n' +
|
||||
this.getDisplayTrackDurationAndUrl(removedTrack, translator)
|
||||
)
|
||||
.setThumbnail(this.getTrackThumbnailUrl(removedTrack))
|
||||
.setColor(this.embedOptions.colors.success)
|
||||
@@ -214,15 +255,20 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
private async handleNoTracksRemoved(logger: Logger, interaction: ChatInputCommandInteraction) {
|
||||
private async handleNoTracksRemoved(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
) {
|
||||
logger.debug('Responding with warning embed.');
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} No tracks removed**\n` +
|
||||
'There were no tracks removed from the queue. Please check if the option you selected has tracks to remove.'
|
||||
translator('commands.remove.noTracksRemoved', {
|
||||
icon: this.embedOptions.icons.warning
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
]
|
||||
@@ -233,7 +279,8 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
private async handleResponseRemovedTracks(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
removedAmount: number
|
||||
removedAmount: number,
|
||||
translator: TFunction
|
||||
) {
|
||||
logger.debug('Responding with success embed.');
|
||||
await interaction.editReply({
|
||||
@@ -241,8 +288,10 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.success} Removed tracks**\n` +
|
||||
`**\`${removedAmount}\`** tracks were removed from the queue.`
|
||||
translator('commands.remove.removedTracks', {
|
||||
icon: this.embedOptions.icons.success,
|
||||
count: removedAmount
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.success)
|
||||
]
|
||||
@@ -254,7 +303,8 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
trackPositionInput: number,
|
||||
queue: GuildQueue
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
) {
|
||||
logger.debug('Specified track position is higher than total tracks.');
|
||||
|
||||
@@ -263,9 +313,12 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
||||
`Position **\`${trackPositionInput}\`** is not a valid track position. There are only a total of **\`${queue.tracks.data.length}\`** tracks in the queue.` +
|
||||
'\n\nView tracks added to the queue with **`/queue`**.'
|
||||
translator('commands.skip.trackPositionHigherThanQueueLength', {
|
||||
icon: this.embedOptions.icons.warning,
|
||||
position: trackPositionInput,
|
||||
count: queue.tracks.data.length,
|
||||
queueCommand: formatSlashCommand('queue', translator)
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
]
|
||||
|
||||
@@ -5,21 +5,23 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ
|
||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
import { Logger } from 'pino';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
class SeekCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName('seek')
|
||||
.setDescription('Seek to a duration in the current track.')
|
||||
.addStringOption((option) =>
|
||||
option.setName('duration').setDescription('Duration in format 00:00:00 (HH:mm:ss).').setRequired(true)
|
||||
);
|
||||
const data = localizeCommand(
|
||||
new SlashCommandBuilder()
|
||||
.setName('seek')
|
||||
.addStringOption((option) => option.setName('duration').setRequired(true))
|
||||
);
|
||||
super(data);
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
@@ -34,14 +36,20 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
||||
const formattedDurationString: string = this.parseDurationArray(durationInputSplit);
|
||||
|
||||
if (!this.validateDurationFormat(formattedDurationString)) {
|
||||
return await this.handleInvalidDurationFormat(logger, interaction, formattedDurationString);
|
||||
return await this.handleInvalidDurationFormat(logger, interaction, formattedDurationString, translator);
|
||||
}
|
||||
|
||||
const currentTrackMaxDurationInMs: number = queue.currentTrack!.durationMS;
|
||||
const inputDurationInMilliseconds: number = this.getDurationInputInMilliseconds(durationInputSplit);
|
||||
|
||||
if (inputDurationInMilliseconds > currentTrackMaxDurationInMs - 1000) {
|
||||
return await this.handleDurationLongerThanTrack(logger, interaction, formattedDurationString, queue);
|
||||
return await this.handleDurationLongerThanTrack(
|
||||
logger,
|
||||
interaction,
|
||||
formattedDurationString,
|
||||
queue,
|
||||
translator
|
||||
);
|
||||
}
|
||||
|
||||
return await this.seekToDurationInCurrentTrack(
|
||||
@@ -49,14 +57,16 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
||||
interaction,
|
||||
queue,
|
||||
inputDurationInMilliseconds,
|
||||
formattedDurationString
|
||||
formattedDurationString,
|
||||
translator
|
||||
);
|
||||
}
|
||||
|
||||
private async handleInvalidDurationFormat(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
formattedDurationString: string
|
||||
formattedDurationString: string,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
logger.debug('Invalid duration format input.');
|
||||
|
||||
@@ -65,13 +75,10 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
||||
`You entered an invalid duration format, **\`${formattedDurationString}\`**.\n` +
|
||||
'Please use the format **`HH:mm:ss`**, **`mm:ss`** or **`ss`**.\n\n' +
|
||||
'**Examples:**\n' +
|
||||
'- **`/seek`** **`1:24:12`** - Seek to 1 hour, 24 minutes and 12 seconds.\n' +
|
||||
'- **`/seek`** **`3:27`** - Seek to 3 minutes and 27 seconds.\n' +
|
||||
'- **`/seek`** **`42`** - Seek to 42 seconds.'
|
||||
translator('commands.seek.correctFormatInstruction', {
|
||||
icon: this.embedOptions.icons.warning,
|
||||
wrongDuration: formattedDurationString
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
]
|
||||
@@ -83,7 +90,8 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
durationInMilliseconds: number,
|
||||
formattedDurationString: string
|
||||
formattedDurationString: string,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
queue.node.seek(durationInMilliseconds);
|
||||
logger.debug(`Seeked to '${formattedDurationString}' in current track.`);
|
||||
@@ -94,8 +102,10 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
||||
new EmbedBuilder()
|
||||
.setAuthor(await this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.success} Seeking to duration**\n` +
|
||||
`Seeking to **\`${formattedDurationString}\`** in current track.`
|
||||
translator('commands.seek.seekingToTimestamp', {
|
||||
icon: this.embedOptions.icons.success,
|
||||
duration: formattedDurationString
|
||||
})
|
||||
)
|
||||
.setThumbnail(this.getTrackThumbnailUrl(queue.currentTrack!))
|
||||
.setColor(this.embedOptions.colors.success)
|
||||
@@ -107,7 +117,8 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
formattedDurationString: string,
|
||||
queue: GuildQueue
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
logger.debug('Duration specified is longer than the track duration.');
|
||||
|
||||
@@ -116,11 +127,11 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
||||
`You entered **\`${formattedDurationString}\`**, which is a duration that is longer than the duration for the current track.\n\n` +
|
||||
`Please try a duration that is less than the duration of the track (**\`${
|
||||
queue.currentTrack!.duration
|
||||
}\`**).`
|
||||
translator('commands.seek.durationLongerThanTrackDuration', {
|
||||
icon: this.embedOptions.icons.warning,
|
||||
wrongDuration: formattedDurationString,
|
||||
trackDuration: queue.currentTrack!.duration
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
]
|
||||
|
||||
@@ -4,18 +4,19 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||
import { checkQueueEmpty, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { formatSlashCommand } from '../../../common/formattingUtils';
|
||||
|
||||
class ShuffleCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName('shuffle')
|
||||
.setDescription('Randomly shuffle all tracks in the queue.');
|
||||
const data = localizeCommand(new SlashCommandBuilder().setName('shuffle'));
|
||||
super(data);
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
@@ -35,9 +36,11 @@ class ShuffleCommand extends BaseSlashCommandInteraction {
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.shuffled} Shuffled queue tracks**\n` +
|
||||
`The **${queue.tracks.data.length}** tracks in the queue has been shuffled.\n\n` +
|
||||
'View the new queue order with **`/queue`**.'
|
||||
translator('commands.shuffle.shuffledTracks', {
|
||||
icon: this.embedOptions.icons.shuffled,
|
||||
count: queue.tracks.data.length,
|
||||
queueCommand: formatSlashCommand('queue', translator)
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.success)
|
||||
]
|
||||
|
||||
@@ -5,21 +5,24 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ
|
||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
import { Logger } from 'pino';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { formatSlashCommand } from '../../../common/formattingUtils';
|
||||
|
||||
class SkipCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName('skip')
|
||||
.setDescription('Skip track to next or specified position in queue.')
|
||||
.addIntegerOption((option) =>
|
||||
option.setName('position').setDescription('The position in queue to skip to.').setMinValue(1)
|
||||
);
|
||||
const data = localizeCommand(
|
||||
new SlashCommandBuilder()
|
||||
.setName('skip')
|
||||
.addIntegerOption((option) => option.setName('position').setMinValue(1))
|
||||
);
|
||||
super(data);
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
@@ -33,9 +36,9 @@ class SkipCommand extends BaseSlashCommandInteraction {
|
||||
const trackPositionInput: number = interaction.options.getInteger('position')!;
|
||||
|
||||
if (trackPositionInput) {
|
||||
return await this.handleSkipToTrackPosition(logger, interaction, queue, trackPositionInput);
|
||||
return await this.handleSkipToTrackPosition(logger, interaction, queue, trackPositionInput, translator);
|
||||
} else {
|
||||
return await this.handleSkipToNextTrack(logger, interaction, queue);
|
||||
return await this.handleSkipToNextTrack(logger, interaction, queue, translator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,15 +46,22 @@ class SkipCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
trackPosition: number
|
||||
trackPosition: number,
|
||||
translator: TFunction
|
||||
) {
|
||||
if (trackPosition > queue.tracks.data.length) {
|
||||
return await this.handleTrackPositionHigherThanQueueLength(trackPosition, queue, logger, interaction);
|
||||
return await this.handleTrackPositionHigherThanQueueLength(
|
||||
trackPosition,
|
||||
queue,
|
||||
logger,
|
||||
interaction,
|
||||
translator
|
||||
);
|
||||
} else {
|
||||
const skippedTrack: Track = queue.currentTrack!;
|
||||
queue.node.skipTo(trackPosition - 1);
|
||||
logger.debug('Skipped to specified track position.');
|
||||
return await this.respondWithSuccessEmbed(skippedTrack, interaction);
|
||||
return await this.respondWithSuccessEmbed(skippedTrack, interaction, translator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,55 +69,77 @@ class SkipCommand extends BaseSlashCommandInteraction {
|
||||
trackPosition: number,
|
||||
queue: GuildQueue,
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
) {
|
||||
logger.debug('Specified track position was higher than total tracks.');
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
||||
`There are only **\`${queue.tracks.data.length}\`** tracks in the queue. You cannot skip to track **\`${trackPosition}\`**.\n\n` +
|
||||
'View tracks added to the queue with **`/queue`**.'
|
||||
translator('commands.skip.trackPositionHigherThanQueueLength', {
|
||||
icon: this.embedOptions.icons.warning,
|
||||
position: trackPosition,
|
||||
queueCommand: formatSlashCommand('queue', translator),
|
||||
count: queue.tracks.data.length
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
private async handleSkipToNextTrack(logger: Logger, interaction: ChatInputCommandInteraction, queue: GuildQueue) {
|
||||
private async handleSkipToNextTrack(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
) {
|
||||
if (queue.tracks.data.length === 0 && !queue.currentTrack) {
|
||||
return await this.handleNoTracksInQueueAndNoCurrentTrack(logger, interaction);
|
||||
return await this.handleNoTracksInQueueAndNoCurrentTrack(logger, interaction, translator);
|
||||
}
|
||||
|
||||
const skippedTrack: Track = queue.currentTrack!;
|
||||
queue.node.skip();
|
||||
logger.debug('Skipped current track.');
|
||||
return await this.respondWithSuccessEmbed(skippedTrack, interaction);
|
||||
return await this.respondWithSuccessEmbed(skippedTrack, interaction, translator);
|
||||
}
|
||||
|
||||
private async handleNoTracksInQueueAndNoCurrentTrack(logger: Logger, interaction: ChatInputCommandInteraction) {
|
||||
private async handleNoTracksInQueueAndNoCurrentTrack(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
) {
|
||||
logger.debug('No tracks in queue and no current track.');
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
||||
'The queue is empty, add some tracks with **`/play`**!'
|
||||
translator('commands.skip.emptyQueue', {
|
||||
icon: this.embedOptions.icons.warning,
|
||||
playCommand: formatSlashCommand('play', translator)
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
private async respondWithSuccessEmbed(skippedTrack: Track, interaction: ChatInputCommandInteraction) {
|
||||
private async respondWithSuccessEmbed(
|
||||
skippedTrack: Track,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
) {
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.skipped} Skipped track**\n` +
|
||||
`${this.getDisplayTrackDurationAndUrl(skippedTrack)}`
|
||||
translator('commands.skip.skippedTrack', {
|
||||
icon: this.embedOptions.icons.skipped
|
||||
}) +
|
||||
'\n' +
|
||||
this.getDisplayTrackDurationAndUrl(skippedTrack, translator)
|
||||
)
|
||||
.setThumbnail(this.getTrackThumbnailUrl(skippedTrack))
|
||||
.setColor(this.embedOptions.colors.success)
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
import { GuildQueue, useQueue } from 'discord-player';
|
||||
import { GuildQueue, QueueRepeatMode, useQueue } from 'discord-player';
|
||||
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { formatSlashCommand } from '../../../common/formattingUtils';
|
||||
|
||||
class StopCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName('stop')
|
||||
.setDescription('Clear the queue and stop playing audio.');
|
||||
const data = localizeCommand(new SlashCommandBuilder().setName('stop'));
|
||||
super(data);
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
@@ -26,7 +27,7 @@ class StopCommand extends BaseSlashCommandInteraction {
|
||||
]);
|
||||
|
||||
if (!queue.deleted) {
|
||||
queue.setRepeatMode(0);
|
||||
queue.setRepeatMode(QueueRepeatMode.OFF);
|
||||
queue.clear();
|
||||
queue.node.stop();
|
||||
logger.debug('Cleared and stopped the queue.');
|
||||
@@ -38,9 +39,10 @@ class StopCommand extends BaseSlashCommandInteraction {
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.success} Stopped playing**\n` +
|
||||
'Stopped playing audio and cleared the track queue.\n\n' +
|
||||
'To play more music, use the **`/play`** command!'
|
||||
translator('commands.stop.stoppedPlaying', {
|
||||
icon: this.embedOptions.icons.success,
|
||||
playCommand: formatSlashCommand('play', translator)
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.success)
|
||||
]
|
||||
|
||||
@@ -5,25 +5,23 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ
|
||||
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
import { Logger } from 'pino';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
class VolumeCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName('volume')
|
||||
.setDescription('Show or change the playback volume for tracks.')
|
||||
.addIntegerOption((option) =>
|
||||
option
|
||||
.setName('percentage')
|
||||
.setDescription('Volume percentage: From 1% to 100%.')
|
||||
.setMinValue(0)
|
||||
.setMaxValue(100)
|
||||
);
|
||||
const data = localizeCommand(
|
||||
new SlashCommandBuilder()
|
||||
.setName('volume')
|
||||
.addIntegerOption((option) => option.setName('percentage').setMinValue(0).setMaxValue(100))
|
||||
);
|
||||
super(data);
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
@@ -36,15 +34,20 @@ class VolumeCommand extends BaseSlashCommandInteraction {
|
||||
const volume: number = interaction.options.getInteger('percentage')!;
|
||||
|
||||
if (!volume && volume !== 0) {
|
||||
return await this.handleShowCurrentVolume(queue, logger, interaction);
|
||||
return await this.handleShowCurrentVolume(queue, logger, interaction, translator);
|
||||
} else if (volume > 100 || volume < 0) {
|
||||
return await this.handleInvalidVolumeInput(volume, logger, interaction);
|
||||
return await this.handleInvalidVolumeInput(volume, logger, interaction, translator);
|
||||
} else {
|
||||
return await this.handleValidVolumeInput(volume, queue, logger, interaction);
|
||||
return await this.handleValidVolumeInput(volume, queue, logger, interaction, translator);
|
||||
}
|
||||
}
|
||||
|
||||
private async handleShowCurrentVolume(queue: GuildQueue, logger: Logger, interaction: ChatInputCommandInteraction) {
|
||||
private async handleShowCurrentVolume(
|
||||
queue: GuildQueue,
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
) {
|
||||
const currentVolume: number = queue.node.volume;
|
||||
logger.debug('No volume input was provided, showing current volume.');
|
||||
|
||||
@@ -56,15 +59,22 @@ class VolumeCommand extends BaseSlashCommandInteraction {
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${currentVolumeIcon} Playback volume**\n` +
|
||||
`The playback volume is currently set to **\`${currentVolume}%\`**.`
|
||||
translator('commands.volume.volumeInformation', {
|
||||
icon: currentVolumeIcon,
|
||||
volume: currentVolume
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.info)
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
private async handleInvalidVolumeInput(volume: number, logger: Logger, interaction: ChatInputCommandInteraction) {
|
||||
private async handleInvalidVolumeInput(
|
||||
volume: number,
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
) {
|
||||
logger.debug('Volume specified was higher than 100% or lower than 0%.');
|
||||
|
||||
logger.debug('Responding with warning embed.');
|
||||
@@ -72,8 +82,10 @@ class VolumeCommand extends BaseSlashCommandInteraction {
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
||||
`You cannot set the volume to **\`${volume}%\`**, please pick a value betwen **\`1%\`** and **\`100%\`**.`
|
||||
translator('commands.volume.invalidVolumeRange', {
|
||||
icon: this.embedOptions.icons.warning,
|
||||
wrongVolume: volume
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
]
|
||||
@@ -84,7 +96,8 @@ class VolumeCommand extends BaseSlashCommandInteraction {
|
||||
volume: number,
|
||||
queue: GuildQueue,
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
) {
|
||||
queue.node.setVolume(volume);
|
||||
logger.debug(`Set volume to ${volume}%.`);
|
||||
@@ -96,8 +109,9 @@ class VolumeCommand extends BaseSlashCommandInteraction {
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.volumeMuted} Audio muted**\n` +
|
||||
`Playback audio has been muted, because volume was set to **\`${volume}%\`**.`
|
||||
translator('commands.volume.volumeMuted', {
|
||||
icon: this.embedOptions.icons.volumeMuted
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.success)
|
||||
]
|
||||
@@ -110,8 +124,10 @@ class VolumeCommand extends BaseSlashCommandInteraction {
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.volumeChanged} Volume changed**\n` +
|
||||
`Playback volume has been changed to **\`${volume}%\`**.`
|
||||
translator('commands.volume.volumeChanged', {
|
||||
icon: this.embedOptions.icons.volumeChanged,
|
||||
volume
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.success)
|
||||
]
|
||||
|
||||
@@ -4,12 +4,12 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||
import { ExtendedClient } from '../../../types/clientTypes';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||
import { checkValidGuildId } from '../../../utils/validation/systemCommandValidator';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
class GuildsCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName('guilds')
|
||||
.setDescription('Show the top 25 guilds by member count.');
|
||||
const data = localizeCommand(new SlashCommandBuilder().setName('guilds'));
|
||||
const isSystemCommand: boolean = true;
|
||||
super(data, isSystemCommand);
|
||||
}
|
||||
@@ -17,6 +17,7 @@ class GuildsCommand extends BaseSlashCommandInteraction {
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction, client } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
await this.runValidators({ interaction, executionId }, [checkValidGuildId]);
|
||||
|
||||
@@ -28,7 +29,12 @@ class GuildsCommand extends BaseSlashCommandInteraction {
|
||||
const guildListFormatted = this.formatGuildListAsString(shardGuilds);
|
||||
const totalMemberCount = this.calculateTotalMemberCount(shardGuilds);
|
||||
|
||||
let embedDescription = this.buildEmbedDescription(totalGuildCount, guildListFormatted, totalMemberCount);
|
||||
let embedDescription = this.buildEmbedDescription(
|
||||
totalGuildCount,
|
||||
guildListFormatted,
|
||||
totalMemberCount,
|
||||
translator
|
||||
);
|
||||
|
||||
if (embedDescription.length >= 4000) {
|
||||
logger.debug('Embed description is too long, truncating.');
|
||||
@@ -72,13 +78,23 @@ class GuildsCommand extends BaseSlashCommandInteraction {
|
||||
private buildEmbedDescription(
|
||||
totalGuildCount: number,
|
||||
guildListFormattedString: string,
|
||||
totalMemberCount: number
|
||||
totalMemberCount: number,
|
||||
translator: TFunction
|
||||
): string {
|
||||
const topGuildsString = totalGuildCount < 25 ? `Top ${totalGuildCount} guilds` : 'Top 25 guilds';
|
||||
const guildCount = Math.max(totalGuildCount, 25);
|
||||
return (
|
||||
`**${this.embedOptions.icons.bot} ${topGuildsString} by member count (${totalGuildCount} total)**\n` +
|
||||
`${guildListFormattedString}\n\n` +
|
||||
`**Total members:** **\`${totalMemberCount}\`**`
|
||||
translator('commands.guilds.topGuildsByMemberCount', {
|
||||
icon: this.embedOptions.icons.bot,
|
||||
count: guildCount,
|
||||
totalCount: totalGuildCount
|
||||
}) +
|
||||
'\n' +
|
||||
guildListFormattedString +
|
||||
'\n' +
|
||||
'\n' +
|
||||
translator('commands.guilds.totalMembers', {
|
||||
count: totalMemberCount
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||
import { ExtendedClient } from '../../../types/clientTypes';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||
import { checkValidGuildId } from '../../../utils/validation/systemCommandValidator';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
class ReloadCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName('reload')
|
||||
.setDescription('Reload slash command, autocomplete and component interactions across shards.');
|
||||
const data = localizeCommand(new SlashCommandBuilder().setName('reload'));
|
||||
const isSystemCommand: boolean = true;
|
||||
super(data, isSystemCommand);
|
||||
}
|
||||
@@ -23,16 +23,17 @@ class ReloadCommand extends BaseSlashCommandInteraction {
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction, client } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
await this.runValidators({ interaction, executionId }, [checkValidGuildId]);
|
||||
|
||||
try {
|
||||
await this.reloadInteractionsAcrossShards(logger, executionId, client!);
|
||||
} catch (error) {
|
||||
return await this.handleReloadError(logger, interaction, executionId, error);
|
||||
return await this.handleReloadError(logger, interaction, executionId, error, translator);
|
||||
}
|
||||
|
||||
return await this.respondWithSuccessEmbed(logger, interaction, client!);
|
||||
return await this.respondWithSuccessEmbed(logger, interaction, client!, translator);
|
||||
}
|
||||
|
||||
private async reloadInteractionsAcrossShards(logger: Logger, executionId: string, client: ExtendedClient) {
|
||||
@@ -50,7 +51,8 @@ class ReloadCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
executionId: string,
|
||||
error: Error | unknown
|
||||
error: Error | unknown,
|
||||
translator: TFunction
|
||||
) {
|
||||
logger.error(error, 'Failed to reload interaction module across shards.');
|
||||
|
||||
@@ -59,8 +61,9 @@ class ReloadCommand extends BaseSlashCommandInteraction {
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.error} Oops!**\n` +
|
||||
'_Hmm.._ It seems I am unable to reload interaction module across shards.'
|
||||
translator('commands.reload.unableToReload', {
|
||||
icon: this.embedOptions.icons.error
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.error)
|
||||
.setFooter({ text: `Execution ID: ${executionId}` })
|
||||
@@ -71,10 +74,11 @@ class ReloadCommand extends BaseSlashCommandInteraction {
|
||||
private async respondWithSuccessEmbed(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
client: ExtendedClient
|
||||
client: ExtendedClient,
|
||||
translator: TFunction
|
||||
) {
|
||||
const commands = this.getCommands(client);
|
||||
const embedDescription = this.buildEmbedDescription(commands);
|
||||
const embedDescription = this.buildEmbedDescription(commands, translator);
|
||||
|
||||
logger.debug('Responding with success embed.');
|
||||
return await interaction.editReply({
|
||||
@@ -103,8 +107,14 @@ class ReloadCommand extends BaseSlashCommandInteraction {
|
||||
return params;
|
||||
}
|
||||
|
||||
private buildEmbedDescription(commands: string[] | undefined): string {
|
||||
return `**${this.embedOptions.icons.bot} Reloaded commands**\n` + commands?.join('\n');
|
||||
private buildEmbedDescription(commands: string[] | undefined, translator: TFunction): string {
|
||||
return (
|
||||
translator('commands.reload.reloadedCommands', {
|
||||
icon: this.embedOptions.icons.bot
|
||||
}) +
|
||||
'\n' +
|
||||
commands?.join('\n')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,30 +10,29 @@ import { ExtendedClient } from '../../../types/clientTypes';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType, ShardInfo } from '../../../types/interactionTypes';
|
||||
import { checkValidGuildId } from '../../../utils/validation/systemCommandValidator';
|
||||
import { Logger } from 'pino';
|
||||
import { localizeCommand } from '../../../common/localeUtil';
|
||||
|
||||
class ShardsCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName('shards')
|
||||
.setDescription('Show information about all connected shards.')
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName('sort')
|
||||
.setDescription('What to sort the shards by.')
|
||||
.setRequired(false)
|
||||
.addChoices(
|
||||
{ name: 'None (Shard ID)', value: 'none' },
|
||||
{ name: 'Memory usage', value: 'memory' },
|
||||
{ name: 'Voice Connections', value: 'connections' },
|
||||
{ name: 'Tracks', value: 'tracks' },
|
||||
{ name: 'Listeners', value: 'listeners' },
|
||||
{ name: 'Guilds', value: 'guilds' },
|
||||
{ name: 'Members', value: 'members' }
|
||||
)
|
||||
)
|
||||
.addIntegerOption((option) =>
|
||||
option.setName('page').setDescription('Page number to display for the shards').setMinValue(1)
|
||||
);
|
||||
const data = localizeCommand(
|
||||
new SlashCommandBuilder()
|
||||
.setName('shards')
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName('sort')
|
||||
.setRequired(false)
|
||||
.addChoices(
|
||||
{ value: 'none', name: ' ' },
|
||||
{ value: 'memory', name: ' ' },
|
||||
{ value: 'connections', name: ' ' },
|
||||
{ value: 'tracks', name: ' ' },
|
||||
{ value: 'listeners', name: ' ' },
|
||||
{ value: 'guilds', name: ' ' },
|
||||
{ value: 'members', name: ' ' }
|
||||
)
|
||||
)
|
||||
.addIntegerOption((option) => option.setName('page').setMinValue(1))
|
||||
);
|
||||
const isSystemCommand: boolean = true;
|
||||
super(data, isSystemCommand);
|
||||
}
|
||||
|
||||
@@ -5,12 +5,11 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||
import { getBotStatistics, getDiscordStatus, getPlayerStatistics, getSystemStatus } from '../../../common/statusUtils';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||
import { checkValidGuildId } from '../../../utils/validation/systemCommandValidator';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
|
||||
class SystemStatusCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName('systemstatus')
|
||||
.setDescription('Show operational status of the bot with additional technical information.');
|
||||
const data = localizeCommand(new SlashCommandBuilder().setName('systemstatus'));
|
||||
const isSystemCommand: boolean = true;
|
||||
super(data, isSystemCommand);
|
||||
}
|
||||
@@ -18,15 +17,16 @@ class SystemStatusCommand extends BaseSlashCommandInteraction {
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction, client } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
await this.runValidators({ interaction, executionId }, [checkValidGuildId]);
|
||||
|
||||
const [botStatisticsEmbedString, playerStatisticsEmbedString, systemStatusEmbedString] = await Promise.all([
|
||||
getBotStatistics(client!, version),
|
||||
getPlayerStatistics(client!),
|
||||
getSystemStatus(executionId, false)
|
||||
getBotStatistics(client!, version, translator),
|
||||
getPlayerStatistics(client!, translator),
|
||||
getSystemStatus(executionId, false, translator)
|
||||
]);
|
||||
const discordStatusEmbedString = getDiscordStatus(client!);
|
||||
const discordStatusEmbedString = getDiscordStatus(client!, translator);
|
||||
const dependenciesEmbedString = this.getDependencies();
|
||||
|
||||
logger.debug('Responding with info embed.');
|
||||
@@ -36,19 +36,27 @@ class SystemStatusCommand extends BaseSlashCommandInteraction {
|
||||
.setDescription(`**${this.embedOptions.icons.bot} Bot status**\n` + botStatisticsEmbedString)
|
||||
.addFields(
|
||||
{
|
||||
name: `**${this.embedOptions.icons.queue} Queue status**`,
|
||||
name: translator('statistics.queueStatus.title', {
|
||||
icon: this.embedOptions.icons.queue
|
||||
}),
|
||||
value: playerStatisticsEmbedString
|
||||
},
|
||||
{
|
||||
name: `**${this.embedOptions.icons.server} System status**`,
|
||||
name: translator('statistics.systemStatus.title', {
|
||||
icon: this.embedOptions.icons.server
|
||||
}),
|
||||
value: systemStatusEmbedString
|
||||
},
|
||||
{
|
||||
name: `**${this.embedOptions.icons.discord} Discord status**`,
|
||||
name: translator('statistics.discordStatus.title', {
|
||||
icon: this.embedOptions.icons.discord
|
||||
}),
|
||||
value: discordStatusEmbedString
|
||||
},
|
||||
{
|
||||
name: `**${this.embedOptions.icons.bot} Dependencies**`,
|
||||
name: translator('statistics.dependencies.title', {
|
||||
icon: this.embedOptions.icons.bot
|
||||
}),
|
||||
value: dependenciesEmbedString
|
||||
}
|
||||
)
|
||||
|
||||
@@ -4,6 +4,9 @@ import { BaseComponentInteraction } from '../../classes/interactions';
|
||||
import { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||
import { TFunction } from 'i18next';
|
||||
import { useServerTranslator } from '../../common/localeUtil';
|
||||
import { formatRepeatModeDetailed, formatSlashCommand } from '../../common/formattingUtils';
|
||||
|
||||
class ActionPauseResumeButton extends BaseComponentInteraction {
|
||||
constructor() {
|
||||
@@ -13,6 +16,7 @@ class ActionPauseResumeButton extends BaseComponentInteraction {
|
||||
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
||||
const { executionId, interaction, referenceId } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
@@ -24,11 +28,11 @@ class ActionPauseResumeButton extends BaseComponentInteraction {
|
||||
]);
|
||||
|
||||
if (!queue || (queue.tracks.data.length === 0 && !queue.currentTrack)) {
|
||||
return await this.handleNoQueue(interaction);
|
||||
return await this.handleNoQueue(interaction, translator);
|
||||
}
|
||||
|
||||
if (queue.currentTrack!.id !== referenceId) {
|
||||
return await this.handleAlreadySkipped(interaction);
|
||||
return await this.handleAlreadySkipped(interaction, translator);
|
||||
}
|
||||
|
||||
const currentTrack: Track = queue.currentTrack!;
|
||||
@@ -41,15 +45,18 @@ class ActionPauseResumeButton extends BaseComponentInteraction {
|
||||
}
|
||||
|
||||
logger.debug('Responding with success embed.');
|
||||
return await this.handleSuccess(interaction, currentTrack, queue);
|
||||
return await this.handleSuccess(interaction, currentTrack, queue, translator);
|
||||
}
|
||||
|
||||
private async handleNoQueue(interaction: MessageComponentInteraction) {
|
||||
private async handleNoQueue(interaction: MessageComponentInteraction, translator: TFunction) {
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Oops!**\nThere is nothing currently playing. First add some tracks with **\`/play\`**!`
|
||||
translator('validation.queueNoCurrentTrack', {
|
||||
icon: this.embedOptions.icons.warning,
|
||||
playCommand: formatSlashCommand('play', translator)
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
],
|
||||
@@ -57,12 +64,14 @@ class ActionPauseResumeButton extends BaseComponentInteraction {
|
||||
});
|
||||
}
|
||||
|
||||
private async handleAlreadySkipped(interaction: MessageComponentInteraction) {
|
||||
private async handleAlreadySkipped(interaction: MessageComponentInteraction, translator: TFunction) {
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Oops!**\nThis track has been skipped or is no longer playing.`
|
||||
translator('validation.trackNotPlayingAnymore', {
|
||||
icon: this.embedOptions.icons.warning
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
],
|
||||
@@ -70,14 +79,21 @@ class ActionPauseResumeButton extends BaseComponentInteraction {
|
||||
});
|
||||
}
|
||||
|
||||
private async handleSuccess(interaction: MessageComponentInteraction, track: Track, queue: GuildQueue) {
|
||||
private async handleSuccess(
|
||||
interaction: MessageComponentInteraction,
|
||||
track: Track,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
) {
|
||||
const successEmbed = new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.pauseResumed} ${
|
||||
queue.node.isPaused() ? 'Paused Track' : 'Resumed track'
|
||||
}**\n ${this.getDisplayTrackDurationAndUrl(queue.currentTrack!)}\n\n` +
|
||||
`${this.getDisplayRepeatMode(queue.repeatMode, 'success')}`
|
||||
queue.node.isPaused()
|
||||
? translator('components.responses.paused')
|
||||
: translator('components.responses.resumed')
|
||||
}**\n ${this.getDisplayTrackDurationAndUrl(queue.currentTrack!, translator)}\n\n` +
|
||||
`${formatRepeatModeDetailed(queue.repeatMode, this.embedOptions, translator, 'success')}`
|
||||
)
|
||||
.setThumbnail(track.thumbnail)
|
||||
.setColor(this.embedOptions.colors.success);
|
||||
|
||||
@@ -5,6 +5,9 @@ import { BaseComponentParams, BaseComponentReturnType } from '../../types/intera
|
||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||
import { Logger } from 'pino';
|
||||
import { TFunction } from 'i18next';
|
||||
import { useServerTranslator } from '../../common/localeUtil';
|
||||
import { formatSlashCommand } from '../../common/formattingUtils';
|
||||
|
||||
class ActionPreviousButton extends BaseComponentInteraction {
|
||||
constructor() {
|
||||
@@ -14,6 +17,7 @@ class ActionPreviousButton extends BaseComponentInteraction {
|
||||
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
||||
const { executionId, interaction, referenceId } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
const history: GuildQueueHistory = useHistory(interaction.guild!.id)!;
|
||||
@@ -26,51 +30,61 @@ class ActionPreviousButton extends BaseComponentInteraction {
|
||||
]);
|
||||
|
||||
if (!queue || (queue.tracks.data.length === 0 && !queue.currentTrack)) {
|
||||
return await this.handleNoQueue(interaction);
|
||||
return await this.handleNoQueue(interaction, translator);
|
||||
}
|
||||
|
||||
if (queue.currentTrack!.id !== referenceId) {
|
||||
return await this.handleAlreadySkipped(interaction);
|
||||
return await this.handleAlreadySkipped(interaction, translator);
|
||||
}
|
||||
|
||||
return await this.handleBackToPreviousTrack(logger, interaction, history);
|
||||
return await this.handleBackToPreviousTrack(logger, interaction, history, translator);
|
||||
}
|
||||
|
||||
private async handleBackToPreviousTrack(
|
||||
logger: Logger,
|
||||
interaction: MessageComponentInteraction,
|
||||
history: GuildQueueHistory
|
||||
history: GuildQueueHistory,
|
||||
translator: TFunction
|
||||
) {
|
||||
if (history.tracks.data.length === 0) {
|
||||
return await this.handleNoTracksInHistory(logger, interaction);
|
||||
return await this.handleNoTracksInHistory(logger, interaction, translator);
|
||||
}
|
||||
|
||||
await history.back();
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
const currentTrack: Track = queue.currentTrack!;
|
||||
logger.debug('Recovered track from history.');
|
||||
return await this.handleSuccess(interaction, currentTrack);
|
||||
return await this.handleSuccess(interaction, currentTrack, translator);
|
||||
}
|
||||
private async handleNoTracksInHistory(logger: Logger, interaction: MessageComponentInteraction) {
|
||||
private async handleNoTracksInHistory(
|
||||
logger: Logger,
|
||||
interaction: MessageComponentInteraction,
|
||||
translator: TFunction
|
||||
) {
|
||||
logger.debug('No tracks in history.');
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
||||
'The history is empty, add some tracks with **`/play`**!'
|
||||
translator('commands.back.trackHistoryEmpty', {
|
||||
icon: this.embedOptions.icons.warning,
|
||||
playCommand: formatSlashCommand('play', translator)
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
private async handleNoQueue(interaction: MessageComponentInteraction) {
|
||||
private async handleNoQueue(interaction: MessageComponentInteraction, translator: TFunction) {
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Oops!**\nThere is nothing currently playing. First add some tracks with **\`/play\`**!`
|
||||
translator('validation.queueNoCurrentTrack', {
|
||||
icon: this.embedOptions.icons.warning,
|
||||
playCommand: formatSlashCommand('play', translator)
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
],
|
||||
@@ -78,12 +92,14 @@ class ActionPreviousButton extends BaseComponentInteraction {
|
||||
});
|
||||
}
|
||||
|
||||
private async handleAlreadySkipped(interaction: MessageComponentInteraction) {
|
||||
private async handleAlreadySkipped(interaction: MessageComponentInteraction, translator: TFunction) {
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Oops!**\nThis track has already been skipped or is no longer playing.`
|
||||
translator('validation.trackNotPlayingAnymore', {
|
||||
icon: this.embedOptions.icons.warning
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
],
|
||||
@@ -91,12 +107,18 @@ class ActionPreviousButton extends BaseComponentInteraction {
|
||||
});
|
||||
}
|
||||
|
||||
private async handleSuccess(interaction: MessageComponentInteraction, recoveredTrack: Track) {
|
||||
private async handleSuccess(
|
||||
interaction: MessageComponentInteraction,
|
||||
recoveredTrack: Track,
|
||||
translator: TFunction
|
||||
) {
|
||||
const successEmbed = new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.back} Recovered track**\n` +
|
||||
`${this.getDisplayTrackDurationAndUrl(recoveredTrack)}`
|
||||
translator('commands.back.trackRecovered', {
|
||||
icon: this.embedOptions.icons.back,
|
||||
track: this.getDisplayTrackDurationAndUrl(recoveredTrack, translator)
|
||||
})
|
||||
)
|
||||
.setThumbnail(recoveredTrack.thumbnail)
|
||||
.setColor(this.embedOptions.colors.success);
|
||||
|
||||
@@ -4,6 +4,9 @@ import { BaseComponentInteraction } from '../../classes/interactions';
|
||||
import { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||
import { TFunction } from 'i18next';
|
||||
import { useServerTranslator } from '../../common/localeUtil';
|
||||
import { formatRepeatModeDetailed, formatSlashCommand } from '../../common/formattingUtils';
|
||||
|
||||
class ActionSkipButton extends BaseComponentInteraction {
|
||||
constructor() {
|
||||
@@ -13,6 +16,7 @@ class ActionSkipButton extends BaseComponentInteraction {
|
||||
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
||||
const { executionId, interaction, referenceId } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
@@ -24,11 +28,11 @@ class ActionSkipButton extends BaseComponentInteraction {
|
||||
]);
|
||||
|
||||
if (!queue || (queue.tracks.data.length === 0 && !queue.currentTrack)) {
|
||||
return await this.handleNoQueue(interaction);
|
||||
return await this.handleNoQueue(interaction, translator);
|
||||
}
|
||||
|
||||
if (queue.currentTrack!.id !== referenceId) {
|
||||
return await this.handleAlreadySkipped(interaction);
|
||||
return await this.handleAlreadySkipped(interaction, translator);
|
||||
}
|
||||
|
||||
const skippedTrack: Track = queue.currentTrack!;
|
||||
@@ -36,15 +40,18 @@ class ActionSkipButton extends BaseComponentInteraction {
|
||||
logger.debug('Skipped the track.');
|
||||
|
||||
logger.debug('Responding with success embed.');
|
||||
return await this.handleSuccess(interaction, skippedTrack, queue);
|
||||
return await this.handleSuccess(interaction, skippedTrack, queue, translator);
|
||||
}
|
||||
|
||||
private async handleNoQueue(interaction: MessageComponentInteraction) {
|
||||
private async handleNoQueue(interaction: MessageComponentInteraction, translator: TFunction) {
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Oops!**\nThere is nothing currently playing. First add some tracks with **\`/play\`**!`
|
||||
translator('validation.queueNoCurrentTrack', {
|
||||
icon: this.embedOptions.icons.warning,
|
||||
playCommand: formatSlashCommand('play', translator)
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
],
|
||||
@@ -52,12 +59,14 @@ class ActionSkipButton extends BaseComponentInteraction {
|
||||
});
|
||||
}
|
||||
|
||||
private async handleAlreadySkipped(interaction: MessageComponentInteraction) {
|
||||
private async handleAlreadySkipped(interaction: MessageComponentInteraction, translator: TFunction) {
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Oops!**\nThis track has already been skipped or is no longer playing.`
|
||||
translator('validation.trackNotPlayingAnymore', {
|
||||
icon: this.embedOptions.icons.warning
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
],
|
||||
@@ -65,13 +74,21 @@ class ActionSkipButton extends BaseComponentInteraction {
|
||||
});
|
||||
}
|
||||
|
||||
private async handleSuccess(interaction: MessageComponentInteraction, skippedTrack: Track, queue: GuildQueue) {
|
||||
private async handleSuccess(
|
||||
interaction: MessageComponentInteraction,
|
||||
skippedTrack: Track,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
) {
|
||||
const successEmbed = new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.skipped} Skipped track**\n` +
|
||||
`${this.getDisplayTrackDurationAndUrl(skippedTrack)}\n\n` +
|
||||
`${this.getDisplayRepeatMode(queue.repeatMode, 'success')}`
|
||||
translator('commands.skip.skippedTrack', {
|
||||
icon: this.embedOptions.icons.skipped
|
||||
}) +
|
||||
'\n' +
|
||||
`${this.getDisplayTrackDurationAndUrl(skippedTrack, translator)}\n\n` +
|
||||
`${formatRepeatModeDetailed(queue.repeatMode, this.embedOptions, translator, 'success')}`
|
||||
)
|
||||
.setThumbnail(skippedTrack.thumbnail)
|
||||
.setColor(this.embedOptions.colors.success);
|
||||
|
||||
@@ -5,6 +5,7 @@ import { BaseComponentInteraction } from '../../classes/interactions';
|
||||
import { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
||||
import { checkQueueExists } from '../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||
import { useServerTranslator } from '../../common/localeUtil';
|
||||
|
||||
class FiltersDisableButtonComponent extends BaseComponentInteraction {
|
||||
constructor() {
|
||||
@@ -14,6 +15,7 @@ class FiltersDisableButtonComponent extends BaseComponentInteraction {
|
||||
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
@@ -31,8 +33,9 @@ class FiltersDisableButtonComponent extends BaseComponentInteraction {
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.success} Disabled filters**\n` +
|
||||
'All audio filters have been disabled.'
|
||||
translator('commands.filters.allFiltersDisabled', {
|
||||
icon: this.embedOptions.icons.success
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.success)
|
||||
],
|
||||
|
||||
@@ -12,6 +12,8 @@ import {
|
||||
import { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
||||
import { checkQueueExists } from '../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||
import { useServerTranslator } from '../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
const ffmpegFilterOptions: FFmpegFilterOptions = config.get('ffmpegFilterOptions');
|
||||
const biquadFilterOptions: BiquadFilterOptions = config.get('biquadFilterOptions');
|
||||
@@ -25,6 +27,7 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
||||
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
||||
const { executionId, interaction, referenceId } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
const filterType = referenceId;
|
||||
|
||||
logger.debug('Received select menu interaction.');
|
||||
@@ -41,16 +44,34 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
||||
this.resetFilters(queue, logger);
|
||||
|
||||
if (selectMenuInteraction.values.length === 0) {
|
||||
return await this.replyWithDisabledFiltersEmbed(logger, selectMenuInteraction);
|
||||
return await this.replyWithDisabledFiltersEmbed(logger, selectMenuInteraction, translator);
|
||||
}
|
||||
|
||||
switch (filterType) {
|
||||
case 'ffmpeg':
|
||||
return await this.handleFfmpegFilterToggle(logger, selectMenuInteraction, queue, filterType);
|
||||
return await this.handleFfmpegFilterToggle(
|
||||
logger,
|
||||
selectMenuInteraction,
|
||||
queue,
|
||||
filterType,
|
||||
translator
|
||||
);
|
||||
case 'biquad':
|
||||
return await this.handleBiquadFilterToggle(logger, selectMenuInteraction, queue, filterType);
|
||||
return await this.handleBiquadFilterToggle(
|
||||
logger,
|
||||
selectMenuInteraction,
|
||||
queue,
|
||||
filterType,
|
||||
translator
|
||||
);
|
||||
case 'equalizer':
|
||||
return await this.handleEqualizerFilterToggle(logger, selectMenuInteraction, queue, filterType);
|
||||
return await this.handleEqualizerFilterToggle(
|
||||
logger,
|
||||
selectMenuInteraction,
|
||||
queue,
|
||||
filterType,
|
||||
translator
|
||||
);
|
||||
default:
|
||||
logger.warn(`Unknown filter type '${filterType}'.`);
|
||||
return;
|
||||
@@ -61,37 +82,40 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
||||
logger: Logger,
|
||||
selectMenuInteraction: StringSelectMenuInteraction,
|
||||
queue: GuildQueue,
|
||||
filterType: string
|
||||
filterType: string,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
this.addFfmpegNormalizerIfRequired(selectMenuInteraction);
|
||||
this.toggleFfmpegFilters(selectMenuInteraction, queue, logger);
|
||||
|
||||
logger.debug('Responding with success embed.');
|
||||
return await this.sendFiltersToggledSuccessEmbed(logger, selectMenuInteraction, filterType);
|
||||
return await this.sendFiltersToggledSuccessEmbed(logger, selectMenuInteraction, filterType, translator);
|
||||
}
|
||||
|
||||
private async handleBiquadFilterToggle(
|
||||
logger: Logger,
|
||||
selectMenuInteraction: StringSelectMenuInteraction,
|
||||
queue: GuildQueue,
|
||||
filterType: string
|
||||
filterType: string,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
this.toggleBiquadFilter(selectMenuInteraction, queue, logger);
|
||||
|
||||
logger.debug('Responding with success embed.');
|
||||
return await this.sendFiltersToggledSuccessEmbed(logger, selectMenuInteraction, filterType);
|
||||
return await this.sendFiltersToggledSuccessEmbed(logger, selectMenuInteraction, filterType, translator);
|
||||
}
|
||||
|
||||
private async handleEqualizerFilterToggle(
|
||||
logger: Logger,
|
||||
selectMenuInteraction: StringSelectMenuInteraction,
|
||||
queue: GuildQueue,
|
||||
filterType: string
|
||||
filterType: string,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
this.toggleEqualizerFilter(selectMenuInteraction, queue, logger);
|
||||
|
||||
logger.debug('Responding with success embed.');
|
||||
return await this.sendFiltersToggledSuccessEmbed(logger, selectMenuInteraction, filterType);
|
||||
return await this.sendFiltersToggledSuccessEmbed(logger, selectMenuInteraction, filterType, translator);
|
||||
}
|
||||
|
||||
private toggleFfmpegFilters(
|
||||
@@ -172,25 +196,33 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
||||
private sendFiltersToggledSuccessEmbed(
|
||||
logger: Logger,
|
||||
interaction: StringSelectMenuInteraction,
|
||||
filterType: string
|
||||
filterType: string,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
logger.debug('Responding with success embed.');
|
||||
return interaction.editReply({
|
||||
embeds: [this.buildSuccessEmbed(interaction, filterType)],
|
||||
embeds: [this.buildSuccessEmbed(interaction, filterType, translator)],
|
||||
components: []
|
||||
});
|
||||
}
|
||||
|
||||
private buildSuccessEmbed(selectMenuInteraction: StringSelectMenuInteraction, filterType: string): EmbedBuilder {
|
||||
private buildSuccessEmbed(
|
||||
selectMenuInteraction: StringSelectMenuInteraction,
|
||||
filterType: string,
|
||||
translator: TFunction
|
||||
): EmbedBuilder {
|
||||
const availableFilters: FilterOption[] = this.getAvailableFilters(filterType);
|
||||
const enabledFilters: string = this.getEnabledFilters(selectMenuInteraction, availableFilters);
|
||||
|
||||
return new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(selectMenuInteraction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.success} Filters toggled**\n` +
|
||||
`Now using these ${filterType} filters:\n` +
|
||||
`${enabledFilters}`
|
||||
translator('commands.filters.nowUsingFilters', {
|
||||
icon: this.embedOptions.icons.success,
|
||||
mode: filterType
|
||||
}) +
|
||||
'\n' +
|
||||
enabledFilters
|
||||
)
|
||||
.setColor(this.embedOptions.colors.success);
|
||||
}
|
||||
@@ -243,7 +275,8 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
||||
|
||||
private async replyWithDisabledFiltersEmbed(
|
||||
logger: Logger,
|
||||
interaction: StringSelectMenuInteraction
|
||||
interaction: StringSelectMenuInteraction,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
logger.debug('Responding with success embed.');
|
||||
return await interaction.editReply({
|
||||
@@ -251,8 +284,9 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.success} Disabled filters**\n` +
|
||||
'All audio filters have been disabled.'
|
||||
translator('commands.filters.allFiltersDisabled', {
|
||||
icon: this.embedOptions.icons.success
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.success)
|
||||
],
|
||||
|
||||
Vendored
+1
@@ -63,6 +63,7 @@ export type EmbedOptions = {
|
||||
nextTrack: string;
|
||||
previousTrack: string;
|
||||
pauseResumeTrack: string;
|
||||
paused: string;
|
||||
shuffleQueue: string;
|
||||
loop: string;
|
||||
loopAction: string;
|
||||
|
||||
@@ -13,6 +13,7 @@ import { InteractionValidationError } from '../../classes/interactions';
|
||||
import loggerModule from '../../services/logger';
|
||||
import { EmbedOptions } from '../../types/configTypes';
|
||||
import { ValidatorParams } from '../../types/utilTypes';
|
||||
import { useServerTranslator } from '../../common/localeUtil';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
export const checkVoicePermissionJoinAndTalk = async ({ interaction, executionId }: ValidatorParams) => {
|
||||
@@ -23,6 +24,7 @@ export const checkVoicePermissionJoinAndTalk = async ({ interaction, executionId
|
||||
shardId: interaction.guild?.shardId,
|
||||
guildId: interaction.guild?.id
|
||||
});
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const channel: VoiceBasedChannel | null =
|
||||
interaction.member instanceof GuildMember ? interaction.member.voice.channel : null;
|
||||
@@ -34,7 +36,10 @@ export const checkVoicePermissionJoinAndTalk = async ({ interaction, executionId
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.warning} Oops!**\nI do not have permission to play audio in the voice channel <#${channel.id}>.\n\nPlease make sure I have the **\`Connect\`** and **\`Speak\`** permissions in this voice channel.`
|
||||
translator('validation.cannotJoinVoiceOrTalk', {
|
||||
icon: embedOptions.icons.warning,
|
||||
channel: `<#${channel.id}>`
|
||||
})
|
||||
)
|
||||
.setColor(embedOptions.colors.warning)
|
||||
.setFooter({
|
||||
@@ -64,6 +69,7 @@ export const checkChannelPermissionViewable = async ({ interaction, executionId
|
||||
shardId: interaction.guild?.shardId,
|
||||
guildId: interaction.guild?.id
|
||||
});
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const channel: TextBasedChannel | null = interaction.channel;
|
||||
|
||||
@@ -89,7 +95,10 @@ export const checkChannelPermissionViewable = async ({ interaction, executionId
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.warning} Oops!**\nI do not have permission to send message replies in the channel <#${channel.id}>.\n\nPlease make sure I have the **\`View Channel\`** permission in this text channel.`
|
||||
translator('validation.cannotSendMessageInChannel', {
|
||||
icon: embedOptions.icons.warning,
|
||||
channel: `<#${channel.id}>`
|
||||
})
|
||||
)
|
||||
.setColor(embedOptions.colors.warning)
|
||||
.setFooter({
|
||||
|
||||
@@ -5,6 +5,8 @@ import { InteractionValidationError } from '../../classes/interactions';
|
||||
import loggerModule from '../../services/logger';
|
||||
import { EmbedOptions } from '../../types/configTypes';
|
||||
import { ValidatorParams } from '../../types/utilTypes';
|
||||
import { useServerTranslator } from '../../common/localeUtil';
|
||||
import { formatSlashCommand } from '../../common/formattingUtils';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
export const checkQueueExists = async ({ interaction, queue, executionId }: ValidatorParams) => {
|
||||
@@ -15,6 +17,7 @@ export const checkQueueExists = async ({ interaction, queue, executionId }: Vali
|
||||
shardId: interaction.guild?.shardId,
|
||||
guildId: interaction.guild?.id
|
||||
});
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const interactionIdentifier =
|
||||
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||
@@ -24,7 +27,10 @@ export const checkQueueExists = async ({ interaction, queue, executionId }: Vali
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.warning} Oops!**\nThere are no tracks in the queue and nothing currently playing. First add some tracks with **\`/play\`**!`
|
||||
translator('validation.queueDoesNotExist', {
|
||||
icon: embedOptions.icons.warning,
|
||||
playCommand: formatSlashCommand('play', translator)
|
||||
})
|
||||
)
|
||||
.setColor(embedOptions.colors.warning)
|
||||
.setFooter({
|
||||
@@ -52,6 +58,7 @@ export const checkHistoryExists = async ({ interaction, history, executionId }:
|
||||
shardId: interaction.guild?.shardId,
|
||||
guildId: interaction.guild?.id
|
||||
});
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const interactionIdentifier =
|
||||
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||
@@ -61,7 +68,10 @@ export const checkHistoryExists = async ({ interaction, history, executionId }:
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.warning} Oops!**\nThere are no tracks in the history and nothing currently playing. First add some tracks with **\`/play\`**!`
|
||||
translator('validation.historyDoesNotExist', {
|
||||
icon: embedOptions.icons.warning,
|
||||
playCommand: formatSlashCommand('play', translator)
|
||||
})
|
||||
)
|
||||
.setColor(embedOptions.colors.warning)
|
||||
.setFooter({
|
||||
@@ -89,6 +99,7 @@ export const checkQueueCurrentTrack = async ({ interaction, queue, executionId }
|
||||
shardId: interaction.guild?.shardId,
|
||||
guildId: interaction.guild?.id
|
||||
});
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const interactionIdentifier =
|
||||
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||
@@ -98,7 +109,10 @@ export const checkQueueCurrentTrack = async ({ interaction, queue, executionId }
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.warning} Oops!**\nThere is nothing currently playing. First add some tracks with **\`/play\`**!`
|
||||
translator('validation.queueNoCurrentTrack', {
|
||||
icon: embedOptions.icons.warning,
|
||||
playCommand: formatSlashCommand('play', translator)
|
||||
})
|
||||
)
|
||||
.setColor(embedOptions.colors.warning)
|
||||
.setFooter({
|
||||
@@ -126,6 +140,7 @@ export const checkQueueEmpty = async ({ interaction, queue, executionId }: Valid
|
||||
shardId: interaction.guild?.shardId,
|
||||
guildId: interaction.guild?.id
|
||||
});
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const interactionIdentifier =
|
||||
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||
@@ -135,7 +150,10 @@ export const checkQueueEmpty = async ({ interaction, queue, executionId }: Valid
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.warning} Oops!**\nThere are no tracks added to the queue. First add some tracks with **\`/play\`**!`
|
||||
translator('validation.queueIsEmpty', {
|
||||
icon: embedOptions.icons.warning,
|
||||
playCommand: formatSlashCommand('play', translator)
|
||||
})
|
||||
)
|
||||
.setColor(embedOptions.colors.warning)
|
||||
.setFooter({
|
||||
|
||||
@@ -5,6 +5,8 @@ import { InteractionValidationError } from '../../classes/interactions';
|
||||
import loggerModule from '../../services/logger';
|
||||
import { EmbedOptions, SystemOptions } from '../../types/configTypes';
|
||||
import { ValidatorParams } from '../../types/utilTypes';
|
||||
import { useServerTranslator } from '../../common/localeUtil';
|
||||
import { formatSlashCommand } from '../../common/formattingUtils';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
const systemOptions: SystemOptions = config.get('systemOptions');
|
||||
@@ -16,6 +18,7 @@ export const checkValidGuildId = async ({ interaction, executionId }: ValidatorP
|
||||
shardId: interaction.guild?.shardId,
|
||||
guildId: interaction.guild?.id
|
||||
});
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const interactionIdentifier =
|
||||
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||
@@ -25,7 +28,10 @@ export const checkValidGuildId = async ({ interaction, executionId }: ValidatorP
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.warning} Oops!**\nNo permission to perform this action.\n\nThe command **\`/${interactionIdentifier}\`** cannot be executed in this server.`
|
||||
translator('validation.notValidGuildId', {
|
||||
icon: embedOptions.icons.warning,
|
||||
command: formatSlashCommand(interactionIdentifier, translator)
|
||||
})
|
||||
)
|
||||
.setColor(embedOptions.colors.warning)
|
||||
]
|
||||
|
||||
@@ -5,6 +5,7 @@ import { InteractionValidationError } from '../../classes/interactions';
|
||||
import loggerModule from '../../services/logger';
|
||||
import { EmbedOptions } from '../../types/configTypes';
|
||||
import { ValidatorParams } from '../../types/utilTypes';
|
||||
import { useServerTranslator } from '../../common/localeUtil';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
export const checkInVoiceChannel = async ({ interaction, executionId }: ValidatorParams) => {
|
||||
@@ -15,6 +16,7 @@ export const checkInVoiceChannel = async ({ interaction, executionId }: Validato
|
||||
shardId: interaction.guild?.shardId,
|
||||
guildId: interaction.guild?.id
|
||||
});
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const interactionIdentifier =
|
||||
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||
@@ -24,7 +26,9 @@ export const checkInVoiceChannel = async ({ interaction, executionId }: Validato
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.warning} Not in a voice channel**\nYou need to be in a voice channel to perform this action.`
|
||||
translator('validation.notInVoiceChannel', {
|
||||
icon: embedOptions.icons.warning
|
||||
})
|
||||
)
|
||||
.setColor(embedOptions.colors.warning)
|
||||
.setFooter({
|
||||
@@ -49,6 +53,7 @@ export const checkSameVoiceChannel = async ({ interaction, queue, executionId }:
|
||||
shardId: interaction.guild?.shardId,
|
||||
guildId: interaction.guild?.id
|
||||
});
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const interactionIdentifier =
|
||||
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||
@@ -66,7 +71,10 @@ export const checkSameVoiceChannel = async ({ interaction, queue, executionId }:
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.warning} Not in same voice channel**\nYou need to be in the same voice channel as me to perform this action.\n\n**Voice channel:** <#${queue.dispatcher.channel.id}>`
|
||||
translator('validation.notInSameVoiceChannel', {
|
||||
icon: embedOptions.icons.warning,
|
||||
channel: `<#${queue.dispatcher.channel.id}>`
|
||||
})
|
||||
)
|
||||
.setColor(embedOptions.colors.warning)
|
||||
.setFooter({
|
||||
|
||||
+1
-1
@@ -9,6 +9,6 @@
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"include": ["src/**/*.ts"],
|
||||
"include": ["src/**/*.ts", "locales/**/*.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
Reference in new issue
Block a user