diff options
| author | Andrew Mike <[email protected]> | 2024-03-03 16:43:56 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-03-03 15:43:56 -0600 |
| commit | ccd8793cc1d8c91423cd37926b51ca283e3a8c39 (patch) | |
| tree | c0b51ea752249504f822f9dac07e31d5a5a2a359 /src/services | |
| parent | 1d5729fd6c9f7dc5f2f9ca599fcdd8fdbe138c84 (diff) | |
| download | muse-ccd8793cc1d8c91423cd37926b51ca283e3a8c39.tar.xz muse-ccd8793cc1d8c91423cd37926b51ca283e3a8c39.zip | |
[RFC] Auto-announce when new song comes on (#914)
Co-authored-by: Andrew Mike <[email protected]>
Co-authored-by: Andrew Mike <[email protected]>
Diffstat (limited to 'src/services')
| -rw-r--r-- | src/services/player.ts | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/services/player.ts b/src/services/player.ts index c17a536..bfd29ad 100644 --- a/src/services/player.ts +++ b/src/services/player.ts @@ -19,6 +19,7 @@ import { import FileCacheProvider from './file-cache.js'; import debug from '../utils/debug.js'; import {getGuildSettings} from '../utils/get-guild-settings.js'; +import {buildPlayingMessageEmbed} from '../utils/build-embed.js'; export enum MediaSource { Youtube, @@ -64,7 +65,7 @@ export default class { public guildId: string; public loopCurrentSong = false; public loopCurrentQueue = false; - + private currentChannel: VoiceChannel | undefined; private queue: QueuedSong[] = []; private queuePosition = 0; private audioPlayer: AudioPlayer | null = null; @@ -102,6 +103,8 @@ export default class { oldNetworking?.off('stateChange', networkStateChangeHandler); newNetworking?.on('stateChange', networkStateChangeHandler); /* eslint-enable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call */ + + this.currentChannel = channel; }); } @@ -559,6 +562,14 @@ export default class { if (newState.status === AudioPlayerStatus.Idle && this.status === STATUS.PLAYING) { await this.forward(1); + // Auto announce the next song if configured to + const settings = await getGuildSettings(this.guildId); + const {autoAnnounceNextSong} = settings; + if (autoAnnounceNextSong && this.currentChannel) { + await this.currentChannel.send({ + embeds: this.getCurrent() ? [buildPlayingMessageEmbed(this)] : [], + }); + } } } |
