getting TypeError: source must an AudioSource not str #6930
Unanswered
Vivekananda-Mullangi
asked this question in
Q&A
Replies: 2 comments 3 replies
-
Please provide a full traceback including the line number where the error occurred. Also, please use code blocks, so the code is easier to read: |
Beta Was this translation helpful? Give feedback.
1 reply
-
error traceback:
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
hi github, I was writing code for music bot it ran ok until I decided to add a queue to it. now it plays one time then stops saying TypeError: source must an AudioSource not str
code:
`import discord
import youtube_dl
from discord.ext import commands
import urllib
import re
import pafy
from discord import FFmpegPCMAudio, PCMVolumeTransformer
client = commands.Bot(command_prefix=["!", "/", ">", "."])
FFMPEG_OPTIONS = {
'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5',
'options': '-vn'
}
song_queue = []
@client.event
async def on_ready():
print("Bot is ready")
@client.command()
async def join(ctx):
if not ctx.message.author.voice:
await ctx.send(":x:You have to be in a voice channel to use this command")
return
else:
channel = ctx.message.author.voice.channel
await channel.connect()
await ctx.send("Connected to the channel. it is time to rock🤘")
@client.command()
async def leave(ctx):
voice_client = ctx.message.guild.voice_client
try:
await voice_client.disconnect()
await ctx.send("Party over disconnecting from voice channel")
except:
await ctx.send(":x:I am not connected to a voice channel. Type
!join
to get me into one.")@client.command()
async def play(ctx, *args):
if ctx.message.author.voice == None:
await ctx.send(":x:You have to be in a voice channel to use this command")
return
def next(ctx):
voice_client = discord.utils.get(client.voice_clients, guild=ctx.guild)
song_queue.pop(0)
source = str(song_queue[0])
voice_client.play(source, after= lambda e: next(ctx))
voice_client.is_playing()
@client.command()
async def queue(ctx, *args):
search = '+'.join(args)
client.run(TOKEN)
`
runs till play() then tries to use next then stops
what is the problem with this code
Beta Was this translation helpful? Give feedback.
All reactions