diff --git a/exts/ae7q.py b/exts/ae7q.py index 1e5f065..b543b13 100644 --- a/exts/ae7q.py +++ b/exts/ae7q.py @@ -37,11 +37,16 @@ class AE7QCog(commands.Cog): callsign = callsign.upper() desc = '' base_url = "http://ae7q.com/query/data/CallHistory.php?CALL=" + embed = cmn.embed_factory(ctx) async with aiohttp.ClientSession() as session: async with session.get(base_url + callsign) as resp: if resp.status != 200: - return await ctx.send('Could not load AE7Q') + embed.title = "Error in AE7Q call command" + embed.description = 'Could not load AE7Q' + embed.colour = cmn.colours.bad + await ctx.send(embed=embed) + return page = await resp.text() soup = BeautifulSoup(page, features="html.parser") @@ -59,7 +64,6 @@ class AE7QCog(commands.Cog): rows = None if rows is None: - embed = cmn.embed_factory(ctx) embed.title = f"AE7Q History for {callsign}" embed.colour = cmn.colours.bad embed.url = f"{base_url}{callsign}" diff --git a/exts/morse.py b/exts/morse.py index de762b6..1d7f952 100644 --- a/exts/morse.py +++ b/exts/morse.py @@ -62,6 +62,7 @@ class MorseCog(commands.Cog): @commands.command(name="cwweight", aliases=["weight", 'cww'], category=cmn.cat.ref) async def _weight(self, ctx: commands.Context, *, msg: str): '''Calculates the CW Weight of a callsign or message.''' + embed = cmn.embed_factory(ctx) with ctx.typing(): msg = msg.upper() weight = 0 @@ -70,13 +71,13 @@ class MorseCog(commands.Cog): cw_char = self.ascii2morse[char].replace('-', '==') weight += len(cw_char) * 2 + 2 except KeyError: - res = f'Unknown character {char} in callsign' - await ctx.send(res) + embed.title = 'Error in calculation of CW weight' + embed.description = f'Unknown character {char} in callsign' + embed.colour = cmn.colours.bad + await ctx.send(embed=embed) return - res = f'The CW weight is **{weight}**' - embed = cmn.embed_factory(ctx) embed.title = f'CW Weight of {msg}' - embed.description = res + embed.description = f'The CW weight is **{weight}**' embed.colour = cmn.colours.good await ctx.send(embed=embed) diff --git a/exts/study.py b/exts/study.py index 541bf73..59c56f4 100644 --- a/exts/study.py +++ b/exts/study.py @@ -30,6 +30,7 @@ class StudyCog(commands.Cog): gen_pool = 'E3_2019' extra_pool = 'E4_2016' + embed = cmn.embed_factory(ctx) with ctx.typing(): selected_pool = None try: @@ -49,15 +50,22 @@ class StudyCog(commands.Cog): if (level is None) or (level == 'all'): # no pool given or user wants all, so pick a random pool selected_pool = random.choice([tech_pool, gen_pool, extra_pool]) if (level is not None) and (selected_pool is None): # unrecognized pool given by user - await ctx.send('The question pool you gave was unrecognized. ' + - 'There are many ways to call up certain question pools - try ?rq t, g, or e. ' + - '(Note that only the US question pools are available).') + embed.title = 'Error in HamStudy command' + embed.description = ('The question pool you gave was unrecognized. ' + 'There are many ways to call up certain question pools - try ?rq t, g, or e. ' + '\n\nNote that currently only the US question pools are available.') + embed.colour = cmn.colours.bad + await ctx.send(embed=embed) return async with aiohttp.ClientSession() as session: async with session.get(f'https://hamstudy.org/pools/{selected_pool}') as resp: if resp.status != 200: - return await ctx.send('Could not load questions...') + embed.title = 'Error in HamStudy command' + embed.description = 'Could not load questions' + embed.colour = cmn.colours.bad + await ctx.send(embed=embed) + return pool = json.loads(await resp.read())['pool'] # Select a question @@ -65,7 +73,6 @@ class StudyCog(commands.Cog): pool_questions = random.choice(pool_section)['questions'] question = random.choice(pool_questions) - embed = cmn.embed_factory(ctx) embed.title = question['id'] embed.description = self.source embed.colour = cmn.colours.good