Add shuffle listener to VoiceBot for enhanced voice state management
This commit is contained in:
parent
a811d870f3
commit
a51483f9da
1 changed files with 13 additions and 1 deletions
|
@ -28,6 +28,7 @@ class VoiceBot:
|
||||||
|
|
||||||
def init_events(self) -> None:
|
def init_events(self) -> None:
|
||||||
self.bot.add_listener(self.on_voice_state_update, "on_voice_state_update")
|
self.bot.add_listener(self.on_voice_state_update, "on_voice_state_update")
|
||||||
|
self.bot.add_listener(self.shuffle, "on_voice_state_update")
|
||||||
self.bot.add_listener(self.random_connect, "on_ready")
|
self.bot.add_listener(self.random_connect, "on_ready")
|
||||||
self.bot.add_application_command(
|
self.bot.add_application_command(
|
||||||
discord.SlashCommand(
|
discord.SlashCommand(
|
||||||
|
@ -145,6 +146,17 @@ class VoiceBot:
|
||||||
):
|
):
|
||||||
await self.connect_voice(after.channel)
|
await self.connect_voice(after.channel)
|
||||||
|
|
||||||
if self.shf and before.channel is None and random.random() < 5 / 100:
|
async def shuffle(
|
||||||
|
self,
|
||||||
|
member: discord.Member,
|
||||||
|
before: discord.VoiceState,
|
||||||
|
after: discord.VoiceState,
|
||||||
|
) -> None:
|
||||||
|
if (
|
||||||
|
self.shf
|
||||||
|
and before.channel is None
|
||||||
|
and member != self.bot.user
|
||||||
|
and random.random() < 5 / 100
|
||||||
|
):
|
||||||
logger.info(f"Voice shuffle from {member}")
|
logger.info(f"Voice shuffle from {member}")
|
||||||
await self.shf.try_shuffle(member.guild)
|
await self.shf.try_shuffle(member.guild)
|
||||||
|
|
Loading…
Add table
Reference in a new issue