Discord.py: message.channel not sending file to channel

Created on 19 Apr 2017  路  4Comments  路  Source: Rapptz/discord.py

@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.

invalid question

All 4 comments

It still throws the same error

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

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

working code

@client.command(pass_context = True)
async def butytho(ctxmessage):
   await client.send_file(ctx.message.channel, 'fibCEus.gifv')
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Yolotroll101 picture Yolotroll101  路  3Comments

superloach picture superloach  路  3Comments

tairabiteru picture tairabiteru  路  3Comments

Rimmy50 picture Rimmy50  路  3Comments

adhoc92 picture adhoc92  路  3Comments