我有一个命令,该命令应该获取给定加密货币的价格,但它不起作用。代码如下:
@commands.command()
async def crypto(self, ctx, cc = None):
try:
if cc is None:
ccbed=discord.Embed(title='Command Usage:', description=f'/crypto [crypto currency]', colour=random.randint(0x000000, 0xffffff), timestamp=datetime.utcnow())
await ctx.send(embed=ccbed)
else:
url = f"https://api.coingecko.com/api/v3/simple/price?ids={cc}&vs_currencies=usd%2Ceur%2Cgbp"
stats = requests.get(url)
json_stats = stats.json()
usdprice = json_stats["usd"]
europrice = json_stats["eur"]
gbpprice = json_stats["gbp"]
ccbed2 = discord.Embed(title=f"**Current price of {cc}**", description="This data might be inaccurate.", colour=random.randint(0x000000, 0xffffff), timestamp=datetime.utcnow())
ccbed2.add_field(name="**USD:**", value=usdprice, inline=True)
ccbed2.add_field(name="**EURO:**", value=europrice, inline=True)
ccbed2.add_field(name="**GBP:**", value=gbpprice, inline=True)
await ctx.send(embed=ccbed2)
except:
ccbed3 = discord.Embed(title="Invalid crypto currency or API error.", colour=random.randint(0x000000, 0xffffff), timestamp=datetime.utcnow())
ccbed3.set_author(name="Error!")
await ctx.send(embed=ccbed3)
当我运行该命令时,它会触发无效的加密货币或API错误
你的类路径中有一个sourcesJAR,这是行不通的。获取一个普通的JAR
mariadb-java-client.jar
并将其放在类路径上。最好使用gradle或Maven等依赖关系管理工具相关问题 更多 >
编程相关推荐