mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-01 14:38:48 +00:00
Add behavior option to enable/disable player start messages
This commit is contained in:
1 parent
99c3cd006f
commit
d91bf74991
5 files changed
+25
-3
No files matched your search
@@ -52,6 +52,7 @@ module.exports.presenceStatusOptions = {
|
||||
|
||||
// Configurations for visual embed messages.
|
||||
// Includes design elements like colors and custom emojis/symbols.
|
||||
// Also includes behavior options like button labels and player start messages.
|
||||
module.exports.embedOptions = {
|
||||
info: {
|
||||
fallbackThumbnailUrl:
|
||||
@@ -69,6 +70,9 @@ module.exports.embedOptions = {
|
||||
components: {
|
||||
showButtonLabels: true
|
||||
},
|
||||
behavior: {
|
||||
enablePlayerStartMessages: false,
|
||||
},
|
||||
icons: {
|
||||
logo: '🤖',
|
||||
beta: '`beta`',
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { ExtendedGuildQueuePlayerNode } from '../../types/eventTypes';
|
||||
import { EmbedOptions } from '../../types/configTypes';
|
||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||
import loggerModule from '../../services/logger';
|
||||
import { Track } from 'discord-player';
|
||||
import { Snowflake } from 'discord.js';
|
||||
import { Logger } from 'pino';
|
||||
import config from 'config';
|
||||
|
||||
// Emitted when the audio player finish playing a track.
|
||||
module.exports = {
|
||||
@@ -20,9 +22,7 @@ module.exports = {
|
||||
guildId: queue.metadata?.channel.guild.id
|
||||
});
|
||||
|
||||
logger.debug(
|
||||
`playerFinish event: Track [${track.url}] finished playing, deleting previous now-playing message.`
|
||||
);
|
||||
logger.debug(`playerFinish event: Track [${track.url}] finished playing.`);
|
||||
|
||||
const { lastMessage } = queue.metadata || {};
|
||||
const fetchLastAnnounceMessage =
|
||||
|
||||
@@ -27,6 +27,11 @@ module.exports = {
|
||||
const { channel, client } = queue.metadata || {};
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
|
||||
if (!embedOptions.behavior.enablePlayerStartMessages) {
|
||||
logger.debug('playerStart event: Player start messages are disabled, skipping now-playing message.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (channel && !client?.channels.cache.get(channel.id)) {
|
||||
logger.warn(
|
||||
`playerStart event: No channel found for guild ${queue.metadata?.channel.guild.id}, cannot send now-playing message.`
|
||||
|
||||
@@ -189,6 +189,16 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
||||
const posistionFirstTrackInPlaylist = queue.tracks.data.length - searchResult.tracks.length + 1;
|
||||
embedFooter = this.getDisplayFooterTrackPosition(posistionFirstTrackInPlaylist, translator);
|
||||
}
|
||||
} else if (queue.currentTrack === track && queue.tracks.data.length === 0) {
|
||||
if (!this.embedOptions.behavior.enablePlayerStartMessages) {
|
||||
message =
|
||||
translator('musicPlayerCommon.nowPlayingTitle', {
|
||||
icon: this.embedOptions.icons.audioStartedPlaying
|
||||
}) +
|
||||
'\n' +
|
||||
trackUrl;
|
||||
embedFooter = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
|
||||
Vendored
+3
@@ -43,6 +43,9 @@ export type EmbedOptions = {
|
||||
components: {
|
||||
showButtonLabels: boolean;
|
||||
};
|
||||
behavior: {
|
||||
enablePlayerStartMessages: boolean;
|
||||
};
|
||||
icons: {
|
||||
logo: string;
|
||||
beta: string;
|
||||
|
||||
Reference in new issue
Block a user