galnir / Master-Bot

A Discord music bot and dashboard with slash commands, playlist support, Spotify, music quiz, saved playlists, lyrics, gifs and more
MIT License
464 stars 373 forks source link

Queue on Redis #724

Closed galnir closed 2 years ago

galnir commented 2 years ago

Tasks left to do:

How the queue works now: Instead of it being a property on Player, Player is a property on Queue - the queue creates and destroys players

Bacon-Fixation commented 2 years ago

Still testing solutions for

  • [ ] When starting the bot automatically make it continue playing the queue

Much Love -Bacon

Bacon-Fixation commented 2 years ago

When starting the bot automatically make it continue playing the queue

https://pastebin.com/DnMLujZh <- index.ts

If the bot is still in a voice channel after restart it will remake the button collector for the old embed and restart the song it was on when the bot was restarted, sorta a recovery feature (picks up where it left off)

this may be my misinterpretation of the comment :D, still had a blast

Much Love -Bacon

galnir commented 2 years ago

When starting the bot automatically make it continue playing the queue

https://pastebin.com/DnMLujZh <- index.ts

If the bot is still in a voice channel after restart it will remake the button collector for the old embed and restart the song it was on when the bot was restarted, sorta a recovery feature (picks up where it left off)

this may be my misinterpretation of the comment :D, still had a blast

Much Love -Bacon

I tweaked your changes a little bit. Consolidated the collector into a function in order to clean up the code. Casting the values in customVoiceStateUpdate obj to bigInt caused the bot to leave the VC after restart. It works now but needs some testing.

Bacon-Fixation commented 2 years ago

When I try to start a fresh queue after a restart, bot wouldn't connect to the voice channel but still trigger the embed but locked out buttons, /leave the redoing the play command would fix it

i moved queue.createPlayer() down 2 lines, and it seems to fix it

this was the same behavior found when a MOD uses the Right Click-> Disconnect to remove bot from voice channel, the channel_id is null and lavalink freaks, so i just ask it to leave....nicely :D HAHAH

Much Love -Bacon

galnir commented 2 years ago

@Bacon-Fixation Did I forget to add anything back except trivia?

Bacon-Fixation commented 2 years ago

Missing a player.setVolume() in play.ts - bot starts at 100 when starting a fresh queue

Don't believe there is a way to Loop a Song or Queue or to View a what's in the queue (/loop, /queue)

Missing Stage Channel Handler https://pastebin.com/VprZhhBM <- channelHandler.ts

was able to get it to work by adding manageStageChannel() into musicSongPlayMessage.ts plus a check if the bot is about to stream to an empty channel

@ApplyOptions({ name: 'musicSongPlayMessage' }) export class MusicSongPlayMessageListener extends Listener { public override async run(channel: TextChannel, track: Song): Promise { const { client } = container; const queue = client.music.queues.get(channel.guild.id); await manageStageChannel( channel.guild.me?.voice.channel!, channel.guild.me!, queue ); // Leave Voice Channel when attempting to stream to an empty channel if (channel.guild.me?.voice.channel?.members.size == 1) { await queue.leave(); return } await channel.send({ content: Now playing: ${track.title} }); } }



Much Love
-Bacon
galnir commented 2 years ago

Missing a player.setVolume() in play.ts - bot starts at 100 when starting a fresh queue

Don't believe there is a way to Loop a Song or Queue

Missing Stage Channel Handler https://pastebin.com/VprZhhBM <- channelHandler.ts

was able to get it to work by adding manageStageChannel() into musicSongPlayMessage.ts plus a check if the bot is about to stream to an empty channel

  • musicSongPlayMessage.ts
import { ApplyOptions } from '@sapphire/decorators';
import { container, Listener, ListenerOptions } from '@sapphire/framework';
import type { TextChannel } from 'discord.js';
import { manageStageChannel } from '../lib/utils/music/channelHandler';
import type { Song } from '../lib/utils/queue/Song';

@ApplyOptions<ListenerOptions>({
  name: 'musicSongPlayMessage'
})
export class MusicSongPlayMessageListener extends Listener {
  public override async run(channel: TextChannel, track: Song): Promise<void> {
    const { client } = container;
    const queue = client.music.queues.get(channel.guild.id);
    await manageStageChannel(
      channel.guild.me?.voice.channel!,
      channel.guild.me!,
      queue
    );
    // Leave Voice Channel when attempting to stream to an empty channel
    if (channel.guild.me?.voice.channel?.members.size == 1) {
      await queue.leave();
      return
    }
    await channel.send({ content: `Now playing: ${track.title}` });
  }
}

Much Love -Bacon

Can you open a PR with this change? I'm gonna merge this PR now