mirror of
https://github.com/RustyRaptor/Trusty-cogs.git
synced 2026-12-03 15:55:21 -07:00
[Conversions] 1.3.3 Fix ticker and currency conversion commands
This commit is contained in:
2 files changed
+6
-4
No files matched your search
@@ -15,7 +15,7 @@ TrustyJAID's Cogs for [Red-DiscordBot](https://github.com/Cog-Creators/Red-Disc
|
||||
| Citation | 1.3.0 | <details><summary>Create your own PapersPlease citation!</summary>Make your own Papers Please citation</details> | Saphire and TrustyJAID |
|
||||
| Cleverbot | 2.4.5 | <details><summary>Talk with Cleverbot!</summary>Have your bot respond with cleverbot responses. Supports tweaks to customize the responses!</details> | Twentysix and TrustyJAID |
|
||||
| Compliment | 1.0.0 | <details><summary>Compliment people in a creative way</summary>Compliment people in a creative way</details> | Airen, JennJenn, and TrustyJAID |
|
||||
| Conversions | 1.3.2 | <details><summary>Conversions for currencies, crypto-currencies, and stocks.</summary>Conversions for currencies, crypto-currencies, and stocks.</details> | TrustyJAID |
|
||||
| Conversions | 1.3.3 | <details><summary>Conversions for currencies, crypto-currencies, and stocks.</summary>Conversions for currencies, crypto-currencies, and stocks.</details> | TrustyJAID |
|
||||
| CrabRave | 1.2.0 | <details><summary>Make Crab rave videos, in discord!</summary>Create your very own Crab Rave videos with custom text! This cog requires FFMPEG, moviepy (https://github.com/Zulko/moviepy), and imagemagick to work. This cog downloads a template video and font file which is then saved locally and generates crab rave videos from the template. Old videos are deleted after uploading. This cog may consume heavy resources rendering videos.</details> | DankMemer Team, TrustyJAID, and thisisjvgrace |
|
||||
| | 2.0.0 | <details><summary>Thanks for installing</summary></details> | |
|
||||
| Elements | 1.1.1 | <details><summary>Periodic table of elements</summary>Get a plethora of information about elements on the periodic table.</details> | TrustyJAID |
|
||||
|
||||
@@ -20,7 +20,7 @@ class Conversions(commands.Cog):
|
||||
"""
|
||||
|
||||
__author__ = ["TrustyJAID"]
|
||||
__version__ = "1.3.2"
|
||||
__version__ = "1.3.3"
|
||||
|
||||
def __init__(self, bot: Red) -> None:
|
||||
self.bot = bot
|
||||
@@ -401,7 +401,8 @@ class Conversions(commands.Cog):
|
||||
`[currency]` is the currency you want to convert to defaults to USD
|
||||
"""
|
||||
stock = "https://query1.finance.yahoo.com/v8/finance/chart/{}"
|
||||
async with self.session.get(stock.format(ticker.upper())) as resp:
|
||||
headers = {"User-Agent": f"Red Trusty-cogs conversions on {self.bot.user.name}"}
|
||||
async with self.session.get(stock.format(ticker.upper()), headers=headers) as resp:
|
||||
data = await resp.json()
|
||||
if not data["chart"]["result"]:
|
||||
await ctx.send(
|
||||
@@ -492,8 +493,9 @@ class Conversions(commands.Cog):
|
||||
"""Function to convert different currencies"""
|
||||
conversion = None
|
||||
try:
|
||||
headers = {"User-Agent": f"Red Trusty-cogs conversions on {self.bot.user.name}"}
|
||||
url = f"https://query1.finance.yahoo.com/v8/finance/chart/{currency1}{currency2}=x"
|
||||
async with self.session.get(url) as resp:
|
||||
async with self.session.get(url, headers=headers) as resp:
|
||||
data = await resp.json()
|
||||
results = data.get("chart", {}).get("result", [])
|
||||
conversion = results[0].get("meta", {}).get("regularMarketPrice")
|
||||
|
||||
Reference in new issue
Block a user