From 69fff97e3836a55569fe3c217ff7089b1fd9c73b Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Tue, 29 Aug 2023 20:32:26 +0200 Subject: [PATCH] fix: added configurable fallback icon url for use in embeds --- config/default.js | 4 +++- src/interactions/commands/player/leave.ts | 2 +- src/interactions/commands/player/loop.ts | 6 +++--- src/interactions/commands/player/nowplaying.ts | 2 +- src/interactions/commands/player/pause.ts | 2 +- src/interactions/commands/player/play.ts | 6 +++--- src/interactions/commands/player/queue.ts | 4 ++-- src/interactions/commands/player/remove.ts | 2 +- src/interactions/commands/player/seek.ts | 2 +- src/interactions/commands/player/shuffle.ts | 2 +- src/interactions/commands/player/skip.ts | 4 ++-- src/interactions/commands/player/stop.ts | 2 +- src/interactions/commands/player/volume.ts | 4 ++-- src/interactions/components/filters-disable-button.ts | 2 +- src/interactions/components/nowplaying-skip-button.ts | 2 +- src/types/configTypes.ts | 1 + 16 files changed, 25 insertions(+), 22 deletions(-) diff --git a/config/default.js b/config/default.js index ecb1573..3581998 100644 --- a/config/default.js +++ b/config/default.js @@ -54,7 +54,9 @@ module.exports.presenceStatusOptions = { module.exports.embedOptions = { info: { fallbackThumbnailUrl: - 'https://raw.githubusercontent.com/mariusbegby/cadence-discord-bot/main/assets/logo-rounded-128px.png' + 'https://raw.githubusercontent.com/mariusbegby/cadence-discord-bot/main/assets/logo-rounded-128px.png', + fallbackIconUrl: + 'https://raw.githubusercontent.com/mariusbegby/cadence-discord-bot/main/assets/discord-profile-icon.png' }, colors: { success: '#23A55A', diff --git a/src/interactions/commands/player/leave.ts b/src/interactions/commands/player/leave.ts index 0c5af31..000520c 100644 --- a/src/interactions/commands/player/leave.ts +++ b/src/interactions/commands/player/leave.ts @@ -61,7 +61,7 @@ const command: CustomSlashCommandInteraction = { new EmbedBuilder() .setAuthor({ name: authorName, - iconURL: interaction.user.avatarURL() || '' + iconURL: interaction.user.avatarURL() || embedOptions.info.fallbackIconUrl }) .setDescription( `**${embedOptions.icons.success} Leaving channel**\nCleared the track queue and left voice channel.\n\nTo play more music, use the **\`/play\`** command!` diff --git a/src/interactions/commands/player/loop.ts b/src/interactions/commands/player/loop.ts index 287200a..419aecd 100644 --- a/src/interactions/commands/player/loop.ts +++ b/src/interactions/commands/player/loop.ts @@ -139,7 +139,7 @@ const command: CustomSlashCommandInteraction = { new EmbedBuilder() .setAuthor({ name: authorName, - iconURL: interaction.user.avatarURL() || '' + iconURL: interaction.user.avatarURL() || embedOptions.info.fallbackIconUrl }) .setDescription( `**${embedOptions.icons.success} Loop mode disabled**\nChanging loop mode from **\`${currentModeUserString}\`** to **\`${modeUserString}\`**.\n\nThe ${currentModeUserString} will no longer play on repeat!` @@ -158,7 +158,7 @@ const command: CustomSlashCommandInteraction = { new EmbedBuilder() .setAuthor({ name: authorName, - iconURL: interaction.user.avatarURL() || '' + iconURL: interaction.user.avatarURL() || embedOptions.info.fallbackIconUrl }) .setDescription( `**${embedOptions.icons.autoplaying} Loop mode changed**\nChanging loop mode from **\`${currentModeUserString}\`** to **\`${modeUserString}\`**.\n\nWhen the queue is empty, similar tracks will start playing!` @@ -176,7 +176,7 @@ const command: CustomSlashCommandInteraction = { new EmbedBuilder() .setAuthor({ name: authorName, - iconURL: interaction.user.avatarURL() || '' + iconURL: interaction.user.avatarURL() || embedOptions.info.fallbackIconUrl }) .setDescription( `**${embedOptions.icons.looping} Loop mode changed**\nChanging loop mode from **\`${currentModeUserString}\`** to **\`${modeUserString}\`**.\n\nThe ${modeUserString} will now play on repeat!` diff --git a/src/interactions/commands/player/nowplaying.ts b/src/interactions/commands/player/nowplaying.ts index 1003e29..133cadd 100644 --- a/src/interactions/commands/player/nowplaying.ts +++ b/src/interactions/commands/player/nowplaying.ts @@ -138,7 +138,7 @@ const command: CustomSlashCommandInteraction = { new EmbedBuilder() .setAuthor({ name: `Channel: ${queue.channel!.name} (${queue.channel!.bitrate / 1000}kbps)`, - iconURL: interaction.guild!.iconURL() || '' + iconURL: interaction.guild!.iconURL() || embedOptions.info.fallbackIconUrl }) .setDescription( (queue.node.isPaused() diff --git a/src/interactions/commands/player/pause.ts b/src/interactions/commands/player/pause.ts index c850ca9..fcba520 100644 --- a/src/interactions/commands/player/pause.ts +++ b/src/interactions/commands/player/pause.ts @@ -72,7 +72,7 @@ const command: CustomSlashCommandInteraction = { new EmbedBuilder() .setAuthor({ name: authorName, - iconURL: interaction.user.avatarURL() || '' + iconURL: interaction.user.avatarURL() || embedOptions.info.fallbackIconUrl }) .setDescription( `**${embedOptions.icons.pauseResumed} ${ diff --git a/src/interactions/commands/player/play.ts b/src/interactions/commands/player/play.ts index dcb0176..dcd599a 100644 --- a/src/interactions/commands/player/play.ts +++ b/src/interactions/commands/player/play.ts @@ -269,7 +269,7 @@ const command: CustomSlashCommandInteraction = { new EmbedBuilder() .setAuthor({ name: authorName, - iconURL: interaction.user.avatarURL() || '' + iconURL: interaction.user.avatarURL() || embedOptions.info.fallbackIconUrl }) .setDescription( `**${embedOptions.icons.success} Added playlist to queue**\n**${durationFormat} [${ @@ -301,7 +301,7 @@ const command: CustomSlashCommandInteraction = { new EmbedBuilder() .setAuthor({ name: authorName, - iconURL: interaction.user.avatarURL() || '' + iconURL: interaction.user.avatarURL() || embedOptions.info.fallbackIconUrl }) .setDescription( `**${embedOptions.icons.audioStartedPlaying} Started playing**\n**${durationFormat} [${ @@ -330,7 +330,7 @@ const command: CustomSlashCommandInteraction = { new EmbedBuilder() .setAuthor({ name: authorName, - iconURL: interaction.user.avatarURL() || '' + iconURL: interaction.user.avatarURL() || embedOptions.info.fallbackIconUrl }) .setDescription( `${embedOptions.icons.success} **Added to queue**\n**${durationFormat} [${track.title}](${ diff --git a/src/interactions/commands/player/queue.ts b/src/interactions/commands/player/queue.ts index 672280d..4b34a0b 100644 --- a/src/interactions/commands/player/queue.ts +++ b/src/interactions/commands/player/queue.ts @@ -116,7 +116,7 @@ const command: CustomSlashCommandInteraction = { new EmbedBuilder() .setAuthor({ name: `Channel: ${queue.channel!.name} (${queue.channel!.bitrate / 1000}kbps)`, - iconURL: interaction.guild!.iconURL() || '' + iconURL: interaction.guild!.iconURL() || embedOptions.info.fallbackIconUrl }) .setDescription( `${repeatModeString}` + `**${embedOptions.icons.queue} Tracks in queue**\n${queueString}` @@ -153,7 +153,7 @@ const command: CustomSlashCommandInteraction = { new EmbedBuilder() .setAuthor({ name: `Channel: ${queue.channel!.name} (${queue.channel!.bitrate / 1000}kbps)`, - iconURL: interaction.guild!.iconURL() || '' + iconURL: interaction.guild!.iconURL() || embedOptions.info.fallbackIconUrl }) .setDescription( `**${embedOptions.icons.audioPlaying} Now playing**\n` + diff --git a/src/interactions/commands/player/remove.ts b/src/interactions/commands/player/remove.ts index 5bab22f..88c0e7d 100644 --- a/src/interactions/commands/player/remove.ts +++ b/src/interactions/commands/player/remove.ts @@ -92,7 +92,7 @@ const command: CustomSlashCommandInteraction = { new EmbedBuilder() .setAuthor({ name: authorName, - iconURL: interaction.user.avatarURL() || '' + iconURL: interaction.user.avatarURL() || embedOptions.info.fallbackIconUrl }) .setDescription( `**${embedOptions.icons.success} Removed track**\n**${durationFormat} [${removedTrack.title}](${ diff --git a/src/interactions/commands/player/seek.ts b/src/interactions/commands/player/seek.ts index 86270a1..c8cba98 100644 --- a/src/interactions/commands/player/seek.ts +++ b/src/interactions/commands/player/seek.ts @@ -173,7 +173,7 @@ const command: CustomSlashCommandInteraction = { new EmbedBuilder() .setAuthor({ name: authorName, - iconURL: interaction.user.avatarURL() || '' + iconURL: interaction.user.avatarURL() || embedOptions.info.fallbackIconUrl }) .setDescription( `**${embedOptions.icons.success} Seeking to duration**\nSeeking to **\`${durationString}\`** in current track.` diff --git a/src/interactions/commands/player/shuffle.ts b/src/interactions/commands/player/shuffle.ts index 56c0af7..878d1b8 100644 --- a/src/interactions/commands/player/shuffle.ts +++ b/src/interactions/commands/player/shuffle.ts @@ -60,7 +60,7 @@ const command: CustomSlashCommandInteraction = { new EmbedBuilder() .setAuthor({ name: authorName, - iconURL: interaction.user.avatarURL() || '' + iconURL: interaction.user.avatarURL() || embedOptions.info.fallbackIconUrl }) .setDescription( `**${embedOptions.icons.shuffled} Shuffled queue tracks**\nThe **${queue.tracks.data.length}** tracks in the queue has been shuffled.\n\nView the new queue order with **\`/queue\`**.` diff --git a/src/interactions/commands/player/skip.ts b/src/interactions/commands/player/skip.ts index 511f868..b970a60 100644 --- a/src/interactions/commands/player/skip.ts +++ b/src/interactions/commands/player/skip.ts @@ -92,7 +92,7 @@ const command: CustomSlashCommandInteraction = { new EmbedBuilder() .setAuthor({ name: authorName, - iconURL: interaction.user.avatarURL() || '' + iconURL: interaction.user.avatarURL() || embedOptions.info.fallbackIconUrl }) .setDescription( `**${embedOptions.icons.skipped} Skipped track**\n**${durationFormat} [${ @@ -156,7 +156,7 @@ const command: CustomSlashCommandInteraction = { new EmbedBuilder() .setAuthor({ name: authorName, - iconURL: interaction.user.avatarURL() || '' + iconURL: interaction.user.avatarURL() || embedOptions.info.fallbackIconUrl }) .setDescription( `**${embedOptions.icons.skipped} Skipped track**\n**${durationFormat} [${ diff --git a/src/interactions/commands/player/stop.ts b/src/interactions/commands/player/stop.ts index a797167..32aae07 100644 --- a/src/interactions/commands/player/stop.ts +++ b/src/interactions/commands/player/stop.ts @@ -63,7 +63,7 @@ const command: CustomSlashCommandInteraction = { new EmbedBuilder() .setAuthor({ name: authorName, - iconURL: interaction.user.avatarURL() || '' + iconURL: interaction.user.avatarURL() || embedOptions.info.fallbackIconUrl }) .setDescription( `**${embedOptions.icons.success} Stopped playing**\nStopped playing audio and cleared the track queue.\n\nTo play more music, use the **\`/play\`** command!` diff --git a/src/interactions/commands/player/volume.ts b/src/interactions/commands/player/volume.ts index 2ebb189..3a37432 100644 --- a/src/interactions/commands/player/volume.ts +++ b/src/interactions/commands/player/volume.ts @@ -100,7 +100,7 @@ const command: CustomSlashCommandInteraction = { new EmbedBuilder() .setAuthor({ name: authorName, - iconURL: interaction.user.avatarURL() || '' + iconURL: interaction.user.avatarURL() || embedOptions.info.fallbackIconUrl }) .setDescription( `**${embedOptions.icons.volumeMuted} Audio muted**\nPlayback audio has been muted, because volume was set to **\`${volume}%\`**.` @@ -116,7 +116,7 @@ const command: CustomSlashCommandInteraction = { new EmbedBuilder() .setAuthor({ name: authorName, - iconURL: interaction.user.avatarURL() || '' + iconURL: interaction.user.avatarURL() || embedOptions.info.fallbackIconUrl }) .setDescription( `**${embedOptions.icons.volumeChanged} Volume changed**\nPlayback volume has been changed to **\`${volume}%\`**.` diff --git a/src/interactions/components/filters-disable-button.ts b/src/interactions/components/filters-disable-button.ts index 8fa4520..191273c 100644 --- a/src/interactions/components/filters-disable-button.ts +++ b/src/interactions/components/filters-disable-button.ts @@ -56,7 +56,7 @@ const component: CustomComponentInteraction = { new EmbedBuilder() .setAuthor({ name: authorName, - iconURL: interaction.user.avatarURL() || '' + iconURL: interaction.user.avatarURL() || embedOptions.info.fallbackIconUrl }) .setDescription( `**${embedOptions.icons.success} Disabled filters**\nAll audio filters have been disabled.` diff --git a/src/interactions/components/nowplaying-skip-button.ts b/src/interactions/components/nowplaying-skip-button.ts index c18cf7d..935c353 100644 --- a/src/interactions/components/nowplaying-skip-button.ts +++ b/src/interactions/components/nowplaying-skip-button.ts @@ -104,7 +104,7 @@ const component: CustomComponentInteraction = { new EmbedBuilder() .setAuthor({ name: authorName, - iconURL: interaction.user.avatarURL() || '' + iconURL: interaction.user.avatarURL() || embedOptions.info.fallbackIconUrl }) .setDescription( `**${embedOptions.icons.skipped} Skipped track**\n**${durationFormat} [${skippedTrack.title}](${ diff --git a/src/types/configTypes.ts b/src/types/configTypes.ts index 491b10b..3fe9c17 100644 --- a/src/types/configTypes.ts +++ b/src/types/configTypes.ts @@ -33,6 +33,7 @@ export interface PresenceStatusOptions { export interface EmbedOptions { info: { fallbackThumbnailUrl: string; + fallbackIconUrl: string; }; colors: { success: ColorResolvable;