All that bloat for nowt

This commit is contained in:
nexy7574 2023-03-22 15:57:10 +00:00
parent 61a475df6c
commit 2373a7b19c
2 changed files with 20 additions and 12 deletions

View file

@ -234,18 +234,23 @@ class Events(commands.Cog):
file = Path.cwd() / "assets" / "it-just-works.ogg"
if message.author.voice is not None and message.author.voice.channel is not None:
voice: discord.VoiceClient = None
if message.guild.me.voice is not None:
if message.guild.voice_client is not None:
console.log("Disconnecting")
try:
await _dc(message.guild.voice_client)
except discord.HTTPException:
pass
voice = await message.author.voice.channel.connect()
console.log("connecting")
voice = await message.author.voice.channel.connect(timeout=10, reconnect=False)
console.log("connected")
if voice.channel != message.author.voice.channel:
console.log("moving")
await voice.move_to(message.author.voice.channel)
if message.guild.me.voice.self_mute or message.guild.me.voice.mute:
await _dc(voice)
console.log("disconnecting bad")
await message.channel.trigger_typing()
await message.reply("Unmute me >:(", file=discord.File(file))
else:
@ -258,7 +263,9 @@ class Events(commands.Cog):
if e is not None:
console.log(f"Error playing audio: {e}")
console.log("sourcing")
src = discord.FFmpegPCMAudio(str(file.absolute()), stderr=subprocess.DEVNULL)
console.log("Playing audio")
voice.play(
src,
after=after

View file

@ -60,6 +60,7 @@ class Bot(commands.Bot):
if getattr(self, "web", None) is not None:
self.console.log("Closing web server...")
await self.web["server"].shutdown()
if hasattr(self, "web"):
self.web["task"].cancel()
self.console.log("Web server closed.")
try: