this is the error I've recieved when I tried to use /play (/pusti on my lang) command on Discord in order to play a song from YT:
2023-12-01 21:25:11 ERROR discord.ext.commands.bot Ignoring exception in command pusti Traceback (most recent call last): File "C:\Users\x\AppData\Roaming\Python\Python312\site-packages\discord\ext\commands\core.py", line 235, in wrapped ret = await coro(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\discord-bot\main.py", line 149, in pusti voice_channel = ctx.author.voice.channel ^^^^^^^^^^ AttributeError: 'str' object has no attribute 'author'
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "C:\Users\x\AppData\Roaming\Python\Python312\site-packages\discord\ext\commands\bot.py", line 1350, in invoke await ctx.command.invoke(ctx) File "C:\Users\x\AppData\Roaming\Python\Python312\site-packages\discord\ext\commands\core.py", line 1029, in invoke await injected(*ctx.args, **ctx.kwargs) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\x\AppData\Roaming\Python\Python312\site-packages\discord\ext\commands\core.py", line 244, in wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'author'
And this is the command I try to use on Discord:
@client.command(name = "pusti", aliases = ["p", "play", "playing"], help = "Pušta pesmu sa tvog linka. 🎵")
async def pusti(self, ctx, *args):
query = " ".join(args)
voice_channel = ctx.author.voice.channel
if voice_channel is None:
await ctx.send("➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖\nUđi prvo na neki voice kanal! 🎵\n➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖")
elif self.is_paused:
self.vc.resume()
else:
song = self.search_yt(query)
if type(song) == type(True):
await ctx.send("➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖\nTvoja pesma je sada u redu za čekanje. 🎵\n➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖")
self.music_queue.append([song, voice_channel])
if self.is_playing == False:
await self.play_music(ctx)
I've done everything the same as it is in course video, but somehow mine stuff does not work. Please help someone!