Ask Sawal

Discussion Forum
Notification Icon1
Write Answer Icon
Add Question Icon

Sen Anshita




Posted Questions



Wait...

Posted Answers



Answer


Open the Amazon Prime Video app or download it from your living room device's app store. Register your device by selecting "sign in and start watching" to enter your account information directly on your device or choose "register on the Amazon website" to get a 5–6 character code to enter in your account.


Answer is posted for the following question.

How to connect amazon prime to another device?

Answer


Perhaps GST was too complex a system for the Indian economy at its present stage of development Regardless, the Centre has to break heads


Answer is posted for the following question.

Why did gst fail in india?

Answer


Alan Beverley Cross (13 April 1931 – 20 March 1998) was an English playwright, librettist, and screenwriter Contents 1 Early life; 2 Career


Answer is posted for the following question.

How did beverley cross die?

Answer


  1. Open WhatsApp Web or WhatsApp Desktop.
  2. Click Menu ( or ) above your chats list > Log out.

Answer is posted for the following question.

How to sign out from whatsapp?

Answer


1
There were some changes to youtube_dl and FFmpeg, so this should work.
2
import discord
3
import youtube_dl
4
from discord.ext import commands
5
ydl_opts = {
6
    'format': 'bestaudio/best',
7
    'postprocessors': [{
8
        'key': 'FFmpegExtractAudio',
9
        'preferredcodec': 'mp3',
10
        'preferredquality': '192',
11
    }],
12
}   
13
def endSong(guild, path):
14
    os.remove(path)                                   
15
@cat.command(pass_context=True)
16
async def play(ctx, url):
17
    if not ctx.message.author.voice:
18
        await ctx.send('you are not connected to a voice channel')
19
        return
20
    else:
21
        channel = ctx.message.author.voice.channel
22
    voice_client = await channel.connect()
23
    guild = ctx.message.guild
24
    with youtube_dl.YoutubeDL(ydl_opts) as ydl:
25
        file = ydl.extract_info(url, download=True)
26
        path = str(file['title']) + - + str(file['id'] + .mp3)
27
    voice_client.play(discord.FFmpegPCMAudio(path), after=lambda x: endSong(guild, path))
28
    voice_client.source = discord.PCMVolumeTransformer(voice_client.source, 1)
29
    await ctx.send(f'**Music: **{url}')
30
Optional, useful function
31
If you want you can make your bot leave the voice channel after the song/music stop playing. Add this at the end of your code.
32
while voice_client.is_playing():
33
        await asyncio.sleep(1)
34
    else:
35
        await voice_client.disconnect()
36
        print(Disconnected)
37
If something wouldn't work
38
If you had any problem with understanding the code or something wouldn't work, comment under my answer and I'll try my best to help you. Btw if you are thinking about hosting your bot on Heroku I can help you with that, because there are some things you need to do to make your music bot run there.

Answer is posted for the following question.

How to python discord music bot (Python Programing Language)


Wait...