mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-02 14:38:49 +00:00
Transcribe everything
Untranscribed sections are marked TODO
This commit is contained in:
32 files changed
+1034
-392
No files matched your search
+112
-21
@@ -14,9 +14,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"trackPositionHigherThanQueueLength": "{{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}}.",
|
||||
"trackPositionHigherThanQueueLength_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}}.",
|
||||
"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": {
|
||||
@@ -30,8 +30,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"disableAllFiltersButton": "Disable all filters",
|
||||
"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."
|
||||
@@ -40,16 +41,18 @@
|
||||
"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."
|
||||
},
|
||||
"addBotCallout": "{{icon}} **Enjoying {{botName}}?**\nAdd me to another server:\n**[Click me!]({{invite}})**",
|
||||
"listTitle": "{{icon}} **List of commands**",
|
||||
"supportServerCallout": "{{icon}} **Support server**\nJoin the support server for help or to suggest improvements:\n{{invite}}",
|
||||
"addBotCallout": "{{icon}} **Enjoying {{botName}}?**\nAdd me to another server:\n**[Click me!]({{invite}})**"
|
||||
"supportServerCallout": "{{icon}} **Support server**\nJoin the support server for help or to suggest improvements:\n{{invite}}"
|
||||
},
|
||||
"history": {
|
||||
"metadata": {
|
||||
@@ -61,19 +64,27 @@
|
||||
"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": {
|
||||
@@ -85,6 +96,18 @@
|
||||
"description": "Loop mode: Track, queue, autoplay or disabled."
|
||||
}
|
||||
}
|
||||
},
|
||||
"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!",
|
||||
"repeatMode": {
|
||||
"off": "disabled",
|
||||
"track": "track",
|
||||
"queue": "queue",
|
||||
"autoplay": "autoplay"
|
||||
}
|
||||
},
|
||||
"lyrics": {
|
||||
@@ -98,7 +121,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"autocompleteSearchResult": "{{title}} [Artist: {{artist}}]"
|
||||
"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": {
|
||||
@@ -114,7 +139,10 @@
|
||||
"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": {
|
||||
@@ -126,7 +154,9 @@
|
||||
"metadata": {
|
||||
"name": "pause",
|
||||
"description": "Toggle pause for the current track."
|
||||
}
|
||||
},
|
||||
"pauseConfirmation": "{{icon}} **Paused track**",
|
||||
"resumeConfirmation": "{{icon}} **Resumed track**"
|
||||
},
|
||||
"play": {
|
||||
"metadata": {
|
||||
@@ -138,7 +168,13 @@
|
||||
"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": {
|
||||
@@ -150,13 +186,24 @@
|
||||
"description": "Page number to display for the queue."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tracksInQueueTitle": "{{icon}} **Tracks in 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": {
|
||||
@@ -165,10 +212,13 @@
|
||||
"options": {
|
||||
"duration": {
|
||||
"name": "duration",
|
||||
"description": "Duration in format 00:00:00 (HH:mm:ss)."
|
||||
"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": {
|
||||
@@ -190,7 +240,8 @@
|
||||
"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": {
|
||||
@@ -202,7 +253,11 @@
|
||||
"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": {
|
||||
@@ -214,7 +269,8 @@
|
||||
"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": {
|
||||
@@ -232,9 +288,33 @@
|
||||
"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%`**."
|
||||
}
|
||||
},
|
||||
"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}}.",
|
||||
"nowPlayingTitle": "{{icon}} **Now playing**",
|
||||
"playingLive": "{{icon}} **`LIVE`** - Playing continuously from live source.",
|
||||
"requestedBy": "**Requested by:** {{user}}",
|
||||
"unavailableDuration": "_No duration available._",
|
||||
"unavailableRequestedBy": "Unavailable",
|
||||
"unavailableTrackTitle": "Title unavailable",
|
||||
"unavailableTrackUrl": "**Unavailable**",
|
||||
"voiceChannelInfo": "Channel: {{channel}} ({{bitrate}}kbps)"
|
||||
},
|
||||
"statistics": {
|
||||
"botStatus": {
|
||||
"title": "{{icon}} **Bot status**",
|
||||
@@ -268,5 +348,16 @@
|
||||
"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}}!"
|
||||
}
|
||||
}
|
||||
Vendored
+112
-21
@@ -15,9 +15,9 @@ interface Resources {
|
||||
}
|
||||
}
|
||||
},
|
||||
"trackPositionHigherThanQueueLength": "{{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}}.",
|
||||
"trackPositionHigherThanQueueLength_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}}.",
|
||||
"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": {
|
||||
@@ -31,8 +31,9 @@ interface Resources {
|
||||
}
|
||||
}
|
||||
},
|
||||
"disableAllFiltersButton": "Disable all filters",
|
||||
"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."
|
||||
@@ -41,16 +42,18 @@ interface Resources {
|
||||
"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."
|
||||
},
|
||||
"addBotCallout": "{{icon}} **Enjoying {{botName}}?**\nAdd me to another server:\n**[Click me!]({{invite}})**",
|
||||
"listTitle": "{{icon}} **List of commands**",
|
||||
"supportServerCallout": "{{icon}} **Support server**\nJoin the support server for help or to suggest improvements:\n{{invite}}",
|
||||
"addBotCallout": "{{icon}} **Enjoying {{botName}}?**\nAdd me to another server:\n**[Click me!]({{invite}})**"
|
||||
"supportServerCallout": "{{icon}} **Support server**\nJoin the support server for help or to suggest improvements:\n{{invite}}"
|
||||
},
|
||||
"history": {
|
||||
"metadata": {
|
||||
@@ -62,19 +65,27 @@ interface Resources {
|
||||
"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": {
|
||||
@@ -86,6 +97,18 @@ interface Resources {
|
||||
"description": "Loop mode: Track, queue, autoplay or disabled."
|
||||
}
|
||||
}
|
||||
},
|
||||
"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!",
|
||||
"repeatMode": {
|
||||
"off": "disabled",
|
||||
"track": "track",
|
||||
"queue": "queue",
|
||||
"autoplay": "autoplay"
|
||||
}
|
||||
},
|
||||
"lyrics": {
|
||||
@@ -99,7 +122,9 @@ interface Resources {
|
||||
}
|
||||
}
|
||||
},
|
||||
"autocompleteSearchResult": "{{title}} [Artist: {{artist}}]"
|
||||
"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": {
|
||||
@@ -115,7 +140,10 @@ interface Resources {
|
||||
"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": {
|
||||
@@ -127,7 +155,9 @@ interface Resources {
|
||||
"metadata": {
|
||||
"name": "pause",
|
||||
"description": "Toggle pause for the current track."
|
||||
}
|
||||
},
|
||||
"pauseConfirmation": "{{icon}} **Paused track**",
|
||||
"resumeConfirmation": "{{icon}} **Resumed track**"
|
||||
},
|
||||
"play": {
|
||||
"metadata": {
|
||||
@@ -139,7 +169,13 @@ interface Resources {
|
||||
"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": {
|
||||
@@ -151,13 +187,24 @@ interface Resources {
|
||||
"description": "Page number to display for the queue."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tracksInQueueTitle": "{{icon}} **Tracks in 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": {
|
||||
@@ -166,10 +213,13 @@ interface Resources {
|
||||
"options": {
|
||||
"duration": {
|
||||
"name": "duration",
|
||||
"description": "Duration in format 00:00:00 (HH:mm:ss)."
|
||||
"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": {
|
||||
@@ -191,7 +241,8 @@ interface Resources {
|
||||
"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": {
|
||||
@@ -203,7 +254,11 @@ interface Resources {
|
||||
"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": {
|
||||
@@ -215,7 +270,8 @@ interface Resources {
|
||||
"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": {
|
||||
@@ -233,9 +289,33 @@ interface Resources {
|
||||
"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%`**."
|
||||
}
|
||||
},
|
||||
"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}}.",
|
||||
"nowPlayingTitle": "{{icon}} **Now playing**",
|
||||
"playingLive": "{{icon}} **`LIVE`** - Playing continuously from live source.",
|
||||
"requestedBy": "**Requested by:** {{user}}",
|
||||
"unavailableDuration": "_No duration available._",
|
||||
"unavailableRequestedBy": "Unavailable",
|
||||
"unavailableTrackTitle": "Title unavailable",
|
||||
"unavailableTrackUrl": "**Unavailable**",
|
||||
"voiceChannelInfo": "Channel: {{channel}} ({{bitrate}}kbps)"
|
||||
},
|
||||
"statistics": {
|
||||
"botStatus": {
|
||||
"title": "{{icon}} **Bot status**",
|
||||
@@ -269,6 +349,17 @@ interface Resources {
|
||||
"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}}!"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+35
-23
@@ -26,6 +26,8 @@ import {
|
||||
BaseSlashCommandReturnType
|
||||
} from '../types/interactionTypes';
|
||||
import { Validator, ValidatorParams } from '../types/utilTypes';
|
||||
import { TFunction } from 'i18next';
|
||||
import { formatSlashCommand } from '../common/formattingUtils';
|
||||
|
||||
abstract class BaseInteraction {
|
||||
embedOptions: EmbedOptions;
|
||||
@@ -72,18 +74,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 +118,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,17 +150,19 @@ 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 {
|
||||
protected getDisplayRepeatMode(repeatMode: number, translator: TFunction, state: string = 'info'): string {
|
||||
let loopModeUserString: string;
|
||||
let icon: string;
|
||||
|
||||
@@ -176,10 +183,11 @@ abstract class BaseInteraction {
|
||||
return '';
|
||||
}
|
||||
|
||||
return (
|
||||
`**${icon} Looping**\n` +
|
||||
`Loop mode is set to **\`${loopModeUserString}\`**. You can change it with **\`/loop\`**.\n\n`
|
||||
);
|
||||
return translator('musicPlayerCommon.loopingInfo', {
|
||||
icon,
|
||||
loopMode: loopModeUserString,
|
||||
loopCommand: formatSlashCommand('loop', translator)
|
||||
});
|
||||
}
|
||||
|
||||
abstract execute(
|
||||
@@ -210,11 +218,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,5 +1,5 @@
|
||||
import assert from 'assert';
|
||||
import { APIApplicationCommandOption, Interaction, Locale, SlashCommandBuilder } from 'discord.js';
|
||||
import { APIApplicationCommandOption, BaseInteraction, Locale, SlashCommandBuilder } from 'discord.js';
|
||||
import { lstatSync, readdirSync } from 'fs';
|
||||
import i18n from 'i18next';
|
||||
import i18nextFsBackend, { FsBackendOptions } from 'i18next-fs-backend';
|
||||
@@ -23,11 +23,11 @@ translatorInstance.use(i18nextFsBackend).init<FsBackendOptions>({
|
||||
}
|
||||
});
|
||||
|
||||
export function useServerTranslator(interaction: Interaction) {
|
||||
export function useServerTranslator(interaction: BaseInteraction) {
|
||||
return translatorInstance.getFixedT(interaction.guildLocale ?? 'en');
|
||||
}
|
||||
|
||||
export function useUserTranslator(interaction: Interaction) {
|
||||
export function useUserTranslator(interaction: BaseInteraction) {
|
||||
return translatorInstance.getFixedT(interaction.locale ?? 'en');
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ class BackCommand extends BaseSlashCommandInteraction {
|
||||
translator: TFunction
|
||||
) {
|
||||
if (backtoTrackPosition > history.tracks.data.length) {
|
||||
return await this.handleTrackPositionHigherThanQueueLength(
|
||||
return await this.handleTrackPositionHigherThanHistoryLength(
|
||||
backtoTrackPosition,
|
||||
history,
|
||||
logger,
|
||||
@@ -65,7 +65,7 @@ class BackCommand extends BaseSlashCommandInteraction {
|
||||
}
|
||||
}
|
||||
|
||||
private async handleTrackPositionHigherThanQueueLength(
|
||||
private async handleTrackPositionHigherThanHistoryLength(
|
||||
backToTrackPosition: number,
|
||||
history: GuildQueueHistory,
|
||||
logger: Logger,
|
||||
@@ -77,7 +77,7 @@ class BackCommand extends BaseSlashCommandInteraction {
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
translator('commands.back.trackPositionHigherThanQueueLength', {
|
||||
translator('commands.back.trackPositionHigherThanHistoryLength', {
|
||||
icon: this.embedOptions.icons.warning,
|
||||
count: history.tracks.data.length,
|
||||
backPosition: backToTrackPosition,
|
||||
@@ -137,7 +137,7 @@ class BackCommand extends BaseSlashCommandInteraction {
|
||||
.setDescription(
|
||||
translator('commands.back.trackRecovered', {
|
||||
icon: this.embedOptions.icons.back,
|
||||
track: this.getDisplayTrackDurationAndUrl(recoveredTrack)
|
||||
track: this.getDisplayTrackDurationAndUrl(recoveredTrack, translator)
|
||||
})
|
||||
)
|
||||
.setThumbnail(this.getTrackThumbnailUrl(recoveredTrack))
|
||||
|
||||
@@ -16,7 +16,9 @@ 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 } from '../../../common/localeUtil';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { formatSlashCommand } from '../../../common/formattingUtils';
|
||||
|
||||
class HistoryCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
@@ -31,6 +33,7 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
||||
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,30 @@ 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` +
|
||||
translator('musicPlayerCommon.nowPlayingTitle', {
|
||||
icon: this.embedOptions.icons.audioPlaying
|
||||
}) +
|
||||
'\n' +
|
||||
this.getFormattedTrackUrl(currentTrack, translator) +
|
||||
'\n' +
|
||||
translator('musicPlayerCommon.requestedBy', {
|
||||
user: this.getDisplayTrackRequestedBy(currentTrack, translator)
|
||||
}) +
|
||||
'\n' +
|
||||
this.getDisplayQueueProgressBar(queue, translator) +
|
||||
'\n' +
|
||||
'\n' +
|
||||
this.getDisplayRepeatMode(queue.repeatMode, translator) +
|
||||
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]
|
||||
@@ -138,7 +164,8 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
history: GuildQueueHistory,
|
||||
historyTracksListString: string
|
||||
historyTracksListString: string,
|
||||
translator: TFunction
|
||||
) {
|
||||
logger.debug('History exists but there is no current track.');
|
||||
|
||||
@@ -146,13 +173,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 +191,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 +201,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 +221,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,7 +5,9 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ
|
||||
import { checkInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
import { checkVoicePermissionJoinAndTalk } from '../../../utils/validation/permissionValidator';
|
||||
import { Logger } from 'pino';
|
||||
import { localizeCommand } from '../../../common/localeUtil';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { formatSlashCommand } from '../../../common/formattingUtils';
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
class JoinCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
@@ -16,23 +18,24 @@ class JoinCommand extends BaseSlashCommandInteraction {
|
||||
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.');
|
||||
@@ -41,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)
|
||||
]
|
||||
@@ -82,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,7 +4,8 @@ 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 } from '../../../common/localeUtil';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { formatSlashCommand } from '../../../common/formattingUtils';
|
||||
|
||||
class LeaveCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
@@ -15,6 +16,7 @@ class LeaveCommand 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)!;
|
||||
|
||||
@@ -33,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,7 +11,8 @@ 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 } from '../../../common/localeUtil';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
class LoopCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
@@ -37,6 +38,7 @@ class LoopCommand 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)!;
|
||||
|
||||
@@ -50,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 = this.getRepeatModeEmbedName(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)
|
||||
]
|
||||
@@ -87,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 = this.getRepeatModeEmbedName(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)
|
||||
]
|
||||
@@ -109,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 = this.getRepeatModeEmbedName(toRepeatMode, translator);
|
||||
const getChangedRepeatModeEmbedReply = this.getChangedRepeatModeEmbedReply(
|
||||
fromRepeatMode,
|
||||
toRepeatMode,
|
||||
translator
|
||||
);
|
||||
|
||||
queue.setRepeatMode(toRepeatMode);
|
||||
logger.debug(`Loop mode changed to '${newRepeatModeEmbedName}'.`);
|
||||
@@ -128,35 +148,48 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
||||
});
|
||||
}
|
||||
|
||||
private getRepeatModeEmbedName(repeatMode: QueueRepeatMode): string {
|
||||
private getRepeatModeEmbedName(repeatMode: QueueRepeatMode, translator: TFunction): string {
|
||||
const repeatModeEmbedString: { [key in QueueRepeatMode]: string } = {
|
||||
[QueueRepeatMode.OFF]: 'disabled',
|
||||
[QueueRepeatMode.TRACK]: 'track',
|
||||
[QueueRepeatMode.QUEUE]: 'queue',
|
||||
[QueueRepeatMode.AUTOPLAY]: 'autoplay'
|
||||
[QueueRepeatMode.OFF]: translator('commands.loop.repeatMode.off'),
|
||||
[QueueRepeatMode.TRACK]: translator('commands.loop.repeatMode.track'),
|
||||
[QueueRepeatMode.QUEUE]: translator('commands.loop.repeatMode.queue'),
|
||||
[QueueRepeatMode.AUTOPLAY]: translator('commands.loop.repeatMode.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 = this.getRepeatModeEmbedName(fromRepeatMode, translator);
|
||||
const toRepeatModeEmbedName = this.getRepeatModeEmbedName(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,7 +6,8 @@ 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 } from '../../../common/localeUtil';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
class LyricsCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
@@ -23,6 +24,7 @@ class LyricsCommand 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)!;
|
||||
const query: string = interaction.options.getString('query')!;
|
||||
@@ -50,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 {
|
||||
@@ -155,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)
|
||||
]
|
||||
@@ -173,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);
|
||||
@@ -181,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)
|
||||
);
|
||||
@@ -204,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,7 +5,9 @@ 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 } from '../../../common/localeUtil';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { formatSlashCommand } from '../../../common/formattingUtils';
|
||||
|
||||
class MoveCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
@@ -21,6 +23,7 @@ class MoveCommand 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)!;
|
||||
|
||||
@@ -33,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(
|
||||
@@ -41,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.');
|
||||
@@ -50,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,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)
|
||||
]
|
||||
@@ -85,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,7 +14,7 @@ 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 } from '../../../common/localeUtil';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
|
||||
class NowPlayingCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
@@ -25,6 +25,7 @@ class NowPlayingCommand 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)!;
|
||||
|
||||
@@ -37,11 +38,11 @@ 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 displayTrackUrl: string = this.getFormattedTrackUrl(currentTrack, translator);
|
||||
const displayTrackRequestedBy: string = this.getDisplayTrackRequestedBy(currentTrack, translator);
|
||||
const displayTrackPlayingStatus: string = this.getDisplayTrackPlayingStatus(queue);
|
||||
const displayQueueRepeatMode: string = this.getDisplayQueueRepeatMode(queue);
|
||||
const displayEmbedProgressBar: string = this.getDisplayQueueProgressBar(queue);
|
||||
const displayEmbedProgressBar: string = this.getDisplayQueueProgressBar(queue, translator);
|
||||
|
||||
const components: APIMessageActionRowComponent[] = [];
|
||||
|
||||
@@ -82,7 +83,7 @@ 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` +
|
||||
|
||||
@@ -5,7 +5,7 @@ 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 } from '../../../common/localeUtil';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
|
||||
class PauseCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
@@ -16,6 +16,7 @@ class PauseCommand 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)!;
|
||||
|
||||
@@ -36,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,7 +6,9 @@ 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 } from '../../../common/localeUtil';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { formatSlashCommand } from '../../../common/formattingUtils';
|
||||
|
||||
class PlayCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
@@ -23,6 +25,7 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
||||
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]);
|
||||
|
||||
@@ -39,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(
|
||||
@@ -63,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(
|
||||
@@ -145,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.');
|
||||
@@ -174,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}'`);
|
||||
|
||||
@@ -183,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)
|
||||
]
|
||||
@@ -195,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}'.`);
|
||||
|
||||
@@ -204,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)
|
||||
]
|
||||
|
||||
@@ -17,7 +17,8 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ
|
||||
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
import { formatDuration } from '../../../common/formattingUtils';
|
||||
import { localizeCommand } from '../../../common/localeUtil';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
class QueueCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
@@ -32,6 +33,7 @@ class QueueCommand 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)!;
|
||||
|
||||
@@ -48,14 +50,21 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
||||
return await this.handleInvalidPage(logger, interaction, pageIndex, totalPages);
|
||||
}
|
||||
|
||||
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,29 @@ 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` +
|
||||
translator('musicPlayerCommon.nowPlayingTitle', {
|
||||
icon: this.embedOptions.icons.audioPlaying
|
||||
}) +
|
||||
this.getFormattedTrackUrl(currentTrack, translator) +
|
||||
'\n' +
|
||||
translator('musicPlayerCommon.requestedBy', {
|
||||
user: this.getDisplayTrackRequestedBy(currentTrack, translator)
|
||||
}) +
|
||||
'\n' +
|
||||
this.getDisplayQueueProgressBar(queue, translator) +
|
||||
'\n' +
|
||||
'\n' +
|
||||
this.getDisplayRepeatMode(queue.repeatMode, translator) +
|
||||
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]
|
||||
@@ -129,7 +152,8 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
queueTracksListString: string
|
||||
queueTracksListString: string,
|
||||
translator: TFunction
|
||||
) {
|
||||
logger.debug('Queue exists but there is no current track.');
|
||||
|
||||
@@ -137,13 +161,13 @@ 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.getDisplayRepeatMode(queue.repeatMode, translator)}` +
|
||||
`**${this.embedOptions.icons.queue} Tracks in queue**\n` +
|
||||
queueTracksListString
|
||||
)
|
||||
.setFooter(this.getDisplayFullFooterInfo(interaction, queue))
|
||||
.setFooter(this.getDisplayFullFooterInfo(interaction, queue, translator))
|
||||
.setColor(this.embedOptions.colors.info)
|
||||
]
|
||||
});
|
||||
@@ -180,7 +204,7 @@ 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`**!';
|
||||
}
|
||||
@@ -188,7 +212,7 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
||||
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');
|
||||
}
|
||||
@@ -210,8 +234,12 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
||||
return `Estimated duration: ${formatDuration(queueDurationMs)}`;
|
||||
}
|
||||
|
||||
private getDisplayFullFooterInfo(interaction: ChatInputCommandInteraction, queue: GuildQueue): EmbedFooterData {
|
||||
const pagination = this.getFooterDisplayPageInfo(interaction, queue);
|
||||
private getDisplayFullFooterInfo(
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
): EmbedFooterData {
|
||||
const pagination = this.getFooterDisplayPageInfo(interaction, queue, translator);
|
||||
const totalDuration = this.getDisplayQueueTotalDuration(queue);
|
||||
|
||||
const fullFooterData = {
|
||||
|
||||
@@ -5,6 +5,9 @@ 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() {
|
||||
@@ -63,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)!;
|
||||
|
||||
@@ -76,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) => {
|
||||
@@ -103,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) => {
|
||||
@@ -126,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.');
|
||||
|
||||
@@ -148,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)
|
||||
]
|
||||
@@ -167,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)!;
|
||||
@@ -204,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)
|
||||
@@ -215,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)
|
||||
]
|
||||
@@ -234,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({
|
||||
@@ -242,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)
|
||||
]
|
||||
@@ -255,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.');
|
||||
|
||||
@@ -264,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,7 +5,8 @@ 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 } from '../../../common/localeUtil';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
class SeekCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
@@ -20,6 +21,7 @@ class SeekCommand 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)!;
|
||||
|
||||
@@ -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,7 +4,8 @@ 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 } from '../../../common/localeUtil';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { formatSlashCommand } from '../../../common/formattingUtils';
|
||||
|
||||
class ShuffleCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
@@ -15,6 +16,7 @@ class ShuffleCommand 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)!;
|
||||
|
||||
@@ -34,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,7 +5,9 @@ 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 } from '../../../common/localeUtil';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { formatSlashCommand } from '../../../common/formattingUtils';
|
||||
|
||||
class SkipCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
@@ -20,6 +22,7 @@ class SkipCommand 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)!;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -4,7 +4,8 @@ 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 } from '../../../common/localeUtil';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { formatSlashCommand } from '../../../common/formattingUtils';
|
||||
|
||||
class StopCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
@@ -15,6 +16,7 @@ class StopCommand 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)!;
|
||||
|
||||
@@ -37,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,7 +5,8 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ
|
||||
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
import { Logger } from 'pino';
|
||||
import { localizeCommand } from '../../../common/localeUtil';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
class VolumeCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
@@ -20,6 +21,7 @@ class VolumeCommand 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)!;
|
||||
|
||||
@@ -32,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.');
|
||||
|
||||
@@ -52,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.');
|
||||
@@ -68,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)
|
||||
]
|
||||
@@ -80,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}%.`);
|
||||
@@ -92,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)
|
||||
]
|
||||
@@ -106,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,7 +4,8 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||
import { ExtendedClient } from '../../../types/clientTypes';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||
import { checkValidGuildId } from '../../../utils/validation/systemCommandValidator';
|
||||
import { localizeCommand } from '../../../common/localeUtil';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
class GuildsCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
@@ -16,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]);
|
||||
|
||||
@@ -27,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.');
|
||||
@@ -71,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,7 +10,8 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||
import { ExtendedClient } from '../../../types/clientTypes';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||
import { checkValidGuildId } from '../../../utils/validation/systemCommandValidator';
|
||||
import { localizeCommand } from '../../../common/localeUtil';
|
||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
class ReloadCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
@@ -22,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) {
|
||||
@@ -49,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.');
|
||||
|
||||
@@ -58,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}` })
|
||||
@@ -70,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({
|
||||
@@ -102,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')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ 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';
|
||||
|
||||
class ActionPauseResumeButton extends BaseComponentInteraction {
|
||||
constructor() {
|
||||
@@ -13,6 +15,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)!;
|
||||
|
||||
@@ -41,7 +44,7 @@ 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) {
|
||||
@@ -70,14 +73,19 @@ 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')}`
|
||||
}**\n ${this.getDisplayTrackDurationAndUrl(queue.currentTrack!, translator)}\n\n` +
|
||||
`${this.getDisplayRepeatMode(queue.repeatMode, 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)!;
|
||||
@@ -33,32 +37,39 @@ class ActionPreviousButton extends BaseComponentInteraction {
|
||||
return await this.handleAlreadySkipped(interaction);
|
||||
}
|
||||
|
||||
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)
|
||||
]
|
||||
@@ -91,12 +102,16 @@ 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)}`
|
||||
`${this.getDisplayTrackDurationAndUrl(recoveredTrack, translator)}`
|
||||
)
|
||||
.setThumbnail(recoveredTrack.thumbnail)
|
||||
.setColor(this.embedOptions.colors.success);
|
||||
|
||||
@@ -4,6 +4,8 @@ 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';
|
||||
|
||||
class ActionSkipButton extends BaseComponentInteraction {
|
||||
constructor() {
|
||||
@@ -13,6 +15,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)!;
|
||||
|
||||
@@ -36,7 +39,7 @@ 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) {
|
||||
@@ -65,13 +68,18 @@ 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')}`
|
||||
`${this.getDisplayTrackDurationAndUrl(skippedTrack, translator)}\n\n` +
|
||||
`${this.getDisplayRepeatMode(queue.repeatMode, 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)
|
||||
],
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in new issue
Block a user