src/cogs/apis.py
async def weather(self, ctx, *, location):
        """Retrieve weather data for a location from OpenWeatherMap.

        location: str
        The location to retrieve weather data for.
        """
        url = (
            f'https://api.openweathermap.org/'
            f'data/2.5/weather?q={location}'
            f'&appid={owm_api_key}&units=metric'
            )
        data, status = await self.get_data(url)

        if data and status:
            return await ctx.reply(f"{status}: {data['message']}")

        sys = data['sys']
        weather = data['weather'][0]
        main = data['main']
        wind = data['wind']

        if 'country' not in sys:
            title = f"{data['name']}"
        else:
            title = f"{data['name']}, {sys['country']}"

        embed = discord.Embed(
            title=title,
            colour=discord.Colour.blurple(),
            description=(
                f"**{round(main['temp'])}\u00b0C**"
                f"\u2002{weather['main']} ({weather['description']})"
                )
            )

        embed.set_thumbnail(
            url=(
                f'http://openweathermap.org/'
                f"img/wn/{weather['icon']}@2x.png"
                )
            )

        if 'rain' not in data:
            rain = '0'
        else:
            rain = data['rain']['1h']

        compass_dir = [
            'N', 'NNE', 'NE', 'ENE',
            'E', 'ESE', 'SE', 'SSE',
            'S', 'SSW', 'SW', 'WSW',
            'W', 'WNW', 'NW', 'NNW',
            'N',
            ]
        wind_dir = compass_dir[round((wind['deg'] % 360) / 22.5)]

        embed.add_field(
            name='Temperatures',
            value=f"""
            Min Temp: {round(main['temp_min'])}\u00b0C
            Max Temp: {round(main['temp_max'])}\u00b0C
            """,
            inline=False
        )

        embed.add_field(
            name='Atmospherics',
            value=f"""
            Percipitation: {rain} mm
            Humidity: {main['humidity']}%
            Wind Speed: {round(wind['speed'], 1)} m/s {wind_dir}
            Atmos Pres: {main['pressure']} hPa
            """,
            inline=False
        )

        embed.add_field(
            name='Times',
            value=f"""
            Sunrise: {datetime.fromtimestamp(sys['sunrise'])
            .strftime('%I:%M %p')}
            Sunset: {datetime.fromtimestamp(sys['sunset'])
            .strftime('%I:%M %p')}
            """,
            inline=False
        )

        await ctx.send(embed=embed)
Retrieve weather data for a location from OpenWeatherMap.

        location: str
        The location to retrieve weather data for.
        
Retrieve weather data for a location from OpenWeatherMap.
location: str
The location to retrieve weather data for.
Retrieve weather data for a location from OpenWeatherMap . location : str The location to retrieve weather data for .
async def weather(self, ctx, *, location):
        url = (
            f'https://api.openweathermap.org/'
            f'data/2.5/weather?q={location}'
            f'&appid={owm_api_key}&units=metric'
            )
        data, status = await self.get_data(url)
        if data and status:
            return await ctx.reply(f"{status}: {data['message']}")
        sys = data['sys']
        weather = data['weather'][0]
        main = data['main']
        wind = data['wind']
        if 'country' not in sys:
            title = f"{data['name']}"
        else:
            title = f"{data['name']}, {sys['country']}"
        embed = discord.Embed(
            title=title,
            colour=discord.Colour.blurple(),
            description=(
                f"**{round(main['temp'])}\u00b0C**"
                f"\u2002{weather['main']} ({weather['description']})"
                )
            )
        embed.set_thumbnail(
            url=(
                f'http://openweathermap.org/'
                f"img/wn/{weather['icon']}@2x.png"
                )
            )
        if 'rain' not in data:
            rain = '0'
        else:
            rain = data['rain']['1h']
        compass_dir = [
            'N', 'NNE', 'NE', 'ENE',
            'E', 'ESE', 'SE', 'SSE',
            'S', 'SSW', 'SW', 'WSW',
            'W', 'WNW', 'NW', 'NNW',
            'N',
            ]
        wind_dir = compass_dir[round((wind['deg'] % 360) / 22.5)]
        embed.add_field(
            name='Temperatures',
            value=f"""
            Min Temp: {round(main['temp_min'])}\u00b0C
            Max Temp: {round(main['temp_max'])}\u00b0C
            """,
            inline=False
        )
        embed.add_field(
            name='Atmospherics',
            value=f"""
            Percipitation: {rain} mm
            Humidity: {main['humidity']}%
            Wind Speed: {round(wind['speed'], 1)} m/s {wind_dir}
            Atmos Pres: {main['pressure']} hPa
            """,
            inline=False
        )
        embed.add_field(
            name='Times',
            value=f"""
            Sunrise: {datetime.fromtimestamp(sys['sunrise'])
            .strftime('%I:%M %p')}
            Sunset: {datetime.fromtimestamp(sys['sunset'])
            .strftime('%I:%M %p')}
            """,
            inline=False
        )
        await ctx.send(embed=embed)
async def weather ( self , ctx , * , location ) : url = ( f'https://api.openweathermap.org/' f'data/2.5/weather?q={location}' f'&appid={owm_api_key}&units=metric' ) data , status = await self . get_data ( url ) if data and status : return await ctx . reply ( f"{status}: {data['message']}" ) sys = data [ 'sys' ] weather = data [ 'weather' ] [ 0 ] main = data [ 'main' ] wind = data [ 'wind' ] if 'country' not in sys : title = f"{data['name']}" else : title = f"{data['name']}, {sys['country']}" embed = discord . Embed ( title = title , colour = discord . Colour . blurple ( ) , description = ( f"**{round(main['temp'])}\u00b0C**" f"\u2002{weather['main']} ({weather['description']})" ) ) embed . set_thumbnail ( url = ( f'http://openweathermap.org/' f"img/wn/{weather['icon']}@2x.png" ) ) if 'rain' not in data : rain = '0' else : rain = data [ 'rain' ] [ '1h' ] compass_dir = [ 'N' , 'NNE' , 'NE' , 'ENE' , 'E' , 'ESE' , 'SE' , 'SSE' , 'S' , 'SSW' , 'SW' , 'WSW' , 'W' , 'WNW' , 'NW' , 'NNW' , 'N' , ] wind_dir = compass_dir [ round ( ( wind [ 'deg' ] % 360 ) / 22.5 ) ] embed . add_field ( name = 'Temperatures' , value = f"""
            Min Temp: {round(main['temp_min'])}\u00b0C
            Max Temp: {round(main['temp_max'])}\u00b0C
            """ , inline = False ) embed . add_field ( name = 'Atmospherics' , value = f"""
            Percipitation: {rain} mm
            Humidity: {main['humidity']}%
            Wind Speed: {round(wind['speed'], 1)} m/s {wind_dir}
            Atmos Pres: {main['pressure']} hPa
            """ , inline = False ) embed . add_field ( name = 'Times' , value = f"""
            Sunrise: {datetime.fromtimestamp(sys['sunrise'])
            .strftime('%I:%M %p')}
            Sunset: {datetime.fromtimestamp(sys['sunset'])
            .strftime('%I:%M %p')}
            """ , inline = False ) await ctx . send ( embed = embed )
Retrieve weather data for a location from OpenWeatherMap.
Retrieve weather data for a location from OpenWeatherMap .
"""Retrieve weather data for a location from OpenWeatherMap.

        location: str
        The location to retrieve weather data for.
        """
self
ctx
location