mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-19 18:16:34 +01:00
All that bloat for nowt
This commit is contained in:
parent
61a475df6c
commit
2373a7b19c
2 changed files with 20 additions and 12 deletions
|
@ -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
|
||||
|
|
|
@ -60,16 +60,17 @@ class Bot(commands.Bot):
|
|||
if getattr(self, "web", None) is not None:
|
||||
self.console.log("Closing web server...")
|
||||
await self.web["server"].shutdown()
|
||||
self.web["task"].cancel()
|
||||
self.console.log("Web server closed.")
|
||||
try:
|
||||
await self.web["task"]
|
||||
except asyncio.CancelledError:
|
||||
pass
|
||||
del self.web["server"]
|
||||
del self.web["config"]
|
||||
del self.web["task"]
|
||||
del self.web
|
||||
if hasattr(self, "web"):
|
||||
self.web["task"].cancel()
|
||||
self.console.log("Web server closed.")
|
||||
try:
|
||||
await self.web["task"]
|
||||
except asyncio.CancelledError:
|
||||
pass
|
||||
del self.web["server"]
|
||||
del self.web["config"]
|
||||
del self.web["task"]
|
||||
del self.web
|
||||
try:
|
||||
await super().close()
|
||||
except asyncio.TimeoutError:
|
||||
|
|
Loading…
Reference in a new issue