我正在尝试编写一个小机器人,它通过使用斜杠命令附加不和谐图像来完成上传图像的工作,但是我遇到了一个小问题,当我在不和谐中添加命令并使用附件,图片没有发布,不知道问题出在哪里
这对我不起作用
而且图片没有上传,我做错了什么
在命令提示符下它给我一个错误
我在 python 中的代码:
slash = SlashCommand(bot, sync_commands=True)
@slash.slash(
name="imgur", description="imgur",
options=[
create_option(
name="image",
description="Attach an Image",
required=True,
option_type=11, #Attachment
)
])
async def _imgur(ctx:SlashContext, image):
await ctx.defer()
with open("configuracion.json") as f:
config = json.load(f)
headers = {'Authorization': 'Bearer ' + config["token_imgur"],}
params = {
'layout': u'blog',
'title':f'Escribe un titulo',
'description':'Escribe una descripción',
'name':'Escribe algun nombre',
'image': base64.b64encode(open(f'{image}', 'rb').read())}
r = requests.post(f'https://api.imgur.com/3/image', headers=headers, data=params)
data = r.json()["data"]["link"]
id = r.json()["data"]["id"]
borrar = r.json()["data"]["deletehash"]
print(image)
await ctx.send(f"{image}\n\n{id}")
有人可以帮我吗?非常感谢!