Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
feat: Add new config option to enable/disable button labels
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusbegby committed Dec 12, 2023
1 parent 82927c5 commit 47d3c36
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 10 deletions.
3 changes: 3 additions & 0 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ module.exports.embedOptions = {
info: '#5865F2',
note: '#80848E'
},
components: {
showButtonLabels: false
},
icons: {
logo: '🤖',
beta: '`beta`',
Expand Down
5 changes: 4 additions & 1 deletion src/interactions/commands/player/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,14 @@ class FiltersCommand extends BaseSlashCommandInteraction {

const disableButton: APIButtonComponent = new ButtonBuilder()
.setCustomId('filters-disable-button')
.setLabel('Disable all filters')
.setStyle(ButtonStyle.Secondary)
.setEmoji(this.embedOptions.icons.disable)
.toJSON();

if (this.embedOptions.components.showButtonLabels) {
disableButton.label = 'Disable all filters';
}

const disableFiltersActionRow: APIActionRowComponent<APIMessageActionRowComponent> = {
type: ComponentType.ActionRow,
components: [disableButton]
Expand Down
9 changes: 6 additions & 3 deletions src/interactions/commands/player/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,31 @@ class HistoryCommand extends BaseSlashCommandInteraction {
const previousButton: APIButtonComponent = new ButtonBuilder()
.setDisabled(queue.history.tracks.data.length > 0 ? false : true)
.setCustomId(`action-previous-button_${currentTrack.id}`)
.setLabel('Previous')
.setStyle(ButtonStyle.Secondary)
.setEmoji(this.embedOptions.icons.previousTrack)
.toJSON();
components.push(previousButton);

const playPauseButton: APIButtonComponent = new ButtonBuilder()
.setCustomId(`action-pauseresume-button_${currentTrack.id}`)
.setLabel(queue.node.isPaused() ? 'Resume' : 'Pause')
.setStyle(ButtonStyle.Secondary)
.setEmoji(this.embedOptions.icons.pauseResumeTrack)
.toJSON();
components.push(playPauseButton);

const skipButton: APIButtonComponent = new ButtonBuilder()
.setCustomId(`action-skip-button_${currentTrack.id}`)
.setLabel('Skip')
.setStyle(ButtonStyle.Secondary)
.setEmoji(this.embedOptions.icons.nextTrack)
.toJSON();
components.push(skipButton);

if (this.embedOptions.components.showButtonLabels) {
previousButton.label = 'Previous';
playPauseButton.label = queue.node.isPaused() ? 'Resume' : 'Pause';
skipButton.label = 'Skip';
}

const embedActionRow: APIActionRowComponent<APIMessageActionRowComponent> = {
type: ComponentType.ActionRow,
components
Expand Down
9 changes: 6 additions & 3 deletions src/interactions/commands/player/nowplaying.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,31 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
const previousButton: APIButtonComponent = new ButtonBuilder()
.setDisabled(queue.history.tracks.data.length > 0 ? false : true)
.setCustomId(`action-previous-button_${currentTrack.id}`)
.setLabel('Previous')
.setStyle(ButtonStyle.Secondary)
.setEmoji(this.embedOptions.icons.previousTrack)
.toJSON();
components.push(previousButton);

const playPauseButton: APIButtonComponent = new ButtonBuilder()
.setCustomId(`action-pauseresume-button_${currentTrack.id}`)
.setLabel(queue.node.isPaused() ? 'Resume' : 'Pause')
.setStyle(ButtonStyle.Secondary)
.setEmoji(this.embedOptions.icons.pauseResumeTrack)
.toJSON();
components.push(playPauseButton);

const skipButton: APIButtonComponent = new ButtonBuilder()
.setCustomId(`action-skip-button_${currentTrack.id}`)
.setLabel('Skip')
.setStyle(ButtonStyle.Secondary)
.setEmoji(this.embedOptions.icons.nextTrack)
.toJSON();
components.push(skipButton);

if (this.embedOptions.components.showButtonLabels) {
previousButton.label = 'Previous';
playPauseButton.label = queue.node.isPaused() ? 'Resume' : 'Pause';
skipButton.label = 'Skip';
}

const embedActionRow: APIActionRowComponent<APIMessageActionRowComponent> = {
type: ComponentType.ActionRow,
components
Expand Down
9 changes: 6 additions & 3 deletions src/interactions/commands/player/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,28 +72,31 @@ class QueueCommand extends BaseSlashCommandInteraction {
const previousButton: APIButtonComponent = new ButtonBuilder()
.setDisabled(queue.history.tracks.data.length > 0 ? false : true)
.setCustomId(`action-previous-button_${currentTrack.id}`)
.setLabel('Previous')
.setStyle(ButtonStyle.Secondary)
.setEmoji(this.embedOptions.icons.previousTrack)
.toJSON();
components.push(previousButton);

const playPauseButton: APIButtonComponent = new ButtonBuilder()
.setCustomId(`action-pauseresume-button_${currentTrack.id}`)
.setLabel(queue.node.isPaused() ? 'Resume' : 'Pause')
.setStyle(ButtonStyle.Secondary)
.setEmoji(this.embedOptions.icons.pauseResumeTrack)
.toJSON();
components.push(playPauseButton);

const skipButton: APIButtonComponent = new ButtonBuilder()
.setCustomId(`action-skip-button_${currentTrack.id}`)
.setLabel('Skip')
.setStyle(ButtonStyle.Secondary)
.setEmoji(this.embedOptions.icons.nextTrack)
.toJSON();
components.push(skipButton);

if (this.embedOptions.components.showButtonLabels) {
previousButton.label = 'Previous';
playPauseButton.label = queue.node.isPaused() ? 'Resume' : 'Pause';
skipButton.label = 'Skip';
}

const embedActionRow: APIActionRowComponent<APIMessageActionRowComponent> = {
type: ComponentType.ActionRow,
components
Expand Down
3 changes: 3 additions & 0 deletions src/types/configTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ export type EmbedOptions = {
info: ColorResolvable;
note: ColorResolvable;
};
components: {
showButtonLabels: boolean;
};
icons: {
logo: string;
beta: string;
Expand Down

0 comments on commit 47d3c36

Please sign in to comment.