Skip to content

Commit

Permalink
fix: improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
tobfd committed Jul 14, 2024
1 parent 0a2ea34 commit 72baaaf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
11 changes: 5 additions & 6 deletions cogs/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from ezcord import codeblock
from pyowm import OWM
from pyowm.utils import timestamps
from pyowm.weatherapi25 import Weather as WeatherClass
from translate import Translator

load_dotenv()
Expand All @@ -35,7 +34,7 @@ async def get_view(
sunrise: str,
sunset: str,
forecast: bool = False,
original_weather: WeatherClass | None = None,
original_weather=None,
) -> discord.ui.View:
if forecast:
label = "Jetzt"
Expand All @@ -51,7 +50,7 @@ async def get_view(


async def get_weather_embed(
weather: WeatherClass, city: str, sunrise: str, sunset: str, three_hours: bool = False
weather, city: str, sunrise: str, sunset: str, three_hours: bool = False
) -> discord.Embed:
temperaturen = weather.temperature("celsius")
temp = round(int(temperaturen.get("temp")))
Expand Down Expand Up @@ -103,7 +102,7 @@ async def weather(self, ctx: ezcord.EzContext, city: str):
observation = mgr.weather_at_place(city)
except pyowm.commons.exceptions.NotFoundError:
return await ctx.error(f"Die Stadt **{city}** konnte nicht gefunden werden.")
weather: WeatherClass = observation.weather
weather = observation.weather
sunrise = discord.utils.format_dt(weather.sunrise_time(timeformat="date"), "T")
sunset = discord.utils.format_dt(weather.sunset_time(timeformat="date"), "T")
embed = await get_weather_embed(weather, city, sunrise, sunset)
Expand All @@ -122,7 +121,7 @@ def __init__(
label: str,
sunrise: str,
sunset: str,
weather: WeatherClass,
weather,
style: discord.ButtonStyle | None = discord.ButtonStyle.primary,
):
super().__init__(label=label, style=style, custom_id="forecast_button")
Expand All @@ -137,7 +136,7 @@ async def callback(self, interaction: Interaction):
three_hours = False
else:
prognose = mgr.forecast_at_place(self.city, "3h")
response: WeatherClass = prognose.get_weather_at(timestamps.next_three_hours())
response = prognose.get_weather_at(timestamps.next_three_hours())
weather = response
three_hours = True
embed = await get_weather_embed(
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ ezcord
python-dotenv
pyowm
translate
setuptools

0 comments on commit 72baaaf

Please sign in to comment.