Discord.py: image sending error

Created on 9 Jul 2017  路  7Comments  路  Source: Rapptz/discord.py

So basically i am trying to use Client.send_file(channel, 'pwned.gif')
and it spits out errors. i change "channel" to a channel name still spits out errors.

I am very new to this so sorry if this is a dumb question

invalid question

Most helpful comment

Please don't...
Join this and read the Channel Info and then ask your questions.

https://discordapp.com/invite/0SBTUU1wZTUzBx2q
It is a dedicated Discord Server for help on these sorts of issues. This is not the place.

All 7 comments

Can you post the error message here.

Please don't...
Join this and read the Channel Info and then ask your questions.

https://discordapp.com/invite/0SBTUU1wZTUzBx2q
It is a dedicated Discord Server for help on these sorts of issues. This is not the place.

Ignoring exception in command pwn
Traceback (most recent call last):
File "C:\Users*name\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\core.py", line 50, in wrapped
ret = yield from coro(
args, *kwargs)
File "C:\Users*name
\Desktop\programming wonders xddd\bots\CuteBot\bot.py", line 44, in pwn
await Client.say(member.mention + " Was PWNED by " + ctx.message.author.mention) and Client.send_file(channel, 'pwned.gif')
NameError: name 'channel' is not defined

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\Marcell\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\bot.py", line 846, in process_commands
yield from command.invoke(ctx)
File "C:\Users\Marcell\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\core.py", line 374, in invoke
yield from injected(ctx.args, *ctx.kwargs)
File "C:\Users\Marcell\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\core.py", line 54, in wrapped
raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'channel' is not defined

You haven't defined channel in this context, it has to be a channel object, which you can get through a number of methods, discord.utils.get(), or, if this is in a command of sorts, you can get it from the message that triggers it. (message.channel).

Also, have you defined client as commands.bot() or are you using both client=discord.Client() and bot=commands.bot()? If you are using the former, please do not do this. Just use bot=commands.bot(), bot inherits everything that client has- if client can do it, bot can do it.

it doesnt spit out any errors now but doesnt send a picture ;-;

Please post the entire line of code this is on. (Alternatively, post the entire bit of code to hastebin/github gist/ghostbin and put that here)

I'm betting you just didn't put an await in front of this- it's a coroutine, so it needs to be awaited.

omg i am retarded. I will use the discord api server from now on but thank you Vexs

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PicklesJars picture PicklesJars  路  3Comments

Nicba1010 picture Nicba1010  路  3Comments

danshat picture danshat  路  3Comments

j0hnmeow picture j0hnmeow  路  3Comments

ghost picture ghost  路  3Comments