mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 06:28:53 +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}}!",
|
"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}}"
|
"trackRecovered": "{{icon}} **Recovered track**\n{{track}}"
|
||||||
},
|
},
|
||||||
"filters": {
|
"filters": {
|
||||||
@@ -30,8 +30,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"disableAllFiltersButton": "Disable all filters",
|
|
||||||
"allFiltersDisabled": "{{icon}} **Disabled filters**\nAll audio filters have been disabled.",
|
"allFiltersDisabled": "{{icon}} **Disabled filters**\nAll audio filters have been disabled.",
|
||||||
|
"disableAllFiltersButton": "Disable all filters",
|
||||||
|
"nowUsingFilters": "{{icon}} **Filters toggled**\nNow using these {{mode}} filters:",
|
||||||
"selectFilterPlaceholder": "Select a filter from the menu.",
|
"selectFilterPlaceholder": "Select a filter from the menu.",
|
||||||
"selectFilterPlaceholderMany": "Select one or multiple filters.",
|
"selectFilterPlaceholderMany": "Select one or multiple filters.",
|
||||||
"toggleFilterInstructions": "**Toggle filters ({{provider}})**\nEnable or disable audio filters for playback from the menu."
|
"toggleFilterInstructions": "**Toggle filters ({{provider}})**\nEnable or disable audio filters for playback from the menu."
|
||||||
@@ -40,16 +41,18 @@
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "guilds",
|
"name": "guilds",
|
||||||
"description": "Show the top 25 guilds by member count."
|
"description": "Show the top 25 guilds by member count."
|
||||||
}
|
},
|
||||||
|
"topGuildsByMemberCount": "{{icon}} **Top {{count}} guilds by member count ({{totalCount}} total)**",
|
||||||
|
"totalMembers": "**Total members:** **`{{count}`**"
|
||||||
},
|
},
|
||||||
"help": {
|
"help": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "help",
|
"name": "help",
|
||||||
"description": "Show the list of bot commands."
|
"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**",
|
"listTitle": "{{icon}} **List of commands**",
|
||||||
"supportServerCallout": "{{icon}} **Support server**\nJoin the support server for help or to suggest improvements:\n{{invite}}",
|
"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}})**"
|
|
||||||
},
|
},
|
||||||
"history": {
|
"history": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -61,19 +64,27 @@
|
|||||||
"description": "Page number to display for the history."
|
"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": {
|
"join": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "join",
|
"name": "join",
|
||||||
"description": "The bot will join the voice channel if not already in one."
|
"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": {
|
"leave": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "leave",
|
"name": "leave",
|
||||||
"description": "Clear the queue and remove bot from voice channel."
|
"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": {
|
"loop": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -85,6 +96,18 @@
|
|||||||
"description": "Loop mode: Track, queue, autoplay or disabled."
|
"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": {
|
"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": {
|
"move": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -114,7 +139,10 @@
|
|||||||
"description": "The position to move the track to."
|
"description": "The position to move the track to."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"trackMoved": "{{icon}} **Moved track**\n{track}\n\nTrack has been moved from position **`{{fromPosition}}`** to position **`{{toPosition}}`**.",
|
||||||
|
"trackPositionHigherThanQueueLength_one": "{{icon}} **Oops!**\nYou cannot move the track in position **`{{fromPosition}}`** to position **`{{toPosition}}`**. There is only **`1`** track in the queue.\n\nView tracks added to the queue with {{queueCommand}}.",
|
||||||
|
"trackPositionHigherThanQueueLength": "{{icon}} **Oops!**\nYou cannot move the track in position **`{{fromPosition}}`** to position **`{{toPosition}}`**. There are only **`{{count}}`** tracks in the queue.\n\nView tracks added to the queue with {{queueCommand}}."
|
||||||
},
|
},
|
||||||
"nowplaying": {
|
"nowplaying": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -126,7 +154,9 @@
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "pause",
|
"name": "pause",
|
||||||
"description": "Toggle pause for the current track."
|
"description": "Toggle pause for the current track."
|
||||||
}
|
},
|
||||||
|
"pauseConfirmation": "{{icon}} **Paused track**",
|
||||||
|
"resumeConfirmation": "{{icon}} **Resumed track**"
|
||||||
},
|
},
|
||||||
"play": {
|
"play": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -138,7 +168,13 @@
|
|||||||
"description": "Search query by text or URL."
|
"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": {
|
"queue": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -150,13 +186,24 @@
|
|||||||
"description": "Page number to display for the queue."
|
"description": "Page number to display for the queue."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"tracksInQueueTitle": "{{icon}} **Tracks in queue**"
|
||||||
},
|
},
|
||||||
"reload": {
|
"reload": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "reload",
|
"name": "reload",
|
||||||
"description": "Reload slash command, autocomplete and component interactions across shards."
|
"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": {
|
"seek": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -165,10 +212,13 @@
|
|||||||
"options": {
|
"options": {
|
||||||
"duration": {
|
"duration": {
|
||||||
"name": "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": {
|
"shards": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -190,7 +240,8 @@
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "shuffle",
|
"name": "shuffle",
|
||||||
"description": "Randomly shuffle all tracks in the queue."
|
"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": {
|
"skip": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -202,7 +253,11 @@
|
|||||||
"description": "The position in queue to skip to."
|
"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": {
|
"status": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -214,7 +269,8 @@
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "stop",
|
"name": "stop",
|
||||||
"description": "Clear the queue and stop playing audio."
|
"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": {
|
"systemstatus": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -232,9 +288,33 @@
|
|||||||
"description": "Volume percentage: From 1% to 100%."
|
"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": {
|
"statistics": {
|
||||||
"botStatus": {
|
"botStatus": {
|
||||||
"title": "{{icon}} **Bot status**",
|
"title": "{{icon}} **Bot status**",
|
||||||
@@ -268,5 +348,16 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"title": "{{icon}} **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}}!",
|
"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}}"
|
"trackRecovered": "{{icon}} **Recovered track**\n{{track}}"
|
||||||
},
|
},
|
||||||
"filters": {
|
"filters": {
|
||||||
@@ -31,8 +31,9 @@ interface Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"disableAllFiltersButton": "Disable all filters",
|
|
||||||
"allFiltersDisabled": "{{icon}} **Disabled filters**\nAll audio filters have been disabled.",
|
"allFiltersDisabled": "{{icon}} **Disabled filters**\nAll audio filters have been disabled.",
|
||||||
|
"disableAllFiltersButton": "Disable all filters",
|
||||||
|
"nowUsingFilters": "{{icon}} **Filters toggled**\nNow using these {{mode}} filters:",
|
||||||
"selectFilterPlaceholder": "Select a filter from the menu.",
|
"selectFilterPlaceholder": "Select a filter from the menu.",
|
||||||
"selectFilterPlaceholderMany": "Select one or multiple filters.",
|
"selectFilterPlaceholderMany": "Select one or multiple filters.",
|
||||||
"toggleFilterInstructions": "**Toggle filters ({{provider}})**\nEnable or disable audio filters for playback from the menu."
|
"toggleFilterInstructions": "**Toggle filters ({{provider}})**\nEnable or disable audio filters for playback from the menu."
|
||||||
@@ -41,16 +42,18 @@ interface Resources {
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "guilds",
|
"name": "guilds",
|
||||||
"description": "Show the top 25 guilds by member count."
|
"description": "Show the top 25 guilds by member count."
|
||||||
}
|
},
|
||||||
|
"topGuildsByMemberCount": "{{icon}} **Top {{count}} guilds by member count ({{totalCount}} total)**",
|
||||||
|
"totalMembers": "**Total members:** **`{{count}`**"
|
||||||
},
|
},
|
||||||
"help": {
|
"help": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "help",
|
"name": "help",
|
||||||
"description": "Show the list of bot commands."
|
"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**",
|
"listTitle": "{{icon}} **List of commands**",
|
||||||
"supportServerCallout": "{{icon}} **Support server**\nJoin the support server for help or to suggest improvements:\n{{invite}}",
|
"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}})**"
|
|
||||||
},
|
},
|
||||||
"history": {
|
"history": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -62,19 +65,27 @@ interface Resources {
|
|||||||
"description": "Page number to display for the history."
|
"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": {
|
"join": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "join",
|
"name": "join",
|
||||||
"description": "The bot will join the voice channel if not already in one."
|
"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": {
|
"leave": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "leave",
|
"name": "leave",
|
||||||
"description": "Clear the queue and remove bot from voice channel."
|
"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": {
|
"loop": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -86,6 +97,18 @@ interface Resources {
|
|||||||
"description": "Loop mode: Track, queue, autoplay or disabled."
|
"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": {
|
"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": {
|
"move": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -115,7 +140,10 @@ interface Resources {
|
|||||||
"description": "The position to move the track to."
|
"description": "The position to move the track to."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"trackMoved": "{{icon}} **Moved track**\n{track}\n\nTrack has been moved from position **`{{fromPosition}}`** to position **`{{toPosition}}`**.",
|
||||||
|
"trackPositionHigherThanQueueLength_one": "{{icon}} **Oops!**\nYou cannot move the track in position **`{{fromPosition}}`** to position **`{{toPosition}}`**. There is only **`1`** track in the queue.\n\nView tracks added to the queue with {{queueCommand}}.",
|
||||||
|
"trackPositionHigherThanQueueLength": "{{icon}} **Oops!**\nYou cannot move the track in position **`{{fromPosition}}`** to position **`{{toPosition}}`**. There are only **`{{count}}`** tracks in the queue.\n\nView tracks added to the queue with {{queueCommand}}."
|
||||||
},
|
},
|
||||||
"nowplaying": {
|
"nowplaying": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -127,7 +155,9 @@ interface Resources {
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "pause",
|
"name": "pause",
|
||||||
"description": "Toggle pause for the current track."
|
"description": "Toggle pause for the current track."
|
||||||
}
|
},
|
||||||
|
"pauseConfirmation": "{{icon}} **Paused track**",
|
||||||
|
"resumeConfirmation": "{{icon}} **Resumed track**"
|
||||||
},
|
},
|
||||||
"play": {
|
"play": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -139,7 +169,13 @@ interface Resources {
|
|||||||
"description": "Search query by text or URL."
|
"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": {
|
"queue": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -151,13 +187,24 @@ interface Resources {
|
|||||||
"description": "Page number to display for the queue."
|
"description": "Page number to display for the queue."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"tracksInQueueTitle": "{{icon}} **Tracks in queue**"
|
||||||
},
|
},
|
||||||
"reload": {
|
"reload": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "reload",
|
"name": "reload",
|
||||||
"description": "Reload slash command, autocomplete and component interactions across shards."
|
"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": {
|
"seek": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -166,10 +213,13 @@ interface Resources {
|
|||||||
"options": {
|
"options": {
|
||||||
"duration": {
|
"duration": {
|
||||||
"name": "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": {
|
"shards": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -191,7 +241,8 @@ interface Resources {
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "shuffle",
|
"name": "shuffle",
|
||||||
"description": "Randomly shuffle all tracks in the queue."
|
"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": {
|
"skip": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -203,7 +254,11 @@ interface Resources {
|
|||||||
"description": "The position in queue to skip to."
|
"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": {
|
"status": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -215,7 +270,8 @@ interface Resources {
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "stop",
|
"name": "stop",
|
||||||
"description": "Clear the queue and stop playing audio."
|
"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": {
|
"systemstatus": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -233,9 +289,33 @@ interface Resources {
|
|||||||
"description": "Volume percentage: From 1% to 100%."
|
"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": {
|
"statistics": {
|
||||||
"botStatus": {
|
"botStatus": {
|
||||||
"title": "{{icon}} **Bot status**",
|
"title": "{{icon}} **Bot status**",
|
||||||
@@ -269,6 +349,17 @@ interface Resources {
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"title": "{{icon}} **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
|
BaseSlashCommandReturnType
|
||||||
} from '../types/interactionTypes';
|
} from '../types/interactionTypes';
|
||||||
import { Validator, ValidatorParams } from '../types/utilTypes';
|
import { Validator, ValidatorParams } from '../types/utilTypes';
|
||||||
|
import { TFunction } from 'i18next';
|
||||||
|
import { formatSlashCommand } from '../common/formattingUtils';
|
||||||
|
|
||||||
abstract class BaseInteraction {
|
abstract class BaseInteraction {
|
||||||
embedOptions: EmbedOptions;
|
embedOptions: EmbedOptions;
|
||||||
@@ -72,18 +74,18 @@ abstract class BaseInteraction {
|
|||||||
return durationFormat;
|
return durationFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getFormattedTrackUrl(track: Track): string {
|
protected getFormattedTrackUrl(track: Track, translator: TFunction): string {
|
||||||
const trackTitle = track.title ?? 'Title unavailable';
|
const trackTitle = track.title ?? translator('musicPlayerCommon.unavailableTrackTitle');
|
||||||
const trackUrl = track.url ?? track.raw.url;
|
const trackUrl = track.url ?? track.raw.url;
|
||||||
if (!trackTitle || !trackUrl) {
|
if (!trackTitle || !trackUrl) {
|
||||||
return '**Unavailable**';
|
return translator('musicPlayerCommon.unavailableTrackUrl');
|
||||||
}
|
}
|
||||||
return `**[${trackTitle}](${trackUrl})**`;
|
return `**[${trackTitle}](${trackUrl})**`;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getDisplayTrackDurationAndUrl(track: Track): string {
|
protected getDisplayTrackDurationAndUrl(track: Track, translator: TFunction): string {
|
||||||
const formattedDuration = this.getFormattedDuration(track);
|
const formattedDuration = this.getFormattedDuration(track);
|
||||||
const formattedUrl = this.getFormattedTrackUrl(track);
|
const formattedUrl = this.getFormattedTrackUrl(track, translator);
|
||||||
|
|
||||||
return `${formattedDuration} ${formattedUrl}`;
|
return `${formattedDuration} ${formattedUrl}`;
|
||||||
}
|
}
|
||||||
@@ -116,24 +118,27 @@ abstract class BaseInteraction {
|
|||||||
|
|
||||||
protected getFooterDisplayPageInfo(
|
protected getFooterDisplayPageInfo(
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
queue: GuildQueue | GuildQueueHistory
|
queue: GuildQueue | GuildQueueHistory,
|
||||||
|
translator: TFunction
|
||||||
): EmbedFooterData {
|
): EmbedFooterData {
|
||||||
if (!queue.tracks.data.length) {
|
|
||||||
return { text: 'Page 1 of 1 (0 tracks)' };
|
|
||||||
}
|
|
||||||
|
|
||||||
const pageIndex: number = (interaction.options.getInteger('page') || 1) - 1;
|
const pageIndex: number = (interaction.options.getInteger('page') || 1) - 1;
|
||||||
const totalPages: number = Math.ceil(queue.tracks.data.length / 10) || 1;
|
const totalPages: number = Math.ceil(queue.tracks.data.length / 10) || 1;
|
||||||
return {
|
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 => {
|
protected getDisplayTrackRequestedBy = (track: Track, translator: TFunction): string => {
|
||||||
return track.requestedBy ? `<@${track.requestedBy.id}>` : 'Unavailable';
|
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()!;
|
const timestamp: PlayerTimestamp = queue.node.getTimestamp()!;
|
||||||
let progressBar: string = `**\`${timestamp.current.label}\`** ${queue.node.createProgressBar({
|
let progressBar: string = `**\`${timestamp.current.label}\`** ${queue.node.createProgressBar({
|
||||||
queue: false,
|
queue: false,
|
||||||
@@ -145,17 +150,19 @@ abstract class BaseInteraction {
|
|||||||
})} **\`${timestamp.total.label}\`**`;
|
})} **\`${timestamp.total.label}\`**`;
|
||||||
|
|
||||||
if (Number(queue.currentTrack?.raw.duration) === 0 || queue.currentTrack?.duration === '0:00') {
|
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) {
|
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;
|
return progressBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getDisplayRepeatMode(repeatMode: number, state: string = 'info'): string {
|
protected getDisplayRepeatMode(repeatMode: number, translator: TFunction, state: string = 'info'): string {
|
||||||
let loopModeUserString: string;
|
let loopModeUserString: string;
|
||||||
let icon: string;
|
let icon: string;
|
||||||
|
|
||||||
@@ -176,10 +183,11 @@ abstract class BaseInteraction {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return translator('musicPlayerCommon.loopingInfo', {
|
||||||
`**${icon} Looping**\n` +
|
icon,
|
||||||
`Loop mode is set to **\`${loopModeUserString}\`**. You can change it with **\`/loop\`**.\n\n`
|
loopMode: loopModeUserString,
|
||||||
);
|
loopCommand: formatSlashCommand('loop', translator)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract execute(
|
abstract execute(
|
||||||
@@ -210,11 +218,15 @@ abstract class BaseInteractionWithEmbedResponse extends BaseInteraction {
|
|||||||
|
|
||||||
protected getEmbedQueueAuthor(
|
protected getEmbedQueueAuthor(
|
||||||
interaction: MessageComponentInteraction | ChatInputCommandInteraction,
|
interaction: MessageComponentInteraction | ChatInputCommandInteraction,
|
||||||
queue: GuildQueue
|
queue: GuildQueue,
|
||||||
|
translator: TFunction
|
||||||
): EmbedAuthorOptions {
|
): EmbedAuthorOptions {
|
||||||
const bitrate = queue.channel ? queue.channel.bitrate / 1000 : 0;
|
const bitrate = queue.channel ? queue.channel.bitrate / 1000 : 0;
|
||||||
return {
|
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
|
iconURL: interaction.guild!.iconURL() || this.embedOptions.info.fallbackIconUrl
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import assert from 'assert';
|
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 { lstatSync, readdirSync } from 'fs';
|
||||||
import i18n from 'i18next';
|
import i18n from 'i18next';
|
||||||
import i18nextFsBackend, { FsBackendOptions } from 'i18next-fs-backend';
|
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');
|
return translatorInstance.getFixedT(interaction.guildLocale ?? 'en');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useUserTranslator(interaction: Interaction) {
|
export function useUserTranslator(interaction: BaseInteraction) {
|
||||||
return translatorInstance.getFixedT(interaction.locale ?? 'en');
|
return translatorInstance.getFixedT(interaction.locale ?? 'en');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class BackCommand extends BaseSlashCommandInteraction {
|
|||||||
translator: TFunction
|
translator: TFunction
|
||||||
) {
|
) {
|
||||||
if (backtoTrackPosition > history.tracks.data.length) {
|
if (backtoTrackPosition > history.tracks.data.length) {
|
||||||
return await this.handleTrackPositionHigherThanQueueLength(
|
return await this.handleTrackPositionHigherThanHistoryLength(
|
||||||
backtoTrackPosition,
|
backtoTrackPosition,
|
||||||
history,
|
history,
|
||||||
logger,
|
logger,
|
||||||
@@ -65,7 +65,7 @@ class BackCommand extends BaseSlashCommandInteraction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleTrackPositionHigherThanQueueLength(
|
private async handleTrackPositionHigherThanHistoryLength(
|
||||||
backToTrackPosition: number,
|
backToTrackPosition: number,
|
||||||
history: GuildQueueHistory,
|
history: GuildQueueHistory,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
@@ -77,7 +77,7 @@ class BackCommand extends BaseSlashCommandInteraction {
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
translator('commands.back.trackPositionHigherThanQueueLength', {
|
translator('commands.back.trackPositionHigherThanHistoryLength', {
|
||||||
icon: this.embedOptions.icons.warning,
|
icon: this.embedOptions.icons.warning,
|
||||||
count: history.tracks.data.length,
|
count: history.tracks.data.length,
|
||||||
backPosition: backToTrackPosition,
|
backPosition: backToTrackPosition,
|
||||||
@@ -137,7 +137,7 @@ class BackCommand extends BaseSlashCommandInteraction {
|
|||||||
.setDescription(
|
.setDescription(
|
||||||
translator('commands.back.trackRecovered', {
|
translator('commands.back.trackRecovered', {
|
||||||
icon: this.embedOptions.icons.back,
|
icon: this.embedOptions.icons.back,
|
||||||
track: this.getDisplayTrackDurationAndUrl(recoveredTrack)
|
track: this.getDisplayTrackDurationAndUrl(recoveredTrack, translator)
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.setThumbnail(this.getTrackThumbnailUrl(recoveredTrack))
|
.setThumbnail(this.getTrackThumbnailUrl(recoveredTrack))
|
||||||
|
|||||||
@@ -16,7 +16,9 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
|||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { checkHistoryExists } from '../../../utils/validation/queueValidator';
|
import { checkHistoryExists } from '../../../utils/validation/queueValidator';
|
||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
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 {
|
class HistoryCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -31,6 +33,7 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
|||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const history: GuildQueueHistory = useHistory(interaction.guild!.id)!;
|
const history: GuildQueueHistory = useHistory(interaction.guild!.id)!;
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
@@ -45,10 +48,10 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
|||||||
const totalPages: number = this.getTotalPages(history);
|
const totalPages: number = this.getTotalPages(history);
|
||||||
|
|
||||||
if (pageIndex > totalPages - 1) {
|
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!;
|
const currentTrack: Track = history.currentTrack!;
|
||||||
if (currentTrack) {
|
if (currentTrack) {
|
||||||
@@ -58,11 +61,19 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
|||||||
queue,
|
queue,
|
||||||
history,
|
history,
|
||||||
currentTrack,
|
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(
|
private async handleCurrentTrack(
|
||||||
@@ -71,7 +82,8 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
|||||||
queue: GuildQueue,
|
queue: GuildQueue,
|
||||||
history: GuildQueueHistory,
|
history: GuildQueueHistory,
|
||||||
currentTrack: Track,
|
currentTrack: Track,
|
||||||
historyTracksListString: string
|
historyTracksListString: string,
|
||||||
|
translator: TFunction
|
||||||
) {
|
) {
|
||||||
logger.debug('History exists with current track, gathering information.');
|
logger.debug('History exists with current track, gathering information.');
|
||||||
|
|
||||||
@@ -100,9 +112,11 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
|||||||
components.push(skipButton);
|
components.push(skipButton);
|
||||||
|
|
||||||
if (this.embedOptions.components.showButtonLabels) {
|
if (this.embedOptions.components.showButtonLabels) {
|
||||||
previousButton.label = 'Previous';
|
previousButton.label = translator('musicPlayerCommon.controls.previous');
|
||||||
playPauseButton.label = queue.node.isPaused() ? 'Resume' : 'Pause';
|
playPauseButton.label = queue.node.isPaused()
|
||||||
skipButton.label = 'Skip';
|
? translator('musicPlayerCommon.controls.resume')
|
||||||
|
: translator('musicPlayerCommon.controls.pause');
|
||||||
|
skipButton.label = translator('musicPlayerCommon.controls.skip');
|
||||||
}
|
}
|
||||||
|
|
||||||
const embedActionRow: APIActionRowComponent<APIMessageActionRowComponent> = {
|
const embedActionRow: APIActionRowComponent<APIMessageActionRowComponent> = {
|
||||||
@@ -114,18 +128,30 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
|||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedQueueAuthor(interaction, queue))
|
.setAuthor(this.getEmbedQueueAuthor(interaction, queue, translator))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.audioPlaying} Now playing**\n` +
|
translator('musicPlayerCommon.nowPlayingTitle', {
|
||||||
`${this.getFormattedTrackUrl(currentTrack)}\n` +
|
icon: this.embedOptions.icons.audioPlaying
|
||||||
`**Requested by:** ${this.getDisplayTrackRequestedBy(currentTrack)}\n` +
|
}) +
|
||||||
`${this.getDisplayQueueProgressBar(queue)}\n\n` +
|
'\n' +
|
||||||
`${this.getDisplayRepeatMode(queue.repeatMode)}` +
|
this.getFormattedTrackUrl(currentTrack, translator) +
|
||||||
`**${this.embedOptions.icons.queue} Tracks in history**\n` +
|
'\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
|
historyTracksListString
|
||||||
)
|
)
|
||||||
.setThumbnail(this.getTrackThumbnailUrl(currentTrack))
|
.setThumbnail(this.getTrackThumbnailUrl(currentTrack))
|
||||||
.setFooter(this.getDisplayFullFooterInfo(interaction, history))
|
.setFooter(this.getDisplayFullFooterInfo(interaction, history, translator))
|
||||||
.setColor(this.embedOptions.colors.info)
|
.setColor(this.embedOptions.colors.info)
|
||||||
],
|
],
|
||||||
components: [embedActionRow]
|
components: [embedActionRow]
|
||||||
@@ -138,7 +164,8 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
|||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
queue: GuildQueue,
|
queue: GuildQueue,
|
||||||
history: GuildQueueHistory,
|
history: GuildQueueHistory,
|
||||||
historyTracksListString: string
|
historyTracksListString: string,
|
||||||
|
translator: TFunction
|
||||||
) {
|
) {
|
||||||
logger.debug('History exists but there is no current track.');
|
logger.debug('History exists but there is no current track.');
|
||||||
|
|
||||||
@@ -146,13 +173,15 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
|||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedQueueAuthor(interaction, queue))
|
.setAuthor(this.getEmbedQueueAuthor(interaction, queue, translator))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`${this.getDisplayRepeatMode(queue.repeatMode)}` +
|
translator('commands.history.tracksInHistoryTitle', {
|
||||||
`**${this.embedOptions.icons.queue} Tracks in history**\n` +
|
icon: this.embedOptions.icons.queue
|
||||||
|
}) +
|
||||||
|
'\n' +
|
||||||
historyTracksListString
|
historyTracksListString
|
||||||
)
|
)
|
||||||
.setFooter(this.getDisplayFullFooterInfo(interaction, history))
|
.setFooter(this.getDisplayFullFooterInfo(interaction, history, translator))
|
||||||
.setColor(this.embedOptions.colors.info)
|
.setColor(this.embedOptions.colors.info)
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -162,7 +191,8 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
|||||||
logger: Logger,
|
logger: Logger,
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
pageIndex: number,
|
pageIndex: number,
|
||||||
totalPages: number
|
totalPages: number,
|
||||||
|
translator: TFunction
|
||||||
) {
|
) {
|
||||||
logger.debug('Specified page was higher than total pages.');
|
logger.debug('Specified page was higher than total pages.');
|
||||||
|
|
||||||
@@ -171,9 +201,11 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
translator('commands.history.invalidPageNumber', {
|
||||||
`Page **\`${pageIndex + 1}\`** is not a valid page number.\n\n` +
|
icon: this.embedOptions.icons.warning,
|
||||||
`There are only a total of **\`${totalPages}\`** pages in the history.`
|
page: pageIndex + 1,
|
||||||
|
count: totalPages
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.warning)
|
.setColor(this.embedOptions.colors.warning)
|
||||||
]
|
]
|
||||||
@@ -189,24 +221,27 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
|||||||
return Math.ceil(history.tracks.data.length / 10) || 1;
|
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) {
|
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
|
return history.tracks.data
|
||||||
.slice(pageIndex * 10, pageIndex * 10 + 10)
|
.slice(pageIndex * 10, pageIndex * 10 + 10)
|
||||||
.map((track, index) => {
|
.map((track, index) => {
|
||||||
return `**${pageIndex * 10 + index + 1}.** ${this.getDisplayTrackDurationAndUrl(track)}`;
|
return `**${pageIndex * 10 + index + 1}.** ${this.getDisplayTrackDurationAndUrl(track, translator)}`;
|
||||||
})
|
})
|
||||||
.join('\n');
|
.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
private getDisplayFullFooterInfo(
|
private getDisplayFullFooterInfo(
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
history: GuildQueueHistory
|
history: GuildQueueHistory,
|
||||||
|
translator: TFunction
|
||||||
): EmbedFooterData {
|
): EmbedFooterData {
|
||||||
const pagination = this.getFooterDisplayPageInfo(interaction, history);
|
const pagination = this.getFooterDisplayPageInfo(interaction, history, translator);
|
||||||
|
|
||||||
const fullFooterData = {
|
const fullFooterData = {
|
||||||
text: `${pagination.text}`
|
text: `${pagination.text}`
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ
|
|||||||
import { checkInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { checkInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
import { checkVoicePermissionJoinAndTalk } from '../../../utils/validation/permissionValidator';
|
import { checkVoicePermissionJoinAndTalk } from '../../../utils/validation/permissionValidator';
|
||||||
import { Logger } from 'pino';
|
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 {
|
class JoinCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -16,23 +18,24 @@ class JoinCommand extends BaseSlashCommandInteraction {
|
|||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
await this.runValidators({ interaction, executionId }, [checkInVoiceChannel, checkVoicePermissionJoinAndTalk]);
|
await this.runValidators({ interaction, executionId }, [checkInVoiceChannel, checkVoicePermissionJoinAndTalk]);
|
||||||
|
|
||||||
const existingQueue = useQueue(interaction.guild!.id);
|
const existingQueue = useQueue(interaction.guild!.id);
|
||||||
|
|
||||||
if (existingQueue) {
|
if (existingQueue) {
|
||||||
return await this.handleExisitingQueue(interaction, existingQueue);
|
return await this.handleExisitingQueue(interaction, existingQueue, translator);
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue = this.createQueue(interaction);
|
const queue = this.createQueue(interaction);
|
||||||
if (!queue) {
|
if (!queue) {
|
||||||
return await this.handleCouldNotConnect(interaction);
|
return await this.handleCouldNotConnect(interaction, translator);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.connectToVoiceChannel(logger, queue, interaction);
|
await this.connectToVoiceChannel(logger, queue, interaction);
|
||||||
if (!queue.dispatcher) {
|
if (!queue.dispatcher) {
|
||||||
return await this.handleCouldNotConnect(interaction);
|
return await this.handleCouldNotConnect(interaction, translator);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
@@ -41,9 +44,11 @@ class JoinCommand extends BaseSlashCommandInteraction {
|
|||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.success} Joined channel**\n` +
|
translator('commands.join.joinedChannel', {
|
||||||
`Connected to voice channel: <#${queue.dispatcher.channel.id}>\n\n` +
|
icon: this.embedOptions.icons.success,
|
||||||
'To add tracks, use the **`/play`** command!'
|
channel: `<#${queue.dispatcher.channel.id}>`,
|
||||||
|
playCommand: formatSlashCommand('play', translator)
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.success)
|
.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({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
translator('commands.join.couldNotJoin', {
|
||||||
'Could not join voice channel, please try again.'
|
icon: this.embedOptions.icons.warning
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.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 connectedChannel = queue.dispatcher?.channel;
|
||||||
const channelMention = connectedChannel?.id ? `<#${connectedChannel.id}>` : 'Unknown';
|
const channelMention = connectedChannel?.id ? `<#${connectedChannel.id}>` : '<#0>';
|
||||||
|
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
translator('commands.join.alreadyConnected', {
|
||||||
`I am already connected to voice channel ${channelMention}.\n\n` +
|
icon: this.embedOptions.icons.warning,
|
||||||
'To disconnect me from the channel, use the **`/leave`** command.'
|
channel: channelMention,
|
||||||
|
leaveCommand: formatSlashCommand('leave', translator)
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.warning)
|
.setColor(this.embedOptions.colors.warning)
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
|||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
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 {
|
class LeaveCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -15,6 +16,7 @@ class LeaveCommand extends BaseSlashCommandInteraction {
|
|||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
@@ -33,9 +35,10 @@ class LeaveCommand extends BaseSlashCommandInteraction {
|
|||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.success} Leaving channel**\n` +
|
translator('commands.leave.leavingChannel', {
|
||||||
'Cleared the track queue and left voice channel.\n\n' +
|
icon: this.embedOptions.icons.success,
|
||||||
'To play more music, use the **`/play`** command!'
|
playCommand: formatSlashCommand('play', translator)
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.success)
|
.setColor(this.embedOptions.colors.success)
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
|||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
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 {
|
class LoopCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -37,6 +38,7 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
|||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
@@ -50,34 +52,44 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
|||||||
const currentRepeatMode: QueueRepeatMode = queue.repeatMode;
|
const currentRepeatMode: QueueRepeatMode = queue.repeatMode;
|
||||||
|
|
||||||
if (!userInputRepeatMode && userInputRepeatMode !== 0) {
|
if (!userInputRepeatMode && userInputRepeatMode !== 0) {
|
||||||
return await this.handleNoInputMode(logger, interaction, currentRepeatMode);
|
return await this.handleNoInputMode(logger, interaction, currentRepeatMode, translator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userInputRepeatMode === currentRepeatMode) {
|
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(
|
private async handleNoInputMode(
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
currentRepeatMode: QueueRepeatMode
|
currentRepeatMode: QueueRepeatMode,
|
||||||
|
translator: TFunction
|
||||||
): Promise<Message> {
|
): Promise<Message> {
|
||||||
logger.debug('No repeat mode was provided, responding with current repeat mode.');
|
logger.debug('No repeat mode was provided, responding with current repeat mode.');
|
||||||
|
|
||||||
const repeatModeEmbedIcon =
|
const repeatModeEmbedIcon =
|
||||||
currentRepeatMode === 3 ? this.embedOptions.icons.autoplay : this.embedOptions.icons.loop;
|
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.');
|
logger.debug('Responding with info embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${repeatModeEmbedIcon} Current loop mode**\n` +
|
translator('commands.loop.loopModeInformation', {
|
||||||
`The looping mode is currently set to **\`${repeatModeEmbedName}\`**.`
|
icon: repeatModeEmbedIcon,
|
||||||
|
mode: repeatModeEmbedName
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.info)
|
.setColor(this.embedOptions.colors.info)
|
||||||
]
|
]
|
||||||
@@ -87,17 +99,20 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
|||||||
private async handleSameMode(
|
private async handleSameMode(
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
currentRepeatMode: QueueRepeatMode
|
currentRepeatMode: QueueRepeatMode,
|
||||||
|
translator: TFunction
|
||||||
): Promise<Message> {
|
): Promise<Message> {
|
||||||
const repeatModeEmbedName = this.getRepeatModeEmbedName(currentRepeatMode);
|
const repeatModeEmbedName = this.getRepeatModeEmbedName(currentRepeatMode, translator);
|
||||||
logger.debug(`Loop mode is already set to '${repeatModeEmbedName}'.`);
|
logger.debug(`Loop mode is already set to '${repeatModeEmbedName}'.`);
|
||||||
logger.debug('Responding with warning embed.');
|
logger.debug('Responding with warning embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
translator('commands.loop.alreadySet', {
|
||||||
`Loop mode is already **\`${repeatModeEmbedName}\`**.`
|
icon: this.embedOptions.icons.warning,
|
||||||
|
mode: repeatModeEmbedName
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.warning)
|
.setColor(this.embedOptions.colors.warning)
|
||||||
]
|
]
|
||||||
@@ -109,10 +124,15 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
|||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
queue: GuildQueue,
|
queue: GuildQueue,
|
||||||
fromRepeatMode: QueueRepeatMode,
|
fromRepeatMode: QueueRepeatMode,
|
||||||
toRepeatMode: QueueRepeatMode
|
toRepeatMode: QueueRepeatMode,
|
||||||
|
translator: TFunction
|
||||||
): Promise<Message> {
|
): Promise<Message> {
|
||||||
const newRepeatModeEmbedName = this.getRepeatModeEmbedName(toRepeatMode);
|
const newRepeatModeEmbedName = this.getRepeatModeEmbedName(toRepeatMode, translator);
|
||||||
const getChangedRepeatModeEmbedReply = this.getChangedRepeatModeEmbedReply(fromRepeatMode, toRepeatMode);
|
const getChangedRepeatModeEmbedReply = this.getChangedRepeatModeEmbedReply(
|
||||||
|
fromRepeatMode,
|
||||||
|
toRepeatMode,
|
||||||
|
translator
|
||||||
|
);
|
||||||
|
|
||||||
queue.setRepeatMode(toRepeatMode);
|
queue.setRepeatMode(toRepeatMode);
|
||||||
logger.debug(`Loop mode changed to '${newRepeatModeEmbedName}'.`);
|
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 } = {
|
const repeatModeEmbedString: { [key in QueueRepeatMode]: string } = {
|
||||||
[QueueRepeatMode.OFF]: 'disabled',
|
[QueueRepeatMode.OFF]: translator('commands.loop.repeatMode.off'),
|
||||||
[QueueRepeatMode.TRACK]: 'track',
|
[QueueRepeatMode.TRACK]: translator('commands.loop.repeatMode.track'),
|
||||||
[QueueRepeatMode.QUEUE]: 'queue',
|
[QueueRepeatMode.QUEUE]: translator('commands.loop.repeatMode.queue'),
|
||||||
[QueueRepeatMode.AUTOPLAY]: 'autoplay'
|
[QueueRepeatMode.AUTOPLAY]: translator('commands.loop.repeatMode.autoplay')
|
||||||
};
|
};
|
||||||
|
|
||||||
return repeatModeEmbedString[repeatMode];
|
return repeatModeEmbedString[repeatMode];
|
||||||
}
|
}
|
||||||
|
|
||||||
private getChangedRepeatModeEmbedReply(fromRepeatMode: QueueRepeatMode, toRepeatMode: QueueRepeatMode): string {
|
private getChangedRepeatModeEmbedReply(
|
||||||
const fromRepeatModeEmbedName = this.getRepeatModeEmbedName(fromRepeatMode);
|
fromRepeatMode: QueueRepeatMode,
|
||||||
const toRepeatModeEmbedName = this.getRepeatModeEmbedName(toRepeatMode);
|
toRepeatMode: QueueRepeatMode,
|
||||||
|
translator: TFunction
|
||||||
|
): string {
|
||||||
|
const fromRepeatModeEmbedName = this.getRepeatModeEmbedName(fromRepeatMode, translator);
|
||||||
|
const toRepeatModeEmbedName = this.getRepeatModeEmbedName(toRepeatMode, translator);
|
||||||
|
|
||||||
let repeatModeIcon = this.embedOptions.icons.looping;
|
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) {
|
if (toRepeatMode === QueueRepeatMode.OFF) {
|
||||||
repeatModeIcon = this.embedOptions.icons.success;
|
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) {
|
} else if (toRepeatMode === QueueRepeatMode.AUTOPLAY) {
|
||||||
repeatModeIcon = this.embedOptions.icons.autoplaying;
|
repeatModeIcon = this.embedOptions.icons.autoplaying;
|
||||||
newRepeatModeMessage = 'When the queue is empty, similar tracks will start playing!';
|
newRepeatModeMessage = translator('commands.loop.willAutoplay');
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
`**${repeatModeIcon} Loop mode changed**\n` +
|
translator('commands.loop.modeChanged', {
|
||||||
`Changing loop mode from **\`${fromRepeatModeEmbedName}\`** to **\`${toRepeatModeEmbedName}\`**.\n\n` +
|
icon: repeatModeIcon,
|
||||||
|
fromName: fromRepeatModeEmbedName,
|
||||||
|
toName: toRepeatModeEmbedName
|
||||||
|
}) +
|
||||||
|
'\n' +
|
||||||
|
'\n' +
|
||||||
newRepeatModeMessage
|
newRepeatModeMessage
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
|||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
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 {
|
class LyricsCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -23,6 +24,7 @@ class LyricsCommand extends BaseSlashCommandInteraction {
|
|||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
const query: string = interaction.options.getString('query')!;
|
const query: string = interaction.options.getString('query')!;
|
||||||
@@ -50,14 +52,14 @@ class LyricsCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
if (!finalLyricsData) {
|
if (!finalLyricsData) {
|
||||||
logger.debug('No matching lyrics found.');
|
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) {
|
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 {
|
private getGeniusSearchQuery(logger: Logger, query: string, queue: GuildQueue): string {
|
||||||
@@ -155,15 +157,18 @@ class LyricsCommand extends BaseSlashCommandInteraction {
|
|||||||
private async sendNoLyricsFoundEmbed(
|
private async sendNoLyricsFoundEmbed(
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
geniusSearchQuery: string
|
geniusSearchQuery: string,
|
||||||
|
translator: TFunction
|
||||||
) {
|
) {
|
||||||
logger.debug('Responding with warning embed.');
|
logger.debug('Responding with warning embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.warning} No lyrics found**\n` +
|
translator('commands.lyrics.noLyricsFound', {
|
||||||
`There was no Genius lyrics found for track **${geniusSearchQuery}**.`
|
icon: this.embedOptions.icons.warning,
|
||||||
|
query: geniusSearchQuery
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.warning)
|
.setColor(this.embedOptions.colors.warning)
|
||||||
]
|
]
|
||||||
@@ -173,7 +178,8 @@ class LyricsCommand extends BaseSlashCommandInteraction {
|
|||||||
private async sendMultipleLyricsMessages(
|
private async sendMultipleLyricsMessages(
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
geniusLyricsResult: LyricsData
|
geniusLyricsResult: LyricsData,
|
||||||
|
translator: TFunction
|
||||||
): Promise<Message> {
|
): Promise<Message> {
|
||||||
logger.debug('Lyrics text too long, splitting into multiple messages.');
|
logger.debug('Lyrics text too long, splitting into multiple messages.');
|
||||||
const messageCount: number = Math.ceil(geniusLyricsResult.lyrics.length / 3800);
|
const messageCount: number = Math.ceil(geniusLyricsResult.lyrics.length / 3800);
|
||||||
@@ -181,9 +187,13 @@ class LyricsCommand extends BaseSlashCommandInteraction {
|
|||||||
embedList.push(
|
embedList.push(
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.queue} Showing lyrics**\n` +
|
translator('commands.lyrics.lyricsEmbed', {
|
||||||
`**Track: [${geniusLyricsResult.title}](${geniusLyricsResult.url})**\n` +
|
icon: this.embedOptions.icons.queue,
|
||||||
`**Artist: [${geniusLyricsResult.artist.name}](${geniusLyricsResult.artist.url})**\n\n`
|
trackTitle: geniusLyricsResult.title,
|
||||||
|
trackUrl: geniusLyricsResult.url,
|
||||||
|
artistName: geniusLyricsResult.artist.name,
|
||||||
|
artistUrl: geniusLyricsResult.artist.url
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.info)
|
.setColor(this.embedOptions.colors.info)
|
||||||
);
|
);
|
||||||
@@ -204,16 +214,23 @@ class LyricsCommand extends BaseSlashCommandInteraction {
|
|||||||
private async sendLyricsEmbed(
|
private async sendLyricsEmbed(
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
geniusLyricsResult: LyricsData
|
geniusLyricsResult: LyricsData,
|
||||||
|
translator: TFunction
|
||||||
): Promise<Message> {
|
): Promise<Message> {
|
||||||
logger.debug('Responding with info embed.');
|
logger.debug('Responding with info embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.queue} Showing lyrics**\n` +
|
translator('commands.lyrics.lyricsEmbed', {
|
||||||
`**Track: [${geniusLyricsResult.title}](${geniusLyricsResult.url})**\n` +
|
icon: this.embedOptions.icons.queue,
|
||||||
`**Artist: [${geniusLyricsResult.artist.name}](${geniusLyricsResult.artist.url})**\n\n` +
|
trackTitle: geniusLyricsResult.title,
|
||||||
|
trackUrl: geniusLyricsResult.url,
|
||||||
|
artistName: geniusLyricsResult.artist.name,
|
||||||
|
artistUrl: geniusLyricsResult.artist.url
|
||||||
|
}) +
|
||||||
|
'\n' +
|
||||||
|
'\n' +
|
||||||
`\`\`\`fix\n${geniusLyricsResult.lyrics}\`\`\``
|
`\`\`\`fix\n${geniusLyricsResult.lyrics}\`\`\``
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.info)
|
.setColor(this.embedOptions.colors.info)
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ
|
|||||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
import { Logger } from 'pino';
|
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 {
|
class MoveCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -21,6 +23,7 @@ class MoveCommand extends BaseSlashCommandInteraction {
|
|||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
@@ -33,7 +36,14 @@ class MoveCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
const fromPositionInput: number = interaction.options.getInteger('from')!;
|
const fromPositionInput: number = interaction.options.getInteger('from')!;
|
||||||
const toPositionInput: number = interaction.options.getInteger('to')!;
|
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(
|
private async handleMoveTrackToPosition(
|
||||||
@@ -41,7 +51,8 @@ class MoveCommand extends BaseSlashCommandInteraction {
|
|||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
queue: GuildQueue,
|
queue: GuildQueue,
|
||||||
fromPosition: number,
|
fromPosition: number,
|
||||||
toPosition: number
|
toPosition: number,
|
||||||
|
translator: TFunction
|
||||||
) {
|
) {
|
||||||
if (fromPosition > queue.tracks.data.length || toPosition > queue.tracks.data.length) {
|
if (fromPosition > queue.tracks.data.length || toPosition > queue.tracks.data.length) {
|
||||||
logger.debug('One of the specified track positions was higher than total tracks.');
|
logger.debug('One of the specified track positions was higher than total tracks.');
|
||||||
@@ -50,13 +61,14 @@ class MoveCommand extends BaseSlashCommandInteraction {
|
|||||||
toPosition,
|
toPosition,
|
||||||
queue,
|
queue,
|
||||||
logger,
|
logger,
|
||||||
interaction
|
interaction,
|
||||||
|
translator
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const trackToMove: Track = queue.tracks.data[fromPosition - 1];
|
const trackToMove: Track = queue.tracks.data[fromPosition - 1];
|
||||||
queue.node.move(trackToMove, toPosition - 1);
|
queue.node.move(trackToMove, toPosition - 1);
|
||||||
logger.debug(`Moved track from position ${fromPosition} to position ${toPosition} in queue`);
|
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,
|
toPosition: number,
|
||||||
queue: GuildQueue,
|
queue: GuildQueue,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
interaction: ChatInputCommandInteraction
|
interaction: ChatInputCommandInteraction,
|
||||||
|
translator: TFunction
|
||||||
) {
|
) {
|
||||||
logger.debug('One of the specified track positions was higher than total tracks.');
|
logger.debug('One of the specified track positions was higher than total tracks.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
translator('commands.move.trackPositionHigherThanQueueLength', {
|
||||||
`You cannot move track in position **\`${fromPosition}\`** to position **\`${toPosition}\`**. There are only **\`${queue.tracks.data.length}\`** tracks in the queue.\n\n` +
|
icon: this.embedOptions.icons.warning,
|
||||||
'View tracks added to the queue with **`/queue`**.'
|
fromPosition,
|
||||||
|
toPosition,
|
||||||
|
count: queue.tracks.data.length,
|
||||||
|
queueCommand: formatSlashCommand('queue', translator)
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.warning)
|
.setColor(this.embedOptions.colors.warning)
|
||||||
]
|
]
|
||||||
@@ -85,16 +102,20 @@ class MoveCommand extends BaseSlashCommandInteraction {
|
|||||||
movedTrack: Track,
|
movedTrack: Track,
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
fromPosition: number,
|
fromPosition: number,
|
||||||
toPosition: number
|
toPosition: number,
|
||||||
|
translator: TFunction
|
||||||
) {
|
) {
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.moved} Moved track**\n` +
|
translator('commands.move.trackMoved', {
|
||||||
`${this.getDisplayTrackDurationAndUrl(movedTrack)}\n\n` +
|
icon: this.embedOptions.icons.moved,
|
||||||
`Track has been moved from position **\`${fromPosition}\`** to position **\`${toPosition}\`**.`
|
track: this.getDisplayTrackDurationAndUrl(movedTrack, translator),
|
||||||
|
fromPosition,
|
||||||
|
toPosition
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setThumbnail(this.getTrackThumbnailUrl(movedTrack))
|
.setThumbnail(this.getTrackThumbnailUrl(movedTrack))
|
||||||
.setColor(this.embedOptions.colors.success)
|
.setColor(this.embedOptions.colors.success)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
|||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType, TrackMetadata } from '../../../types/interactionTypes';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType, TrackMetadata } from '../../../types/interactionTypes';
|
||||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
import { localizeCommand } from '../../../common/localeUtil';
|
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||||
|
|
||||||
class NowPlayingCommand extends BaseSlashCommandInteraction {
|
class NowPlayingCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -25,6 +25,7 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
|
|||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
@@ -37,11 +38,11 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
const tracksInQueueCount: number = queue.tracks.data.length;
|
const tracksInQueueCount: number = queue.tracks.data.length;
|
||||||
const currentTrack: Track = queue.currentTrack!;
|
const currentTrack: Track = queue.currentTrack!;
|
||||||
const displayTrackUrl: string = this.getFormattedTrackUrl(currentTrack);
|
const displayTrackUrl: string = this.getFormattedTrackUrl(currentTrack, translator);
|
||||||
const displayTrackRequestedBy: string = this.getDisplayTrackRequestedBy(currentTrack);
|
const displayTrackRequestedBy: string = this.getDisplayTrackRequestedBy(currentTrack, translator);
|
||||||
const displayTrackPlayingStatus: string = this.getDisplayTrackPlayingStatus(queue);
|
const displayTrackPlayingStatus: string = this.getDisplayTrackPlayingStatus(queue);
|
||||||
const displayQueueRepeatMode: string = this.getDisplayQueueRepeatMode(queue);
|
const displayQueueRepeatMode: string = this.getDisplayQueueRepeatMode(queue);
|
||||||
const displayEmbedProgressBar: string = this.getDisplayQueueProgressBar(queue);
|
const displayEmbedProgressBar: string = this.getDisplayQueueProgressBar(queue, translator);
|
||||||
|
|
||||||
const components: APIMessageActionRowComponent[] = [];
|
const components: APIMessageActionRowComponent[] = [];
|
||||||
|
|
||||||
@@ -82,7 +83,7 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
|
|||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedQueueAuthor(interaction, queue))
|
.setAuthor(this.getEmbedQueueAuthor(interaction, queue, translator))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`${displayTrackPlayingStatus}\n` +
|
`${displayTrackPlayingStatus}\n` +
|
||||||
`${displayTrackUrl}\n` +
|
`${displayTrackUrl}\n` +
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
|||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
import { localizeCommand } from '../../../common/localeUtil';
|
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||||
|
|
||||||
class PauseCommand extends BaseSlashCommandInteraction {
|
class PauseCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -16,6 +16,7 @@ class PauseCommand extends BaseSlashCommandInteraction {
|
|||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
@@ -36,9 +37,16 @@ class PauseCommand extends BaseSlashCommandInteraction {
|
|||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.pauseResumed} ${
|
translator(
|
||||||
queue.node.isPaused() ? 'Paused Track' : 'Resumed track'
|
queue.node.isPaused()
|
||||||
}**\n ${this.getDisplayTrackDurationAndUrl(currentTrack)}`
|
? 'commands.pause.pauseConfirmation'
|
||||||
|
: 'commands.pause.resumeConfirmation',
|
||||||
|
{
|
||||||
|
icon: this.embedOptions.icons.success
|
||||||
|
}
|
||||||
|
) +
|
||||||
|
'\n' +
|
||||||
|
this.getDisplayTrackDurationAndUrl(currentTrack, translator)
|
||||||
)
|
)
|
||||||
.setThumbnail(currentTrack.thumbnail)
|
.setThumbnail(currentTrack.thumbnail)
|
||||||
.setColor(this.embedOptions.colors.success)
|
.setColor(this.embedOptions.colors.success)
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ
|
|||||||
import { checkVoicePermissionJoinAndTalk } from '../../../utils/validation/permissionValidator';
|
import { checkVoicePermissionJoinAndTalk } from '../../../utils/validation/permissionValidator';
|
||||||
import { transformQuery } from '../../../utils/validation/searchQueryValidator';
|
import { transformQuery } from '../../../utils/validation/searchQueryValidator';
|
||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
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 {
|
class PlayCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -23,6 +25,7 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
|||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
await this.runValidators({ interaction, executionId }, [checkInVoiceChannel]);
|
await this.runValidators({ interaction, executionId }, [checkInVoiceChannel]);
|
||||||
|
|
||||||
@@ -39,14 +42,14 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
const searchResult = await this.searchTrack(player, transformedQuery, interaction, logger);
|
const searchResult = await this.searchTrack(player, transformedQuery, interaction, logger);
|
||||||
if (!searchResult || searchResult.tracks.length === 0) {
|
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)!;
|
queue = useQueue(interaction.guild!.id)!;
|
||||||
const queueSize = queue?.size ?? 0;
|
const queueSize = queue?.size ?? 0;
|
||||||
|
|
||||||
if ((searchResult.playlist! && searchResult.tracks.length) > this.playerOptions.maxQueueSize - queueSize) {
|
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(
|
const track: Track | void = await this.addResultsToPlayer(
|
||||||
@@ -63,7 +66,7 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
|||||||
throw new Error('Failed to add track to player.');
|
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(
|
private async searchTrack(
|
||||||
@@ -145,18 +148,39 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
|||||||
track: Track,
|
track: Track,
|
||||||
searchResult: SearchResult,
|
searchResult: SearchResult,
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
logger: Logger
|
logger: Logger,
|
||||||
|
translator: TFunction
|
||||||
): Promise<Message> {
|
): Promise<Message> {
|
||||||
logger.debug('Result found and added with player.play(), added to queue.');
|
logger.debug('Result found and added with player.play(), added to queue.');
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
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) {
|
if (searchResult.playlist) {
|
||||||
const otherTracksString = `And **${searchResult.tracks.length}** more tracks... **\`/queue\`** to view all.`;
|
message =
|
||||||
message = `${this.embedOptions.icons.success} **Added playlist to queue**\n${trackUrl}\n\n${otherTracksString}`;
|
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) {
|
} 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.');
|
logger.debug('Responding with success embed.');
|
||||||
@@ -174,7 +198,8 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
|||||||
private async handleNoResultsFound(
|
private async handleNoResultsFound(
|
||||||
transformedQuery: string,
|
transformedQuery: string,
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
logger: Logger
|
logger: Logger,
|
||||||
|
translator: TFunction
|
||||||
): Promise<Message> {
|
): Promise<Message> {
|
||||||
logger.debug(`No results found for query: '${transformedQuery}'`);
|
logger.debug(`No results found for query: '${transformedQuery}'`);
|
||||||
|
|
||||||
@@ -183,9 +208,10 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.warning} No track found**\n` +
|
translator('commands.play.trackNotFound', {
|
||||||
`No results found for **\`${transformedQuery}\`**.\n\n` +
|
icon: this.embedOptions.icons.warning,
|
||||||
'If you specified a URL, please make sure it is valid and public.'
|
query: transformedQuery
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.warning)
|
.setColor(this.embedOptions.colors.warning)
|
||||||
]
|
]
|
||||||
@@ -195,7 +221,8 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
|||||||
private async handlePlaylistTooLarge(
|
private async handlePlaylistTooLarge(
|
||||||
query: string,
|
query: string,
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
logger: Logger
|
logger: Logger,
|
||||||
|
translator: TFunction
|
||||||
): Promise<Message> {
|
): Promise<Message> {
|
||||||
logger.debug(`Playlist found but would exceed max queue size. Query: '${query}'.`);
|
logger.debug(`Playlist found but would exceed max queue size. Query: '${query}'.`);
|
||||||
|
|
||||||
@@ -204,9 +231,10 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.warning} Playlist too large**\n` +
|
translator('commands.play.playlistTooLarge', {
|
||||||
'This playlist is too large to be added to the queue.\n\n' +
|
icon: this.embedOptions.icons.warning,
|
||||||
`The maximum amount of tracks that can be added to the queue is **${this.playerOptions.maxQueueSize}**.`
|
count: this.playerOptions.maxQueueSize
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.warning)
|
.setColor(this.embedOptions.colors.warning)
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ
|
|||||||
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
import { formatDuration } from '../../../common/formattingUtils';
|
import { formatDuration } from '../../../common/formattingUtils';
|
||||||
import { localizeCommand } from '../../../common/localeUtil';
|
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||||
|
import { TFunction } from 'i18next';
|
||||||
|
|
||||||
class QueueCommand extends BaseSlashCommandInteraction {
|
class QueueCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -32,6 +33,7 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
|||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
@@ -48,14 +50,21 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
|||||||
return await this.handleInvalidPage(logger, interaction, pageIndex, totalPages);
|
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!;
|
const currentTrack: Track = queue.currentTrack!;
|
||||||
if (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(
|
private async handleCurrentTrack(
|
||||||
@@ -63,7 +72,8 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
|||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
queue: GuildQueue,
|
queue: GuildQueue,
|
||||||
currentTrack: Track,
|
currentTrack: Track,
|
||||||
queueTracksListString: string
|
queueTracksListString: string,
|
||||||
|
translator: TFunction
|
||||||
) {
|
) {
|
||||||
logger.debug('Queue exists with current track, gathering information.');
|
logger.debug('Queue exists with current track, gathering information.');
|
||||||
|
|
||||||
@@ -92,9 +102,11 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
|||||||
components.push(skipButton);
|
components.push(skipButton);
|
||||||
|
|
||||||
if (this.embedOptions.components.showButtonLabels) {
|
if (this.embedOptions.components.showButtonLabels) {
|
||||||
previousButton.label = 'Previous';
|
previousButton.label = translator('musicPlayerCommon.controls.previous');
|
||||||
playPauseButton.label = queue.node.isPaused() ? 'Resume' : 'Pause';
|
playPauseButton.label = queue.node.isPaused()
|
||||||
skipButton.label = 'Skip';
|
? translator('musicPlayerCommon.controls.resume')
|
||||||
|
: translator('musicPlayerCommon.controls.pause');
|
||||||
|
skipButton.label = translator('musicPlayerCommon.controls.skip');
|
||||||
}
|
}
|
||||||
|
|
||||||
const embedActionRow: APIActionRowComponent<APIMessageActionRowComponent> = {
|
const embedActionRow: APIActionRowComponent<APIMessageActionRowComponent> = {
|
||||||
@@ -106,18 +118,29 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
|||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedQueueAuthor(interaction, queue))
|
.setAuthor(this.getEmbedQueueAuthor(interaction, queue, translator))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.audioPlaying} Now playing**\n` +
|
translator('musicPlayerCommon.nowPlayingTitle', {
|
||||||
`${this.getFormattedTrackUrl(currentTrack)}\n` +
|
icon: this.embedOptions.icons.audioPlaying
|
||||||
`**Requested by:** ${this.getDisplayTrackRequestedBy(currentTrack)}\n` +
|
}) +
|
||||||
`${this.getDisplayQueueProgressBar(queue)}\n\n` +
|
this.getFormattedTrackUrl(currentTrack, translator) +
|
||||||
`${this.getDisplayRepeatMode(queue.repeatMode)}` +
|
'\n' +
|
||||||
`**${this.embedOptions.icons.queue} Tracks in queue**\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
|
queueTracksListString
|
||||||
)
|
)
|
||||||
.setThumbnail(this.getTrackThumbnailUrl(currentTrack))
|
.setThumbnail(this.getTrackThumbnailUrl(currentTrack))
|
||||||
.setFooter(this.getDisplayFullFooterInfo(interaction, queue))
|
.setFooter(this.getDisplayFullFooterInfo(interaction, queue, translator))
|
||||||
.setColor(this.embedOptions.colors.info)
|
.setColor(this.embedOptions.colors.info)
|
||||||
],
|
],
|
||||||
components: [embedActionRow]
|
components: [embedActionRow]
|
||||||
@@ -129,7 +152,8 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
|||||||
logger: Logger,
|
logger: Logger,
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
queue: GuildQueue,
|
queue: GuildQueue,
|
||||||
queueTracksListString: string
|
queueTracksListString: string,
|
||||||
|
translator: TFunction
|
||||||
) {
|
) {
|
||||||
logger.debug('Queue exists but there is no current track.');
|
logger.debug('Queue exists but there is no current track.');
|
||||||
|
|
||||||
@@ -137,13 +161,13 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
|||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedQueueAuthor(interaction, queue))
|
.setAuthor(this.getEmbedQueueAuthor(interaction, queue, translator))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`${this.getDisplayRepeatMode(queue.repeatMode)}` +
|
`${this.getDisplayRepeatMode(queue.repeatMode, translator)}` +
|
||||||
`**${this.embedOptions.icons.queue} Tracks in queue**\n` +
|
`**${this.embedOptions.icons.queue} Tracks in queue**\n` +
|
||||||
queueTracksListString
|
queueTracksListString
|
||||||
)
|
)
|
||||||
.setFooter(this.getDisplayFullFooterInfo(interaction, queue))
|
.setFooter(this.getDisplayFullFooterInfo(interaction, queue, translator))
|
||||||
.setColor(this.embedOptions.colors.info)
|
.setColor(this.embedOptions.colors.info)
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -180,7 +204,7 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
|||||||
return Math.ceil(queue.tracks.data.length / 10) || 1;
|
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) {
|
if (!queue || queue.tracks.data.length === 0) {
|
||||||
return 'The queue is empty, add some tracks with **`/play`**!';
|
return 'The queue is empty, add some tracks with **`/play`**!';
|
||||||
}
|
}
|
||||||
@@ -188,7 +212,7 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
|||||||
return queue.tracks.data
|
return queue.tracks.data
|
||||||
.slice(pageIndex * 10, pageIndex * 10 + 10)
|
.slice(pageIndex * 10, pageIndex * 10 + 10)
|
||||||
.map((track, index) => {
|
.map((track, index) => {
|
||||||
return `**${pageIndex * 10 + index + 1}.** ${this.getDisplayTrackDurationAndUrl(track)}`;
|
return `**${pageIndex * 10 + index + 1}.** ${this.getDisplayTrackDurationAndUrl(track, translator)}`;
|
||||||
})
|
})
|
||||||
.join('\n');
|
.join('\n');
|
||||||
}
|
}
|
||||||
@@ -210,8 +234,12 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
|||||||
return `Estimated duration: ${formatDuration(queueDurationMs)}`;
|
return `Estimated duration: ${formatDuration(queueDurationMs)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getDisplayFullFooterInfo(interaction: ChatInputCommandInteraction, queue: GuildQueue): EmbedFooterData {
|
private getDisplayFullFooterInfo(
|
||||||
const pagination = this.getFooterDisplayPageInfo(interaction, queue);
|
interaction: ChatInputCommandInteraction,
|
||||||
|
queue: GuildQueue,
|
||||||
|
translator: TFunction
|
||||||
|
): EmbedFooterData {
|
||||||
|
const pagination = this.getFooterDisplayPageInfo(interaction, queue, translator);
|
||||||
const totalDuration = this.getDisplayQueueTotalDuration(queue);
|
const totalDuration = this.getDisplayQueueTotalDuration(queue);
|
||||||
|
|
||||||
const fullFooterData = {
|
const fullFooterData = {
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ
|
|||||||
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
import { Logger } from 'pino';
|
import { Logger } from 'pino';
|
||||||
|
import { TFunction } from 'i18next';
|
||||||
|
import { useServerTranslator } from '../../../common/localeUtil';
|
||||||
|
import { formatSlashCommand } from '../../../common/formattingUtils';
|
||||||
|
|
||||||
class RemoveCommand extends BaseSlashCommandInteraction {
|
class RemoveCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -63,6 +66,7 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
|||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
@@ -76,21 +80,26 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
switch (subcommand) {
|
switch (subcommand) {
|
||||||
case 'track':
|
case 'track':
|
||||||
return await this.handleRemovedTrack(logger, interaction, queue);
|
return await this.handleRemovedTrack(logger, interaction, queue, translator);
|
||||||
case 'range':
|
case 'range':
|
||||||
return await this.handleRemoveRange(logger, interaction, queue);
|
return await this.handleRemoveRange(logger, interaction, queue, translator);
|
||||||
case 'queue':
|
case 'queue':
|
||||||
return await this.handleRemoveQueue(logger, interaction, queue);
|
return await this.handleRemoveQueue(logger, interaction, queue, translator);
|
||||||
case 'user':
|
case 'user':
|
||||||
return await this.handleRemoveUserTracks(logger, interaction, queue);
|
return await this.handleRemoveUserTracks(logger, interaction, queue, translator);
|
||||||
case 'duplicates':
|
case 'duplicates':
|
||||||
return await this.handleRemoveDuplicates(logger, interaction, queue);
|
return await this.handleRemoveDuplicates(logger, interaction, queue, translator);
|
||||||
default:
|
default:
|
||||||
return Promise.resolve();
|
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 targetUser = interaction.options.getUser('target')!;
|
||||||
const removedTracks: Track[] = [];
|
const removedTracks: Track[] = [];
|
||||||
queue.tracks.data.forEach((track) => {
|
queue.tracks.data.forEach((track) => {
|
||||||
@@ -103,15 +112,20 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (removedTracks.length === 0) {
|
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.`);
|
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 removedTracks: Track[] = [];
|
||||||
const uniqueTrackUrls = new Set<string>();
|
const uniqueTrackUrls = new Set<string>();
|
||||||
queue.tracks.data.forEach((track) => {
|
queue.tracks.data.forEach((track) => {
|
||||||
@@ -126,20 +140,25 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (removedTracks.length === 0) {
|
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.`);
|
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 start: number = interaction.options.getInteger('start')!;
|
||||||
const end: number = interaction.options.getInteger('end')!;
|
const end: number = interaction.options.getInteger('end')!;
|
||||||
|
|
||||||
if (start > queue.tracks.data.length || end > queue.tracks.data.length) {
|
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) {
|
} else if (start > end) {
|
||||||
logger.debug('Start position is higher than end position.');
|
logger.debug('Start position is higher than end position.');
|
||||||
|
|
||||||
@@ -148,9 +167,12 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
translator('commands.remove.startPositionHigherThanEndPosition', {
|
||||||
`Start position **\`${start}\`** is higher than end position **\`${end}\`**. Please specify a valid range.` +
|
icon: this.embedOptions.icons.warning,
|
||||||
'\n\nView tracks added to the queue with **`/queue`**.'
|
start,
|
||||||
|
end,
|
||||||
|
queueCommand: formatSlashCommand('queue', translator)
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.warning)
|
.setColor(this.embedOptions.colors.warning)
|
||||||
]
|
]
|
||||||
@@ -167,32 +189,48 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (removedTracks.length === 0) {
|
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.`);
|
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;
|
const queueLength = queue.tracks.data.length;
|
||||||
queue.clear();
|
queue.clear();
|
||||||
|
|
||||||
if (queueLength === 0) {
|
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.');
|
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')!;
|
const trackPositionInput: number = interaction.options.getInteger('position')!;
|
||||||
|
|
||||||
if (trackPositionInput > queue.tracks.data.length) {
|
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)!;
|
const removedTrack: Track = queue.node.remove(trackPositionInput - 1)!;
|
||||||
@@ -204,9 +242,11 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
|||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.success} Removed track**\n${this.getDisplayTrackDurationAndUrl(
|
translator('commands.remove.removedTrack', {
|
||||||
removedTrack
|
icon: this.embedOptions.icons.success
|
||||||
)}`
|
}) +
|
||||||
|
'\n' +
|
||||||
|
this.getDisplayTrackDurationAndUrl(removedTrack, translator)
|
||||||
)
|
)
|
||||||
.setThumbnail(this.getTrackThumbnailUrl(removedTrack))
|
.setThumbnail(this.getTrackThumbnailUrl(removedTrack))
|
||||||
.setColor(this.embedOptions.colors.success)
|
.setColor(this.embedOptions.colors.success)
|
||||||
@@ -215,15 +255,20 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
|||||||
return Promise.resolve();
|
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.');
|
logger.debug('Responding with warning embed.');
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.warning} No tracks removed**\n` +
|
translator('commands.remove.noTracksRemoved', {
|
||||||
'There were no tracks removed from the queue. Please check if the option you selected has tracks to remove.'
|
icon: this.embedOptions.icons.warning
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.warning)
|
.setColor(this.embedOptions.colors.warning)
|
||||||
]
|
]
|
||||||
@@ -234,7 +279,8 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
|||||||
private async handleResponseRemovedTracks(
|
private async handleResponseRemovedTracks(
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
removedAmount: number
|
removedAmount: number,
|
||||||
|
translator: TFunction
|
||||||
) {
|
) {
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
@@ -242,8 +288,10 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
|||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.success} Removed tracks**\n` +
|
translator('commands.remove.removedTracks', {
|
||||||
`**\`${removedAmount}\`** tracks were removed from the queue.`
|
icon: this.embedOptions.icons.success,
|
||||||
|
count: removedAmount
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.success)
|
.setColor(this.embedOptions.colors.success)
|
||||||
]
|
]
|
||||||
@@ -255,7 +303,8 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
|||||||
logger: Logger,
|
logger: Logger,
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
trackPositionInput: number,
|
trackPositionInput: number,
|
||||||
queue: GuildQueue
|
queue: GuildQueue,
|
||||||
|
translator: TFunction
|
||||||
) {
|
) {
|
||||||
logger.debug('Specified track position is higher than total tracks.');
|
logger.debug('Specified track position is higher than total tracks.');
|
||||||
|
|
||||||
@@ -264,9 +313,12 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
translator('commands.skip.trackPositionHigherThanQueueLength', {
|
||||||
`Position **\`${trackPositionInput}\`** is not a valid track position. There are only a total of **\`${queue.tracks.data.length}\`** tracks in the queue.` +
|
icon: this.embedOptions.icons.warning,
|
||||||
'\n\nView tracks added to the queue with **`/queue`**.'
|
position: trackPositionInput,
|
||||||
|
count: queue.tracks.data.length,
|
||||||
|
queueCommand: formatSlashCommand('queue', translator)
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.warning)
|
.setColor(this.embedOptions.colors.warning)
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ
|
|||||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
import { Logger } from 'pino';
|
import { Logger } from 'pino';
|
||||||
import { localizeCommand } from '../../../common/localeUtil';
|
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||||
|
import { TFunction } from 'i18next';
|
||||||
|
|
||||||
class SeekCommand extends BaseSlashCommandInteraction {
|
class SeekCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -20,6 +21,7 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
|||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
@@ -34,14 +36,20 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
|||||||
const formattedDurationString: string = this.parseDurationArray(durationInputSplit);
|
const formattedDurationString: string = this.parseDurationArray(durationInputSplit);
|
||||||
|
|
||||||
if (!this.validateDurationFormat(formattedDurationString)) {
|
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 currentTrackMaxDurationInMs: number = queue.currentTrack!.durationMS;
|
||||||
const inputDurationInMilliseconds: number = this.getDurationInputInMilliseconds(durationInputSplit);
|
const inputDurationInMilliseconds: number = this.getDurationInputInMilliseconds(durationInputSplit);
|
||||||
|
|
||||||
if (inputDurationInMilliseconds > currentTrackMaxDurationInMs - 1000) {
|
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(
|
return await this.seekToDurationInCurrentTrack(
|
||||||
@@ -49,14 +57,16 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
|||||||
interaction,
|
interaction,
|
||||||
queue,
|
queue,
|
||||||
inputDurationInMilliseconds,
|
inputDurationInMilliseconds,
|
||||||
formattedDurationString
|
formattedDurationString,
|
||||||
|
translator
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleInvalidDurationFormat(
|
private async handleInvalidDurationFormat(
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
formattedDurationString: string
|
formattedDurationString: string,
|
||||||
|
translator: TFunction
|
||||||
): Promise<Message> {
|
): Promise<Message> {
|
||||||
logger.debug('Invalid duration format input.');
|
logger.debug('Invalid duration format input.');
|
||||||
|
|
||||||
@@ -65,13 +75,10 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
translator('commands.seek.correctFormatInstruction', {
|
||||||
`You entered an invalid duration format, **\`${formattedDurationString}\`**.\n` +
|
icon: this.embedOptions.icons.warning,
|
||||||
'Please use the format **`HH:mm:ss`**, **`mm:ss`** or **`ss`**.\n\n' +
|
wrongDuration: formattedDurationString
|
||||||
'**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.'
|
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.warning)
|
.setColor(this.embedOptions.colors.warning)
|
||||||
]
|
]
|
||||||
@@ -83,7 +90,8 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
|||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
queue: GuildQueue,
|
queue: GuildQueue,
|
||||||
durationInMilliseconds: number,
|
durationInMilliseconds: number,
|
||||||
formattedDurationString: string
|
formattedDurationString: string,
|
||||||
|
translator: TFunction
|
||||||
): Promise<Message> {
|
): Promise<Message> {
|
||||||
queue.node.seek(durationInMilliseconds);
|
queue.node.seek(durationInMilliseconds);
|
||||||
logger.debug(`Seeked to '${formattedDurationString}' in current track.`);
|
logger.debug(`Seeked to '${formattedDurationString}' in current track.`);
|
||||||
@@ -94,8 +102,10 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
|||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(await this.getEmbedUserAuthor(interaction))
|
.setAuthor(await this.getEmbedUserAuthor(interaction))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.success} Seeking to duration**\n` +
|
translator('commands.seek.seekingToTimestamp', {
|
||||||
`Seeking to **\`${formattedDurationString}\`** in current track.`
|
icon: this.embedOptions.icons.success,
|
||||||
|
duration: formattedDurationString
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setThumbnail(this.getTrackThumbnailUrl(queue.currentTrack!))
|
.setThumbnail(this.getTrackThumbnailUrl(queue.currentTrack!))
|
||||||
.setColor(this.embedOptions.colors.success)
|
.setColor(this.embedOptions.colors.success)
|
||||||
@@ -107,7 +117,8 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
|||||||
logger: Logger,
|
logger: Logger,
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
formattedDurationString: string,
|
formattedDurationString: string,
|
||||||
queue: GuildQueue
|
queue: GuildQueue,
|
||||||
|
translator: TFunction
|
||||||
): Promise<Message> {
|
): Promise<Message> {
|
||||||
logger.debug('Duration specified is longer than the track duration.');
|
logger.debug('Duration specified is longer than the track duration.');
|
||||||
|
|
||||||
@@ -116,11 +127,11 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
translator('commands.seek.durationLongerThanTrackDuration', {
|
||||||
`You entered **\`${formattedDurationString}\`**, which is a duration that is longer than the duration for the current track.\n\n` +
|
icon: this.embedOptions.icons.warning,
|
||||||
`Please try a duration that is less than the duration of the track (**\`${
|
wrongDuration: formattedDurationString,
|
||||||
queue.currentTrack!.duration
|
trackDuration: queue.currentTrack!.duration
|
||||||
}\`**).`
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.warning)
|
.setColor(this.embedOptions.colors.warning)
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
|||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { checkQueueEmpty, checkQueueExists } from '../../../utils/validation/queueValidator';
|
import { checkQueueEmpty, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
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 {
|
class ShuffleCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -15,6 +16,7 @@ class ShuffleCommand extends BaseSlashCommandInteraction {
|
|||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
@@ -34,9 +36,11 @@ class ShuffleCommand extends BaseSlashCommandInteraction {
|
|||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.shuffled} Shuffled queue tracks**\n` +
|
translator('commands.shuffle.shuffledTracks', {
|
||||||
`The **${queue.tracks.data.length}** tracks in the queue has been shuffled.\n\n` +
|
icon: this.embedOptions.icons.shuffled,
|
||||||
'View the new queue order with **`/queue`**.'
|
count: queue.tracks.data.length,
|
||||||
|
queueCommand: formatSlashCommand('queue', translator)
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.success)
|
.setColor(this.embedOptions.colors.success)
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ
|
|||||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
import { Logger } from 'pino';
|
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 {
|
class SkipCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -20,6 +22,7 @@ class SkipCommand extends BaseSlashCommandInteraction {
|
|||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
@@ -33,9 +36,9 @@ class SkipCommand extends BaseSlashCommandInteraction {
|
|||||||
const trackPositionInput: number = interaction.options.getInteger('position')!;
|
const trackPositionInput: number = interaction.options.getInteger('position')!;
|
||||||
|
|
||||||
if (trackPositionInput) {
|
if (trackPositionInput) {
|
||||||
return await this.handleSkipToTrackPosition(logger, interaction, queue, trackPositionInput);
|
return await this.handleSkipToTrackPosition(logger, interaction, queue, trackPositionInput, translator);
|
||||||
} else {
|
} 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,
|
logger: Logger,
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
queue: GuildQueue,
|
queue: GuildQueue,
|
||||||
trackPosition: number
|
trackPosition: number,
|
||||||
|
translator: TFunction
|
||||||
) {
|
) {
|
||||||
if (trackPosition > queue.tracks.data.length) {
|
if (trackPosition > queue.tracks.data.length) {
|
||||||
return await this.handleTrackPositionHigherThanQueueLength(trackPosition, queue, logger, interaction);
|
return await this.handleTrackPositionHigherThanQueueLength(
|
||||||
|
trackPosition,
|
||||||
|
queue,
|
||||||
|
logger,
|
||||||
|
interaction,
|
||||||
|
translator
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
const skippedTrack: Track = queue.currentTrack!;
|
const skippedTrack: Track = queue.currentTrack!;
|
||||||
queue.node.skipTo(trackPosition - 1);
|
queue.node.skipTo(trackPosition - 1);
|
||||||
logger.debug('Skipped to specified track position.');
|
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,
|
trackPosition: number,
|
||||||
queue: GuildQueue,
|
queue: GuildQueue,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
interaction: ChatInputCommandInteraction
|
interaction: ChatInputCommandInteraction,
|
||||||
|
translator: TFunction
|
||||||
) {
|
) {
|
||||||
logger.debug('Specified track position was higher than total tracks.');
|
logger.debug('Specified track position was higher than total tracks.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
translator('commands.skip.trackPositionHigherThanQueueLength', {
|
||||||
`There are only **\`${queue.tracks.data.length}\`** tracks in the queue. You cannot skip to track **\`${trackPosition}\`**.\n\n` +
|
icon: this.embedOptions.icons.warning,
|
||||||
'View tracks added to the queue with **`/queue`**.'
|
position: trackPosition,
|
||||||
|
queueCommand: formatSlashCommand('queue', translator),
|
||||||
|
count: queue.tracks.data.length
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.warning)
|
.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) {
|
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!;
|
const skippedTrack: Track = queue.currentTrack!;
|
||||||
queue.node.skip();
|
queue.node.skip();
|
||||||
logger.debug('Skipped current track.');
|
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.');
|
logger.debug('No tracks in queue and no current track.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
translator('commands.skip.emptyQueue', {
|
||||||
'The queue is empty, add some tracks with **`/play`**!'
|
icon: this.embedOptions.icons.warning,
|
||||||
|
playCommand: formatSlashCommand('play', translator)
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.warning)
|
.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({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.skipped} Skipped track**\n` +
|
translator('commands.skip.skippedTrack', {
|
||||||
`${this.getDisplayTrackDurationAndUrl(skippedTrack)}`
|
icon: this.embedOptions.icons.skipped
|
||||||
|
}) +
|
||||||
|
'\n' +
|
||||||
|
this.getDisplayTrackDurationAndUrl(skippedTrack, translator)
|
||||||
)
|
)
|
||||||
.setThumbnail(this.getTrackThumbnailUrl(skippedTrack))
|
.setThumbnail(this.getTrackThumbnailUrl(skippedTrack))
|
||||||
.setColor(this.embedOptions.colors.success)
|
.setColor(this.embedOptions.colors.success)
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
|||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
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 {
|
class StopCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -15,6 +16,7 @@ class StopCommand extends BaseSlashCommandInteraction {
|
|||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
@@ -37,9 +39,10 @@ class StopCommand extends BaseSlashCommandInteraction {
|
|||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.success} Stopped playing**\n` +
|
translator('commands.stop.stoppedPlaying', {
|
||||||
'Stopped playing audio and cleared the track queue.\n\n' +
|
icon: this.embedOptions.icons.success,
|
||||||
'To play more music, use the **`/play`** command!'
|
playCommand: formatSlashCommand('play', translator)
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.success)
|
.setColor(this.embedOptions.colors.success)
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ
|
|||||||
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
import { Logger } from 'pino';
|
import { Logger } from 'pino';
|
||||||
import { localizeCommand } from '../../../common/localeUtil';
|
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||||
|
import { TFunction } from 'i18next';
|
||||||
|
|
||||||
class VolumeCommand extends BaseSlashCommandInteraction {
|
class VolumeCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -20,6 +21,7 @@ class VolumeCommand extends BaseSlashCommandInteraction {
|
|||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
@@ -32,15 +34,20 @@ class VolumeCommand extends BaseSlashCommandInteraction {
|
|||||||
const volume: number = interaction.options.getInteger('percentage')!;
|
const volume: number = interaction.options.getInteger('percentage')!;
|
||||||
|
|
||||||
if (!volume && volume !== 0) {
|
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) {
|
} else if (volume > 100 || volume < 0) {
|
||||||
return await this.handleInvalidVolumeInput(volume, logger, interaction);
|
return await this.handleInvalidVolumeInput(volume, logger, interaction, translator);
|
||||||
} else {
|
} 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;
|
const currentVolume: number = queue.node.volume;
|
||||||
logger.debug('No volume input was provided, showing current volume.');
|
logger.debug('No volume input was provided, showing current volume.');
|
||||||
|
|
||||||
@@ -52,15 +59,22 @@ class VolumeCommand extends BaseSlashCommandInteraction {
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${currentVolumeIcon} Playback volume**\n` +
|
translator('commands.volume.volumeInformation', {
|
||||||
`The playback volume is currently set to **\`${currentVolume}%\`**.`
|
icon: currentVolumeIcon,
|
||||||
|
volume: currentVolume
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.info)
|
.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('Volume specified was higher than 100% or lower than 0%.');
|
||||||
|
|
||||||
logger.debug('Responding with warning embed.');
|
logger.debug('Responding with warning embed.');
|
||||||
@@ -68,8 +82,10 @@ class VolumeCommand extends BaseSlashCommandInteraction {
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
translator('commands.volume.invalidVolumeRange', {
|
||||||
`You cannot set the volume to **\`${volume}%\`**, please pick a value betwen **\`1%\`** and **\`100%\`**.`
|
icon: this.embedOptions.icons.warning,
|
||||||
|
wrongVolume: volume
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.warning)
|
.setColor(this.embedOptions.colors.warning)
|
||||||
]
|
]
|
||||||
@@ -80,7 +96,8 @@ class VolumeCommand extends BaseSlashCommandInteraction {
|
|||||||
volume: number,
|
volume: number,
|
||||||
queue: GuildQueue,
|
queue: GuildQueue,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
interaction: ChatInputCommandInteraction
|
interaction: ChatInputCommandInteraction,
|
||||||
|
translator: TFunction
|
||||||
) {
|
) {
|
||||||
queue.node.setVolume(volume);
|
queue.node.setVolume(volume);
|
||||||
logger.debug(`Set volume to ${volume}%.`);
|
logger.debug(`Set volume to ${volume}%.`);
|
||||||
@@ -92,8 +109,9 @@ class VolumeCommand extends BaseSlashCommandInteraction {
|
|||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.volumeMuted} Audio muted**\n` +
|
translator('commands.volume.volumeMuted', {
|
||||||
`Playback audio has been muted, because volume was set to **\`${volume}%\`**.`
|
icon: this.embedOptions.icons.volumeMuted
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.success)
|
.setColor(this.embedOptions.colors.success)
|
||||||
]
|
]
|
||||||
@@ -106,8 +124,10 @@ class VolumeCommand extends BaseSlashCommandInteraction {
|
|||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.volumeChanged} Volume changed**\n` +
|
translator('commands.volume.volumeChanged', {
|
||||||
`Playback volume has been changed to **\`${volume}%\`**.`
|
icon: this.embedOptions.icons.volumeChanged,
|
||||||
|
volume
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.success)
|
.setColor(this.embedOptions.colors.success)
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
|||||||
import { ExtendedClient } from '../../../types/clientTypes';
|
import { ExtendedClient } from '../../../types/clientTypes';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { checkValidGuildId } from '../../../utils/validation/systemCommandValidator';
|
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 {
|
class GuildsCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -16,6 +17,7 @@ class GuildsCommand extends BaseSlashCommandInteraction {
|
|||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction, client } = params;
|
const { executionId, interaction, client } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
await this.runValidators({ interaction, executionId }, [checkValidGuildId]);
|
await this.runValidators({ interaction, executionId }, [checkValidGuildId]);
|
||||||
|
|
||||||
@@ -27,7 +29,12 @@ class GuildsCommand extends BaseSlashCommandInteraction {
|
|||||||
const guildListFormatted = this.formatGuildListAsString(shardGuilds);
|
const guildListFormatted = this.formatGuildListAsString(shardGuilds);
|
||||||
const totalMemberCount = this.calculateTotalMemberCount(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) {
|
if (embedDescription.length >= 4000) {
|
||||||
logger.debug('Embed description is too long, truncating.');
|
logger.debug('Embed description is too long, truncating.');
|
||||||
@@ -71,13 +78,23 @@ class GuildsCommand extends BaseSlashCommandInteraction {
|
|||||||
private buildEmbedDescription(
|
private buildEmbedDescription(
|
||||||
totalGuildCount: number,
|
totalGuildCount: number,
|
||||||
guildListFormattedString: string,
|
guildListFormattedString: string,
|
||||||
totalMemberCount: number
|
totalMemberCount: number,
|
||||||
|
translator: TFunction
|
||||||
): string {
|
): string {
|
||||||
const topGuildsString = totalGuildCount < 25 ? `Top ${totalGuildCount} guilds` : 'Top 25 guilds';
|
const guildCount = Math.max(totalGuildCount, 25);
|
||||||
return (
|
return (
|
||||||
`**${this.embedOptions.icons.bot} ${topGuildsString} by member count (${totalGuildCount} total)**\n` +
|
translator('commands.guilds.topGuildsByMemberCount', {
|
||||||
`${guildListFormattedString}\n\n` +
|
icon: this.embedOptions.icons.bot,
|
||||||
`**Total members:** **\`${totalMemberCount}\`**`
|
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 { ExtendedClient } from '../../../types/clientTypes';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { checkValidGuildId } from '../../../utils/validation/systemCommandValidator';
|
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 {
|
class ReloadCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -22,16 +23,17 @@ class ReloadCommand extends BaseSlashCommandInteraction {
|
|||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction, client } = params;
|
const { executionId, interaction, client } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
await this.runValidators({ interaction, executionId }, [checkValidGuildId]);
|
await this.runValidators({ interaction, executionId }, [checkValidGuildId]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.reloadInteractionsAcrossShards(logger, executionId, client!);
|
await this.reloadInteractionsAcrossShards(logger, executionId, client!);
|
||||||
} catch (error) {
|
} 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) {
|
private async reloadInteractionsAcrossShards(logger: Logger, executionId: string, client: ExtendedClient) {
|
||||||
@@ -49,7 +51,8 @@ class ReloadCommand extends BaseSlashCommandInteraction {
|
|||||||
logger: Logger,
|
logger: Logger,
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
executionId: string,
|
executionId: string,
|
||||||
error: Error | unknown
|
error: Error | unknown,
|
||||||
|
translator: TFunction
|
||||||
) {
|
) {
|
||||||
logger.error(error, 'Failed to reload interaction module across shards.');
|
logger.error(error, 'Failed to reload interaction module across shards.');
|
||||||
|
|
||||||
@@ -58,8 +61,9 @@ class ReloadCommand extends BaseSlashCommandInteraction {
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.error} Oops!**\n` +
|
translator('commands.reload.unableToReload', {
|
||||||
'_Hmm.._ It seems I am unable to reload interaction module across shards.'
|
icon: this.embedOptions.icons.error
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.error)
|
.setColor(this.embedOptions.colors.error)
|
||||||
.setFooter({ text: `Execution ID: ${executionId}` })
|
.setFooter({ text: `Execution ID: ${executionId}` })
|
||||||
@@ -70,10 +74,11 @@ class ReloadCommand extends BaseSlashCommandInteraction {
|
|||||||
private async respondWithSuccessEmbed(
|
private async respondWithSuccessEmbed(
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
client: ExtendedClient
|
client: ExtendedClient,
|
||||||
|
translator: TFunction
|
||||||
) {
|
) {
|
||||||
const commands = this.getCommands(client);
|
const commands = this.getCommands(client);
|
||||||
const embedDescription = this.buildEmbedDescription(commands);
|
const embedDescription = this.buildEmbedDescription(commands, translator);
|
||||||
|
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
@@ -102,8 +107,14 @@ class ReloadCommand extends BaseSlashCommandInteraction {
|
|||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildEmbedDescription(commands: string[] | undefined): string {
|
private buildEmbedDescription(commands: string[] | undefined, translator: TFunction): string {
|
||||||
return `**${this.embedOptions.icons.bot} Reloaded commands**\n` + commands?.join('\n');
|
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 { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
||||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation/queueValidator';
|
import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation/queueValidator';
|
||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||||
|
import { TFunction } from 'i18next';
|
||||||
|
import { useServerTranslator } from '../../common/localeUtil';
|
||||||
|
|
||||||
class ActionPauseResumeButton extends BaseComponentInteraction {
|
class ActionPauseResumeButton extends BaseComponentInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -13,6 +15,7 @@ class ActionPauseResumeButton extends BaseComponentInteraction {
|
|||||||
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
||||||
const { executionId, interaction, referenceId } = params;
|
const { executionId, interaction, referenceId } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
@@ -41,7 +44,7 @@ class ActionPauseResumeButton extends BaseComponentInteraction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await this.handleSuccess(interaction, currentTrack, queue);
|
return await this.handleSuccess(interaction, currentTrack, queue, translator);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleNoQueue(interaction: MessageComponentInteraction) {
|
private async handleNoQueue(interaction: MessageComponentInteraction) {
|
||||||
@@ -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()
|
const successEmbed = new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.pauseResumed} ${
|
`**${this.embedOptions.icons.pauseResumed} ${
|
||||||
queue.node.isPaused() ? 'Paused Track' : 'Resumed track'
|
queue.node.isPaused() ? 'Paused Track' : 'Resumed track'
|
||||||
}**\n ${this.getDisplayTrackDurationAndUrl(queue.currentTrack!)}\n\n` +
|
}**\n ${this.getDisplayTrackDurationAndUrl(queue.currentTrack!, translator)}\n\n` +
|
||||||
`${this.getDisplayRepeatMode(queue.repeatMode, 'success')}`
|
`${this.getDisplayRepeatMode(queue.repeatMode, translator, 'success')}`
|
||||||
)
|
)
|
||||||
.setThumbnail(track.thumbnail)
|
.setThumbnail(track.thumbnail)
|
||||||
.setColor(this.embedOptions.colors.success);
|
.setColor(this.embedOptions.colors.success);
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import { BaseComponentParams, BaseComponentReturnType } from '../../types/intera
|
|||||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation/queueValidator';
|
import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation/queueValidator';
|
||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||||
import { Logger } from 'pino';
|
import { Logger } from 'pino';
|
||||||
|
import { TFunction } from 'i18next';
|
||||||
|
import { useServerTranslator } from '../../common/localeUtil';
|
||||||
|
import { formatSlashCommand } from '../../common/formattingUtils';
|
||||||
|
|
||||||
class ActionPreviousButton extends BaseComponentInteraction {
|
class ActionPreviousButton extends BaseComponentInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -14,6 +17,7 @@ class ActionPreviousButton extends BaseComponentInteraction {
|
|||||||
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
||||||
const { executionId, interaction, referenceId } = params;
|
const { executionId, interaction, referenceId } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
const history: GuildQueueHistory = useHistory(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.handleAlreadySkipped(interaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
return await this.handleBackToPreviousTrack(logger, interaction, history);
|
return await this.handleBackToPreviousTrack(logger, interaction, history, translator);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleBackToPreviousTrack(
|
private async handleBackToPreviousTrack(
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
interaction: MessageComponentInteraction,
|
interaction: MessageComponentInteraction,
|
||||||
history: GuildQueueHistory
|
history: GuildQueueHistory,
|
||||||
|
translator: TFunction
|
||||||
) {
|
) {
|
||||||
if (history.tracks.data.length === 0) {
|
if (history.tracks.data.length === 0) {
|
||||||
return await this.handleNoTracksInHistory(logger, interaction);
|
return await this.handleNoTracksInHistory(logger, interaction, translator);
|
||||||
}
|
}
|
||||||
|
|
||||||
await history.back();
|
await history.back();
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
const currentTrack: Track = queue.currentTrack!;
|
const currentTrack: Track = queue.currentTrack!;
|
||||||
logger.debug('Recovered track from history.');
|
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.');
|
logger.debug('No tracks in history.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
translator('commands.back.trackHistoryEmpty', {
|
||||||
'The history is empty, add some tracks with **`/play`**!'
|
icon: this.embedOptions.icons.warning,
|
||||||
|
playCommand: formatSlashCommand('play', translator)
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.warning)
|
.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()
|
const successEmbed = new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.back} Recovered track**\n` +
|
`**${this.embedOptions.icons.back} Recovered track**\n` +
|
||||||
`${this.getDisplayTrackDurationAndUrl(recoveredTrack)}`
|
`${this.getDisplayTrackDurationAndUrl(recoveredTrack, translator)}`
|
||||||
)
|
)
|
||||||
.setThumbnail(recoveredTrack.thumbnail)
|
.setThumbnail(recoveredTrack.thumbnail)
|
||||||
.setColor(this.embedOptions.colors.success);
|
.setColor(this.embedOptions.colors.success);
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import { BaseComponentInteraction } from '../../classes/interactions';
|
|||||||
import { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
import { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
||||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation/queueValidator';
|
import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation/queueValidator';
|
||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||||
|
import { TFunction } from 'i18next';
|
||||||
|
import { useServerTranslator } from '../../common/localeUtil';
|
||||||
|
|
||||||
class ActionSkipButton extends BaseComponentInteraction {
|
class ActionSkipButton extends BaseComponentInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -13,6 +15,7 @@ class ActionSkipButton extends BaseComponentInteraction {
|
|||||||
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
||||||
const { executionId, interaction, referenceId } = params;
|
const { executionId, interaction, referenceId } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
@@ -36,7 +39,7 @@ class ActionSkipButton extends BaseComponentInteraction {
|
|||||||
logger.debug('Skipped the track.');
|
logger.debug('Skipped the track.');
|
||||||
|
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await this.handleSuccess(interaction, skippedTrack, queue);
|
return await this.handleSuccess(interaction, skippedTrack, queue, translator);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleNoQueue(interaction: MessageComponentInteraction) {
|
private async handleNoQueue(interaction: MessageComponentInteraction) {
|
||||||
@@ -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()
|
const successEmbed = new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.skipped} Skipped track**\n` +
|
`**${this.embedOptions.icons.skipped} Skipped track**\n` +
|
||||||
`${this.getDisplayTrackDurationAndUrl(skippedTrack)}\n\n` +
|
`${this.getDisplayTrackDurationAndUrl(skippedTrack, translator)}\n\n` +
|
||||||
`${this.getDisplayRepeatMode(queue.repeatMode, 'success')}`
|
`${this.getDisplayRepeatMode(queue.repeatMode, translator, 'success')}`
|
||||||
)
|
)
|
||||||
.setThumbnail(skippedTrack.thumbnail)
|
.setThumbnail(skippedTrack.thumbnail)
|
||||||
.setColor(this.embedOptions.colors.success);
|
.setColor(this.embedOptions.colors.success);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { BaseComponentInteraction } from '../../classes/interactions';
|
|||||||
import { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
import { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
||||||
import { checkQueueExists } from '../../utils/validation/queueValidator';
|
import { checkQueueExists } from '../../utils/validation/queueValidator';
|
||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||||
|
import { useServerTranslator } from '../../common/localeUtil';
|
||||||
|
|
||||||
class FiltersDisableButtonComponent extends BaseComponentInteraction {
|
class FiltersDisableButtonComponent extends BaseComponentInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -14,6 +15,7 @@ class FiltersDisableButtonComponent extends BaseComponentInteraction {
|
|||||||
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
@@ -31,8 +33,9 @@ class FiltersDisableButtonComponent extends BaseComponentInteraction {
|
|||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.success} Disabled filters**\n` +
|
translator('commands.filters.allFiltersDisabled', {
|
||||||
'All audio filters have been disabled.'
|
icon: this.embedOptions.icons.success
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.success)
|
.setColor(this.embedOptions.colors.success)
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import {
|
|||||||
import { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
import { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
||||||
import { checkQueueExists } from '../../utils/validation/queueValidator';
|
import { checkQueueExists } from '../../utils/validation/queueValidator';
|
||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||||
|
import { useServerTranslator } from '../../common/localeUtil';
|
||||||
|
import { TFunction } from 'i18next';
|
||||||
|
|
||||||
const ffmpegFilterOptions: FFmpegFilterOptions = config.get('ffmpegFilterOptions');
|
const ffmpegFilterOptions: FFmpegFilterOptions = config.get('ffmpegFilterOptions');
|
||||||
const biquadFilterOptions: BiquadFilterOptions = config.get('biquadFilterOptions');
|
const biquadFilterOptions: BiquadFilterOptions = config.get('biquadFilterOptions');
|
||||||
@@ -25,6 +27,7 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
|||||||
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
||||||
const { executionId, interaction, referenceId } = params;
|
const { executionId, interaction, referenceId } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
const filterType = referenceId;
|
const filterType = referenceId;
|
||||||
|
|
||||||
logger.debug('Received select menu interaction.');
|
logger.debug('Received select menu interaction.');
|
||||||
@@ -41,16 +44,34 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
|||||||
this.resetFilters(queue, logger);
|
this.resetFilters(queue, logger);
|
||||||
|
|
||||||
if (selectMenuInteraction.values.length === 0) {
|
if (selectMenuInteraction.values.length === 0) {
|
||||||
return await this.replyWithDisabledFiltersEmbed(logger, selectMenuInteraction);
|
return await this.replyWithDisabledFiltersEmbed(logger, selectMenuInteraction, translator);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (filterType) {
|
switch (filterType) {
|
||||||
case 'ffmpeg':
|
case 'ffmpeg':
|
||||||
return await this.handleFfmpegFilterToggle(logger, selectMenuInteraction, queue, filterType);
|
return await this.handleFfmpegFilterToggle(
|
||||||
|
logger,
|
||||||
|
selectMenuInteraction,
|
||||||
|
queue,
|
||||||
|
filterType,
|
||||||
|
translator
|
||||||
|
);
|
||||||
case 'biquad':
|
case 'biquad':
|
||||||
return await this.handleBiquadFilterToggle(logger, selectMenuInteraction, queue, filterType);
|
return await this.handleBiquadFilterToggle(
|
||||||
|
logger,
|
||||||
|
selectMenuInteraction,
|
||||||
|
queue,
|
||||||
|
filterType,
|
||||||
|
translator
|
||||||
|
);
|
||||||
case 'equalizer':
|
case 'equalizer':
|
||||||
return await this.handleEqualizerFilterToggle(logger, selectMenuInteraction, queue, filterType);
|
return await this.handleEqualizerFilterToggle(
|
||||||
|
logger,
|
||||||
|
selectMenuInteraction,
|
||||||
|
queue,
|
||||||
|
filterType,
|
||||||
|
translator
|
||||||
|
);
|
||||||
default:
|
default:
|
||||||
logger.warn(`Unknown filter type '${filterType}'.`);
|
logger.warn(`Unknown filter type '${filterType}'.`);
|
||||||
return;
|
return;
|
||||||
@@ -61,37 +82,40 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
|||||||
logger: Logger,
|
logger: Logger,
|
||||||
selectMenuInteraction: StringSelectMenuInteraction,
|
selectMenuInteraction: StringSelectMenuInteraction,
|
||||||
queue: GuildQueue,
|
queue: GuildQueue,
|
||||||
filterType: string
|
filterType: string,
|
||||||
|
translator: TFunction
|
||||||
): Promise<Message> {
|
): Promise<Message> {
|
||||||
this.addFfmpegNormalizerIfRequired(selectMenuInteraction);
|
this.addFfmpegNormalizerIfRequired(selectMenuInteraction);
|
||||||
this.toggleFfmpegFilters(selectMenuInteraction, queue, logger);
|
this.toggleFfmpegFilters(selectMenuInteraction, queue, logger);
|
||||||
|
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await this.sendFiltersToggledSuccessEmbed(logger, selectMenuInteraction, filterType);
|
return await this.sendFiltersToggledSuccessEmbed(logger, selectMenuInteraction, filterType, translator);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleBiquadFilterToggle(
|
private async handleBiquadFilterToggle(
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
selectMenuInteraction: StringSelectMenuInteraction,
|
selectMenuInteraction: StringSelectMenuInteraction,
|
||||||
queue: GuildQueue,
|
queue: GuildQueue,
|
||||||
filterType: string
|
filterType: string,
|
||||||
|
translator: TFunction
|
||||||
): Promise<Message> {
|
): Promise<Message> {
|
||||||
this.toggleBiquadFilter(selectMenuInteraction, queue, logger);
|
this.toggleBiquadFilter(selectMenuInteraction, queue, logger);
|
||||||
|
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await this.sendFiltersToggledSuccessEmbed(logger, selectMenuInteraction, filterType);
|
return await this.sendFiltersToggledSuccessEmbed(logger, selectMenuInteraction, filterType, translator);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleEqualizerFilterToggle(
|
private async handleEqualizerFilterToggle(
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
selectMenuInteraction: StringSelectMenuInteraction,
|
selectMenuInteraction: StringSelectMenuInteraction,
|
||||||
queue: GuildQueue,
|
queue: GuildQueue,
|
||||||
filterType: string
|
filterType: string,
|
||||||
|
translator: TFunction
|
||||||
): Promise<Message> {
|
): Promise<Message> {
|
||||||
this.toggleEqualizerFilter(selectMenuInteraction, queue, logger);
|
this.toggleEqualizerFilter(selectMenuInteraction, queue, logger);
|
||||||
|
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await this.sendFiltersToggledSuccessEmbed(logger, selectMenuInteraction, filterType);
|
return await this.sendFiltersToggledSuccessEmbed(logger, selectMenuInteraction, filterType, translator);
|
||||||
}
|
}
|
||||||
|
|
||||||
private toggleFfmpegFilters(
|
private toggleFfmpegFilters(
|
||||||
@@ -172,25 +196,33 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
|||||||
private sendFiltersToggledSuccessEmbed(
|
private sendFiltersToggledSuccessEmbed(
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
interaction: StringSelectMenuInteraction,
|
interaction: StringSelectMenuInteraction,
|
||||||
filterType: string
|
filterType: string,
|
||||||
|
translator: TFunction
|
||||||
): Promise<Message> {
|
): Promise<Message> {
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return interaction.editReply({
|
return interaction.editReply({
|
||||||
embeds: [this.buildSuccessEmbed(interaction, filterType)],
|
embeds: [this.buildSuccessEmbed(interaction, filterType, translator)],
|
||||||
components: []
|
components: []
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildSuccessEmbed(selectMenuInteraction: StringSelectMenuInteraction, filterType: string): EmbedBuilder {
|
private buildSuccessEmbed(
|
||||||
|
selectMenuInteraction: StringSelectMenuInteraction,
|
||||||
|
filterType: string,
|
||||||
|
translator: TFunction
|
||||||
|
): EmbedBuilder {
|
||||||
const availableFilters: FilterOption[] = this.getAvailableFilters(filterType);
|
const availableFilters: FilterOption[] = this.getAvailableFilters(filterType);
|
||||||
const enabledFilters: string = this.getEnabledFilters(selectMenuInteraction, availableFilters);
|
const enabledFilters: string = this.getEnabledFilters(selectMenuInteraction, availableFilters);
|
||||||
|
|
||||||
return new EmbedBuilder()
|
return new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedUserAuthor(selectMenuInteraction))
|
.setAuthor(this.getEmbedUserAuthor(selectMenuInteraction))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.success} Filters toggled**\n` +
|
translator('commands.filters.nowUsingFilters', {
|
||||||
`Now using these ${filterType} filters:\n` +
|
icon: this.embedOptions.icons.success,
|
||||||
`${enabledFilters}`
|
mode: filterType
|
||||||
|
}) +
|
||||||
|
'\n' +
|
||||||
|
enabledFilters
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.success);
|
.setColor(this.embedOptions.colors.success);
|
||||||
}
|
}
|
||||||
@@ -243,7 +275,8 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
|||||||
|
|
||||||
private async replyWithDisabledFiltersEmbed(
|
private async replyWithDisabledFiltersEmbed(
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
interaction: StringSelectMenuInteraction
|
interaction: StringSelectMenuInteraction,
|
||||||
|
translator: TFunction
|
||||||
): Promise<Message> {
|
): Promise<Message> {
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
@@ -251,8 +284,9 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
|||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.success} Disabled filters**\n` +
|
translator('commands.filters.allFiltersDisabled', {
|
||||||
'All audio filters have been disabled.'
|
icon: this.embedOptions.icons.success
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.success)
|
.setColor(this.embedOptions.colors.success)
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { InteractionValidationError } from '../../classes/interactions';
|
|||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { EmbedOptions } from '../../types/configTypes';
|
import { EmbedOptions } from '../../types/configTypes';
|
||||||
import { ValidatorParams } from '../../types/utilTypes';
|
import { ValidatorParams } from '../../types/utilTypes';
|
||||||
|
import { useServerTranslator } from '../../common/localeUtil';
|
||||||
|
|
||||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||||
export const checkVoicePermissionJoinAndTalk = async ({ interaction, executionId }: ValidatorParams) => {
|
export const checkVoicePermissionJoinAndTalk = async ({ interaction, executionId }: ValidatorParams) => {
|
||||||
@@ -23,6 +24,7 @@ export const checkVoicePermissionJoinAndTalk = async ({ interaction, executionId
|
|||||||
shardId: interaction.guild?.shardId,
|
shardId: interaction.guild?.shardId,
|
||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const channel: VoiceBasedChannel | null =
|
const channel: VoiceBasedChannel | null =
|
||||||
interaction.member instanceof GuildMember ? interaction.member.voice.channel : null;
|
interaction.member instanceof GuildMember ? interaction.member.voice.channel : null;
|
||||||
@@ -34,7 +36,10 @@ export const checkVoicePermissionJoinAndTalk = async ({ interaction, executionId
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.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)
|
.setColor(embedOptions.colors.warning)
|
||||||
.setFooter({
|
.setFooter({
|
||||||
@@ -64,6 +69,7 @@ export const checkChannelPermissionViewable = async ({ interaction, executionId
|
|||||||
shardId: interaction.guild?.shardId,
|
shardId: interaction.guild?.shardId,
|
||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const channel: TextBasedChannel | null = interaction.channel;
|
const channel: TextBasedChannel | null = interaction.channel;
|
||||||
|
|
||||||
@@ -89,7 +95,10 @@ export const checkChannelPermissionViewable = async ({ interaction, executionId
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.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)
|
.setColor(embedOptions.colors.warning)
|
||||||
.setFooter({
|
.setFooter({
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import { InteractionValidationError } from '../../classes/interactions';
|
|||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { EmbedOptions } from '../../types/configTypes';
|
import { EmbedOptions } from '../../types/configTypes';
|
||||||
import { ValidatorParams } from '../../types/utilTypes';
|
import { ValidatorParams } from '../../types/utilTypes';
|
||||||
|
import { useServerTranslator } from '../../common/localeUtil';
|
||||||
|
import { formatSlashCommand } from '../../common/formattingUtils';
|
||||||
|
|
||||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||||
export const checkQueueExists = async ({ interaction, queue, executionId }: ValidatorParams) => {
|
export const checkQueueExists = async ({ interaction, queue, executionId }: ValidatorParams) => {
|
||||||
@@ -15,6 +17,7 @@ export const checkQueueExists = async ({ interaction, queue, executionId }: Vali
|
|||||||
shardId: interaction.guild?.shardId,
|
shardId: interaction.guild?.shardId,
|
||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const interactionIdentifier =
|
const interactionIdentifier =
|
||||||
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||||
@@ -24,7 +27,10 @@ export const checkQueueExists = async ({ interaction, queue, executionId }: Vali
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.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)
|
.setColor(embedOptions.colors.warning)
|
||||||
.setFooter({
|
.setFooter({
|
||||||
@@ -52,6 +58,7 @@ export const checkHistoryExists = async ({ interaction, history, executionId }:
|
|||||||
shardId: interaction.guild?.shardId,
|
shardId: interaction.guild?.shardId,
|
||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const interactionIdentifier =
|
const interactionIdentifier =
|
||||||
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||||
@@ -61,7 +68,10 @@ export const checkHistoryExists = async ({ interaction, history, executionId }:
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.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)
|
.setColor(embedOptions.colors.warning)
|
||||||
.setFooter({
|
.setFooter({
|
||||||
@@ -89,6 +99,7 @@ export const checkQueueCurrentTrack = async ({ interaction, queue, executionId }
|
|||||||
shardId: interaction.guild?.shardId,
|
shardId: interaction.guild?.shardId,
|
||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const interactionIdentifier =
|
const interactionIdentifier =
|
||||||
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||||
@@ -98,7 +109,10 @@ export const checkQueueCurrentTrack = async ({ interaction, queue, executionId }
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.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)
|
.setColor(embedOptions.colors.warning)
|
||||||
.setFooter({
|
.setFooter({
|
||||||
@@ -126,6 +140,7 @@ export const checkQueueEmpty = async ({ interaction, queue, executionId }: Valid
|
|||||||
shardId: interaction.guild?.shardId,
|
shardId: interaction.guild?.shardId,
|
||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const interactionIdentifier =
|
const interactionIdentifier =
|
||||||
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||||
@@ -135,7 +150,10 @@ export const checkQueueEmpty = async ({ interaction, queue, executionId }: Valid
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.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)
|
.setColor(embedOptions.colors.warning)
|
||||||
.setFooter({
|
.setFooter({
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import { InteractionValidationError } from '../../classes/interactions';
|
|||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { EmbedOptions, SystemOptions } from '../../types/configTypes';
|
import { EmbedOptions, SystemOptions } from '../../types/configTypes';
|
||||||
import { ValidatorParams } from '../../types/utilTypes';
|
import { ValidatorParams } from '../../types/utilTypes';
|
||||||
|
import { useServerTranslator } from '../../common/localeUtil';
|
||||||
|
import { formatSlashCommand } from '../../common/formattingUtils';
|
||||||
|
|
||||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||||
const systemOptions: SystemOptions = config.get('systemOptions');
|
const systemOptions: SystemOptions = config.get('systemOptions');
|
||||||
@@ -16,6 +18,7 @@ export const checkValidGuildId = async ({ interaction, executionId }: ValidatorP
|
|||||||
shardId: interaction.guild?.shardId,
|
shardId: interaction.guild?.shardId,
|
||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const interactionIdentifier =
|
const interactionIdentifier =
|
||||||
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||||
@@ -25,7 +28,10 @@ export const checkValidGuildId = async ({ interaction, executionId }: ValidatorP
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.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)
|
.setColor(embedOptions.colors.warning)
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { InteractionValidationError } from '../../classes/interactions';
|
|||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { EmbedOptions } from '../../types/configTypes';
|
import { EmbedOptions } from '../../types/configTypes';
|
||||||
import { ValidatorParams } from '../../types/utilTypes';
|
import { ValidatorParams } from '../../types/utilTypes';
|
||||||
|
import { useServerTranslator } from '../../common/localeUtil';
|
||||||
|
|
||||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||||
export const checkInVoiceChannel = async ({ interaction, executionId }: ValidatorParams) => {
|
export const checkInVoiceChannel = async ({ interaction, executionId }: ValidatorParams) => {
|
||||||
@@ -15,6 +16,7 @@ export const checkInVoiceChannel = async ({ interaction, executionId }: Validato
|
|||||||
shardId: interaction.guild?.shardId,
|
shardId: interaction.guild?.shardId,
|
||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const interactionIdentifier =
|
const interactionIdentifier =
|
||||||
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||||
@@ -24,7 +26,9 @@ export const checkInVoiceChannel = async ({ interaction, executionId }: Validato
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.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)
|
.setColor(embedOptions.colors.warning)
|
||||||
.setFooter({
|
.setFooter({
|
||||||
@@ -49,6 +53,7 @@ export const checkSameVoiceChannel = async ({ interaction, queue, executionId }:
|
|||||||
shardId: interaction.guild?.shardId,
|
shardId: interaction.guild?.shardId,
|
||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const interactionIdentifier =
|
const interactionIdentifier =
|
||||||
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||||
@@ -66,7 +71,10 @@ export const checkSameVoiceChannel = async ({ interaction, queue, executionId }:
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.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)
|
.setColor(embedOptions.colors.warning)
|
||||||
.setFooter({
|
.setFooter({
|
||||||
|
|||||||
Reference in new issue
Block a user