Answer the question
In order to leave comments, you need to log in
How to play music using discord.py?
How to play music to a bot in a channel?
Here is my code:
import discord, re, asyncio, datetime
from time import *
from function import *
from discord.ext import commands
token, bot, p, tag = session()
bot.remove_command('help')
@bot.command(pass_context=True)
async def play(ctx):
if ctx.message.author.id == 666249181295542273 or ctx.message.author.id == 383958826245816321:
await ctx.message.author.voice.channel.connect(reconnect=True)
ctx.voice_client.play(source='test.mp3', after=None)
Answer the question
In order to leave comments, you need to log in
The problem is that you are passing the string 'test.mp3' and it expects an object of class discord.AudioSource or its descendants.
You can do this, but here you need ffmpeg installed and added to PATH
ctx.voice_client.play(discord.FFmpegPCMAudio(clip.audiopath), None)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question