'Discord.py music bot's play command throws a TypeError
import discord
from discord import Intents
from discord import guild
from discord import permissions
from discord import member
from discord.ext import commands
from discord.ext.commands.core import has_permissions
import DiscordUtils
from discord.user import User
intents = discord.Intents().all()
client=commands.Bot(command_prefix='-', intents = intents)
#['dislike_count']
@client.command()
async def join(ctx):
voiceTrue = ctx.author.voice
if voiceTrue is None:
return await ctx.send("You are not in a voice channel")
await ctx.author.voice.channel.connect()
await ctx.send('Joined your voice channel')
@client.command()
async def leave(ctx):
voiceTrue = ctx.author.voice
mevoiceTrue = ctx.guild.me.voice
if voiceTrue is None:
return await ctx.send('You are not in a voice channel')
if mevoiceTrue is None:
return await ctx.send('I already left')
await ctx.voice_client.disconnect()
await ctx.send('Left your voice channel')
@client.command()
async def play(ctx, *, url):
player = music.get_player(guild_id = ctx.guild.id)
if not player:
player = music.create_player(ctx, ffmpeg_error_betterfix=True)
if not ctx.voice_client.is_playing():
await player.queue(url, search=True)
song = await player.play()
await ctx.send(f'Started playing{song.name}')
else:
song = await player.queue(url, search=True)
await ctx.send(f'Added {song.name} to the queue')
I have tried the above code, and this TypeError keeps popping up whenever I use the play() command:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'NoneType' object is not subscriptable
I was following this YouTube tutorial by Glowstik, and it worked perfectly for him in the video. Any solutions?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
