diff --git a/Music-Bot.py b/Music-Bot.py index 12b4441..1680020 100644 --- a/Music-Bot.py +++ b/Music-Bot.py @@ -76,8 +76,9 @@ else: data = data["entries"][0] filename = data["url"] if stream else ytdl.prepare_filename(data) - return cls(discord.FFmpegPCMAudio(filename, **ffmpeg_options), data=data) - + #return cls(discord.FFmpegPCMAudio(filename, **ffmpeg_options), data=data) + return cls(discord.FFmpegOpusAudio(bitrate=128, codec=None, executable='ffmpeg', pipe=False, stderr=None, + before_options=None, options=ffmpeg_options), data=data) intents = discord.Intents.default() intents.message_content = True @@ -103,15 +104,15 @@ else: async def join(ctx: commands.Context): try: channel = ctx.author.voice.channel + if channel is None: + await ctx.send(f"{error}You are not in a voice-channel! Could not join...") + if ctx.voice_client is not None: + return await ctx.voice_client.move_to(channel) + + await ctx.respond(f"{success}Connected to `{channel.name}`") + await channel.connect() except Exception as err: print(err) - if channel is None: - await ctx.send(f"{error}You are not in a voice-channel! Could not join...") - if ctx.voice_client is not None: - return await ctx.voice_client.move_to(channel) - - await ctx.respond(f"{success}Connected to `{channel.name}`") - await channel.connect() @bot.slash_command(name="nowplaying", descriprion="Show details what the bot is currently playing") @@ -221,4 +222,9 @@ else: await ctx.send(embed=embed) - bot.run(args.token, bot=True, reconnect=True) + try: + bot.loop.run_until_complete(bot.start(token=args.token, reconnect=True)) + except KeyboardInterrupt: + bot.loop.run_until_complete(bot.close()) + finally: + bot.loop.close()