How do I use client.send_file discord.py

霸气de小男生 提交于 2019-12-25 08:38:54

问题


@my_bot.command()
async def memes():
    await client.send_file(discord.Object(id='321332957690331138'),'1.jpg')

I used that and I got error code 401 aka Unauthorized

my_bot.run(TOKEN)

I'm using that to login All my other commands work and do not output this error. -I'm quite new to this website so I may have done something wrong-


回答1:


Your issue is that you need to pass a proper destination (channel in server) as the first parameter. To get the server object from a server ID you can use:

server = client.get_server('321332957690331138')

and to get the default channel of that server you can use:

server.default_channel

So to sum it up you now have:

await client.send_file(client.get_server('321332957690331138').default_channel, '1.jpg')

Hope I helped!



来源:https://stackoverflow.com/questions/44398114/how-do-i-use-client-send-file-discord-py

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!