我的代码如下:
@commands.command(name='crackhash', aliases = ['hashcrack'])
async def hashcracking(self, ctx, query):
url = "https://hashes.org/api.php?key=" + hashapi_key + ".&query=" + query
async with ClientSession() as session:
async with session.get(url) as response:
r = await response.json(content_type=None)
embed = discord.Embed(colour=discord.Colour.purple(), timestamp=ctx.message.created_at,
title=f"Hash Cracking")
member = ctx.message.author
embed.set_thumbnail(url=member.avatar_url)
embed.set_footer(text=f"Requested by {ctx.author}")
embed.add_field(name=f"Status", value={r['status']}, inline=False)
embed.add_field(name=f"{query}", value="Algorithm: " + [r][0]['result'][query]['algoritm]'], inline=False)
embed.add_field(name=f"Plaintext", value={r[0]['result'][query]['plain']}, inline=False)
await ctx.send(embed=embed)
以下是API的示例:https://hashes.org/api.php?key=3Ak6W7ytyIo3GS0mG3cUpARnpCVbnd&query=9ede947a76b6af18f51996d0817ac496
如果有人可以帮助您,因为说实话,那会很棒,我不知道我在做什么
答案 0 :(得分:0)
尝试-
embed.add_field(name=f"{query}", value="Algorithm: " + [r['result'][query]['algorithm'], inline=False)
embed.add_field(name=f"Plaintext", value={r['result'][query]['plain']}, inline=False)
答案 1 :(得分:0)
修复了我自己的代码。 更改为此:
@commands.command(name='crackhash', aliases = ['hashcrack'])
async def hashcracking(self, ctx, query):
url = "https://hashes.org/api.php?key=" + hashapi_key + "&query=" + query
async with ClientSession() as session:
async with session.get(url) as response:
str(query)
r = await response.json(content_type=None)
embed = discord.Embed(colour=discord.Colour.purple(), timestamp=ctx.message.created_at,
title=f"Hash Cracking")
status = (f"{r['status']}")
status.capitalize()
member = ctx.message.author
embed.set_thumbnail(url=member.avatar_url)
embed.set_footer(text=f"Requested by {ctx.author}")
embed.add_field(name=f"Status", value=status, inline=False)
embed.add_field(name=f"Algorithm", value=f"{r['result'][query]['algorithm']}", inline=False)
embed.add_field(name=f"Plaintext", value=f"{r['result'][query]['plain']}", inline=False)
await ctx.send(embed=embed)
不过谢谢您的帮助!