Skip to content

Commit

Permalink
Improved temp images
Browse files Browse the repository at this point in the history
#close 476
  • Loading branch information
StephanAkkerman committed Feb 10, 2024
1 parent 65164c9 commit 164de38
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/cogs/loops/liquidations.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ async def post_liquidations(self):
fig.set_size_inches(15, 6)

# Convert to plot to a temporary image
filename = "liquidations.png"
filename = "temp/liquidations.png"
plt.savefig(filename, bbox_inches="tight", dpi=300)
plt.cla()
plt.close()
Expand Down
2 changes: 1 addition & 1 deletion src/cogs/loops/rsi_heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ async def post_rsi_heatmap(self):
# Display the plot
plt.tight_layout()

filename = "rsi_heatmap.png"
filename = "temp/rsi_heatmap.png"
plt.savefig(filename, bbox_inches="tight", dpi=300)
plt.cla()
plt.close()
Expand Down
9 changes: 5 additions & 4 deletions src/cogs/loops/yield.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ async def post_curve(self) -> None:
plt.xlabel("Residual Maturity")

# Convert to plot to a temporary image
plt.savefig("yield.png", bbox_inches="tight", dpi=300)
file_name = "temp/yield.png"
plt.savefig(file_name, bbox_inches="tight", dpi=300)
plt.cla()
plt.close()

Expand All @@ -84,14 +85,14 @@ async def post_curve(self) -> None:
color=0x000000,
timestamp=datetime.datetime.now(datetime.timezone.utc),
)
file = discord.File("yield.png")
e.set_image(url="attachment://yield.png")
file = discord.File(file_name)
e.set_image(url=f"attachment://{file_name}")

await self.channel.purge(limit=1)
await self.channel.send(file=file, embed=e)

# Delete yield.png
os.remove("yield.png")
os.remove(file_name)

async def plot_US_yield(self) -> None:
"""
Expand Down
4 changes: 2 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def load_folder(foldername: str) -> None:
bot.load_extension("util.db")

# Ensure the logs directory exists
if not os.path.exists("logs"):
os.makedirs("logs")
os.makedirs("logs", exist_ok=True)
os.makedirs("temp", exist_ok=True)

# Load commands
load_folder("commands")
Expand Down

0 comments on commit 164de38

Please sign in to comment.