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"
|
file = Path.cwd() / "assets" / "it-just-works.ogg"
|
||||||
if message.author.voice is not None and message.author.voice.channel is not None:
|
if message.author.voice is not None and message.author.voice.channel is not None:
|
||||||
voice: discord.VoiceClient = 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:
|
try:
|
||||||
await _dc(message.guild.voice_client)
|
await _dc(message.guild.voice_client)
|
||||||
except discord.HTTPException:
|
except discord.HTTPException:
|
||||||
pass
|
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:
|
if voice.channel != message.author.voice.channel:
|
||||||
|
console.log("moving")
|
||||||
await voice.move_to(message.author.voice.channel)
|
await voice.move_to(message.author.voice.channel)
|
||||||
|
|
||||||
if message.guild.me.voice.self_mute or message.guild.me.voice.mute:
|
if message.guild.me.voice.self_mute or message.guild.me.voice.mute:
|
||||||
await _dc(voice)
|
await _dc(voice)
|
||||||
|
console.log("disconnecting bad")
|
||||||
await message.channel.trigger_typing()
|
await message.channel.trigger_typing()
|
||||||
await message.reply("Unmute me >:(", file=discord.File(file))
|
await message.reply("Unmute me >:(", file=discord.File(file))
|
||||||
else:
|
else:
|
||||||
|
@ -258,7 +263,9 @@ class Events(commands.Cog):
|
||||||
if e is not None:
|
if e is not None:
|
||||||
console.log(f"Error playing audio: {e}")
|
console.log(f"Error playing audio: {e}")
|
||||||
|
|
||||||
|
console.log("sourcing")
|
||||||
src = discord.FFmpegPCMAudio(str(file.absolute()), stderr=subprocess.DEVNULL)
|
src = discord.FFmpegPCMAudio(str(file.absolute()), stderr=subprocess.DEVNULL)
|
||||||
|
console.log("Playing audio")
|
||||||
voice.play(
|
voice.play(
|
||||||
src,
|
src,
|
||||||
after=after
|
after=after
|
||||||
|
|
|
@ -60,16 +60,17 @@ class Bot(commands.Bot):
|
||||||
if getattr(self, "web", None) is not None:
|
if getattr(self, "web", None) is not None:
|
||||||
self.console.log("Closing web server...")
|
self.console.log("Closing web server...")
|
||||||
await self.web["server"].shutdown()
|
await self.web["server"].shutdown()
|
||||||
self.web["task"].cancel()
|
if hasattr(self, "web"):
|
||||||
self.console.log("Web server closed.")
|
self.web["task"].cancel()
|
||||||
try:
|
self.console.log("Web server closed.")
|
||||||
await self.web["task"]
|
try:
|
||||||
except asyncio.CancelledError:
|
await self.web["task"]
|
||||||
pass
|
except asyncio.CancelledError:
|
||||||
del self.web["server"]
|
pass
|
||||||
del self.web["config"]
|
del self.web["server"]
|
||||||
del self.web["task"]
|
del self.web["config"]
|
||||||
del self.web
|
del self.web["task"]
|
||||||
|
del self.web
|
||||||
try:
|
try:
|
||||||
await super().close()
|
await super().close()
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
|
|
Loading…
Reference in a new issue