Attribute Error: 'Aru' object has no attribute 'message' | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Attribute Error: 'Aru' object has no attribute 'message'

So I've been making my new discord bot... and everything works fine besides this command: https://code.sololearn.com/c1hUWCSc9U0D/#py Line 15 is this "bad" one... And I don't know how to resolve this...

18th Aug 2017, 7:30 PM
ArualKneza
ArualKneza - avatar
4 Answers
0
I've tried both await ctx.bot.delete_message(message) and await bot.delete_message(message) but it gives the other error: 'str' object has no attribute 'channel' What I guess is that I might have not imported something important to _init_ ... but I have no clue what I've forgot about and how should I do it... it's my first time working on classes like this... (well, this command worked when I had a bit more simple bot without Music class... but now as I had to put this command to class... (because without it bot doesn't even recognize it as a command))
19th Aug 2017, 2:41 PM
ArualKneza
ArualKneza - avatar
0
So... I forgot to add to the call "self". And yea, I should put "message" in front of "*args". I also had to delete 13 line >.< though... now it "eats" the first argument... and I don't know how to deal with it...
20th Aug 2017, 12:49 PM
ArualKneza
ArualKneza - avatar
- 2
in init you store bot into self.bot but at line 15 no "bot" exists, you shoud try ctx.bot, also there is no ctx.message, there is just message (await ctx.bot.delete_message(message) ) line 16 may have same problem
18th Aug 2017, 11:32 PM
Michal Pácal
Michal Pácal - avatar
- 2
Oh, I noticed it now, when checking the code again. Problem: you might have swapped arguments in function call. Shoudn't it be (ctx, message, *args) ? Why I think so: the error says that class string have no attribute channel, so it expects other class, also you act with args like it is an array of strings, so it would mach that way.
19th Aug 2017, 10:28 PM
Michal Pácal
Michal Pácal - avatar