Rapptz / discord.py

An API wrapper for Discord written in Python.
http://discordpy.rtfd.org/en/latest
MIT License
14.93k stars 3.77k forks source link

message.channel not sending file to channel #537

Closed trevor229 closed 7 years ago

trevor229 commented 7 years ago

@client.command() #butytho async def butytho(message): await client.send_file(message.channel, 'fibCEus.gifv')

I'm trying to send the image in the same channel as the command was issued. I think the fix is obvious but I can't find it.

The error thrown is

raise MissingRequiredArgument('{0.name} is a required argument that is missing.'.format(param)) discord.ext.commands.errors.MissingRequiredArgument: message is a required argument that is missing.

trevor229 commented 7 years ago

It still throws the same error

NotSoSuper commented 7 years ago

sorry, I misread (was typing this while ingame), the file must the in the same dir you launched your script await client.send_file(message.channel, open('fibCEus.gifv', 'rb')) try that

Ikusaba-san commented 7 years ago

Your command is expecting a message parameter, which you most likely never gave.

If you want to get the original message, you have to make the command pass the original context. See this link for reference: http://discordpy.readthedocs.io/en/latest/faq.html#how-do-i-get-the-original-message

ButterCheezii commented 7 years ago

working code

@client.command(pass_context = True)
async def butytho(ctxmessage):
   await client.send_file(ctx.message.channel, 'fibCEus.gifv')