FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
YDL_OPTIONS = {'format':"bestaudio", 'noplaylist': True, 'default_search': 'auto', 'forceduration': True, 'quiet': True}
songs = asyncio.Queue()
play_next_song = asyncio.Event()
play_song_is_running = False
def loop():
asyncio.get_running_loop()
async def play_song():
url = await songs.get()
global play_song_is_running
global vc
play_song_is_running = True
if vc is None:
await voice_channel.connect()
else:
await vc.move_to(voice_channel)
vc.stop()
while True:
play_song.clear()
current = await songs.get()
current.start()
await play_next_song.wait()
voice_channel = ctx.author.voice.channel
with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
info = ydl.extract_info(url, download=False)
if 'entries' in info:
url2 = info['entries'][0]["formats"][0]
elif 'formats' in info:
url2 = info["formats"][0]
url = info["webpage_url"]
stream_url = url2["url"]
source = await discord.FFmpegOpusAudio.from_probe(stream_url, **FFMPEG_OPTIONS)
vc.play(source, after = loop)
@bot.command(name='play')
async def play(ctx, *, url: str):
run_play_song()
if ctx.author.voice is None:
embed = discord.Embed(title=f'подключись к каналу, ебло', color=discord.Color.red())
bot_msg = await ctx.send(embed=embed)
await asyncio.sleep(5)
await bot_msg.delete()
global play_song_is_running
if not play_song_is_running:
run_play_song()
await songs.put(url)
vc = ctx.voice_client
def run_play_song(err = None):
asyncio.get_event_loop().create_task(play_song())
FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
YDL_OPTIONS = {'format':"bestaudio", 'noplaylist': True, 'default_search': 'auto', 'forceduration': True, 'quiet': True}
songs = asyncio.Queue()
play_next_song = asyncio.Event()
play_song_is_running = False
def loop():
asyncio.get_running_loop()
async def play_song(ctx):
url = await songs.get()
global play_song_is_running
play_song_is_running = True
if ctx.voice_client is None:
await voice_channel.connect()
else:
await ctx.voice_client.move_to(voice_channel)
ctx.voice_client.stop()
while True:
play_song.clear()
current = await songs.get()
current.start()
await play_next_song.wait()
voice_channel = ctx.author.voice.channel
vc = ctx.voice_client
with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
info = ydl.extract_info(url, download=False)
if 'entries' in info:
url2 = info['entries'][0]["formats"][0]
elif 'formats' in info:
url2 = info["formats"][0]
url = info["webpage_url"]
stream_url = url2["url"]
source = await discord.FFmpegOpusAudio.from_probe(stream_url, **FFMPEG_OPTIONS)
vc.play(source, after = loop)
@bot.command(name='play')
async def play(ctx, *, url: str):
run_play_song()
if ctx.author.voice is None:
embed = discord.Embed(title=f'подключись к каналу, ебло', color=discord.Color.red())
bot_msg = await ctx.send(embed=embed)
await asyncio.sleep(5)
await bot_msg.delete()
global play_song_is_running
if not play_song_is_running:
run_play_song()
await songs.put(url)
def run_play_song(err = None):
asyncio.get_event_loop().create_task(play_song())
FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
YDL_OPTIONS = {'format':"bestaudio", 'noplaylist': True, 'default_search': 'auto', 'forceduration': True, 'quiet': True}
songs = asyncio.Queue()
play_next_song = asyncio.Event()
play_song_is_running = False
def loop():
asyncio.get_event_loop().create_task(play_song())
async def play_song():
url = await songs.get()
if ctx.voice_client is None:
await voice_channel.connect()
else:
await ctx.voice_client.move_to(voice_channel)
ctx.voice_client.stop()
while True:
global play_song_is_running
play_song_is_running = True
voice_channel = ctx.author.voice.channel
vc = ctx.voice_client
with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
info = ydl.extract_info(url, download=False)
if 'entries' in info:
url2 = info['entries'][0]["formats"][0]
elif 'formats' in info:
url2 = info["formats"][0]
url = info["webpage_url"]
stream_url = url2["url"]
source = await discord.FFmpegOpusAudio.from_probe(stream_url, **FFMPEG_OPTIONS)
vc.play(source, after = loop)
@bot.command(name='play')
async def play(ctx, *, url: str):
run_play_song()
if ctx.author.voice is None:
embed = discord.Embed(title=f'подключись к каналу, ебло', color=discord.Color.red())
bot_msg = await ctx.send(embed=embed)
await asyncio.sleep(5)
await bot_msg.delete()
global play_song_is_running
if not play_song_is_running:
run_play_song()
await songs.put(url)
def run_play_song(err = None):
asyncio.get_running_loop(play_song())
FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
YDL_OPTIONS = {'format':"bestaudio", 'noplaylist': True, 'default_search': 'auto', 'forceduration': True, 'quiet': True}
songs = asyncio.Queue()
play_next_song = asyncio.Event()
def get():
asyncio.get_running_loop(play_song())
async def play_song():
if ctx.voice_client is None:
await voice_channel.connect()
else:
await ctx.voice_client.move_to(voice_channel)
ctx.voice_client.stop()
while True:
play_next_song.clear()
current = await songs.get()
current.start()
await play_next_song.wait()
voice_channel = ctx.author.voice.channel
vc = ctx.voice_client
with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
info = ydl.extract_info(url, download=False)
if 'entries' in info:
url2 = info['entries'][0]["formats"][0]
elif 'formats' in info:
url2 = info["formats"][0]
url = info["webpage_url"]
stream_url = url2["url"]
source = await discord.FFmpegOpusAudio.from_probe(stream_url, **FFMPEG_OPTIONS)
vc.play(source, after = loop)
@bot.command(name='play')
async def play(ctx, *, url: str):
await get()
if ctx.author.voice is None:
embed = discord.Embed(title=f'подключись к каналу, ебло', color=discord.Color.red())
bot_msg = await ctx.send(embed=embed)
await asyncio.sleep(5)
await bot_msg.delete()
await songs.put(play_song)
def loop():
client.loop.create_task(play_song(ctx))
Ошибка:
Traceback (most recent call last):
File "/app/main.py", line 53, in play_song
await voice_channel.connect()
AttributeError: 'NoneType' object has no attribute 'connect'