add embed footers and timestamps to all current embeds (#34)

This commit is contained in:
Abigail Gold 2019-10-09 01:25:33 -04:00 committed by GitHub
parent a0cb64789b
commit 021a1312cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 118 additions and 32 deletions

View File

@ -10,6 +10,8 @@ General Public License, version 2.
import discord import discord
import discord.ext.commands as commands import discord.ext.commands as commands
from datetime import datetime
class BaseCog(commands.Cog): class BaseCog(commands.Cog):
def __init__(self, bot): def __init__(self, bot):
@ -19,7 +21,12 @@ class BaseCog(commands.Cog):
@commands.command(name="info", aliases=["about"]) @commands.command(name="info", aliases=["about"])
async def _info(self, ctx): async def _info(self, ctx):
"""Shows info about qrm.""" """Shows info about qrm."""
embed = discord.Embed(title="About qrm", description=self.gs.info.description, colour=self.gs.colours.neutral) embed = discord.Embed(title="About qrm",
description=self.gs.info.description,
colour=self.gs.colours.neutral,
timestamp=datetime.utcnow())
embed.set_footer(text=ctx.author.name,
icon_url=str(ctx.author.avatar_url))
embed = embed.add_field(name="Authors", value=", ".join(self.gs.info.authors)) embed = embed.add_field(name="Authors", value=", ".join(self.gs.info.authors))
embed = embed.add_field(name="Contributing", value=self.gs.info.contributing) embed = embed.add_field(name="Contributing", value=self.gs.info.contributing)
embed = embed.add_field(name="License", value=self.gs.info.license) embed = embed.add_field(name="License", value=self.gs.info.license)
@ -27,7 +34,13 @@ class BaseCog(commands.Cog):
@commands.command(name="ping") @commands.command(name="ping")
async def _ping(self, ctx): async def _ping(self, ctx):
await ctx.send(f'**Pong!** Current ping is {self.bot.latency*1000:.1f} ms') embed = discord.Embed(title="**Pong!**",
description=f'Current ping is {self.bot.latency*1000:.1f} ms',
colour=self.gs.colours.neutral,
timestamp=datetime.utcnow())
embed.set_footer(text=ctx.author.name,
icon_url=str(ctx.author.avatar_url))
await ctx.send(embed=embed)
def setup(bot): def setup(bot):

View File

@ -11,6 +11,8 @@ import discord
import discord.ext.commands as commands import discord.ext.commands as commands
import math import math
from datetime import datetime
class GridCog(commands.Cog): class GridCog(commands.Cog):
def __init__(self, bot): def __init__(self, bot):
@ -36,12 +38,20 @@ class GridCog(commands.Cog):
grid += chr(ord('a') + int((latf - (int(latf/1)*1)) / (2.5/60))) grid += chr(ord('a') + int((latf - (int(latf/1)*1)) / (2.5/60)))
grid += "**" grid += "**"
embed = discord.Embed(title=f'Maidenhead Grid Locator for {float(lat):.6f}, {float(lon):.6f}', embed = discord.Embed(title=f'Maidenhead Grid Locator for {float(lat):.6f}, {float(lon):.6f}',
description=grid, colour=self.gs.colours.good) description=grid,
colour=self.gs.colours.good,
timestamp=datetime.utcnow())
embed.set_footer(text=ctx.author.name,
icon_url=str(ctx.author.avatar_url))
else: else:
raise ValueError('Out of range.') raise ValueError('Out of range.')
except Exception as e: except Exception as e:
msg = f'Error generating grid square for {lat}, {lon}.' msg = f'Error generating grid square for {lat}, {lon}.'
embed = discord.Embed(title=msg, description=str(e), colour=self.gs.colours.bad) embed = discord.Embed(title=msg, description=str(e),
colour=self.gs.colours.bad,
timestamp=datetime.utcnow())
embed.set_footer(text=ctx.author.name,
icon_url=str(ctx.author.avatar_url))
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="ungrid", aliases=['loc']) @commands.command(name="ungrid", aliases=['loc'])
@ -57,15 +67,23 @@ class GridCog(commands.Cog):
if len(grid) >= 6: if len(grid) >= 6:
embed = discord.Embed(title=f'Latitude and Longitude for {grid}', embed = discord.Embed(title=f'Latitude and Longitude for {grid}',
description=f'**{loc[0]:.5f}, {loc[1]:.5f}**', colour=self.gs.colours.good, description=f'**{loc[0]:.5f}, {loc[1]:.5f}**', colour=self.gs.colours.good,
url=f'https://www.openstreetmap.org/#map=13/{loc[0]:.5f}/{loc[1]:.5f}') url=f'https://www.openstreetmap.org/#map=13/{loc[0]:.5f}/{loc[1]:.5f}',
timestamp=datetime.utcnow())
else: else:
embed = discord.Embed(title=f'Latitude and Longitude for {grid}', embed = discord.Embed(title=f'Latitude and Longitude for {grid}',
description=f'**{loc[0]:.1f}, {loc[1]:.1f}**', colour=self.gs.colours.good, description=f'**{loc[0]:.1f}, {loc[1]:.1f}**', colour=self.gs.colours.good,
url=f'https://www.openstreetmap.org/#map=10/{loc[0]:.1f}/{loc[1]:.1f}') url=f'https://www.openstreetmap.org/#map=10/{loc[0]:.1f}/{loc[1]:.1f}',
timestamp=datetime.utcnow())
embed.set_footer(text=ctx.author.name,
icon_url=str(ctx.author.avatar_url))
except Exception as e: except Exception as e:
msg = f'Error generating latitude and longitude for grid {grid}.' msg = f'Error generating latitude and longitude for grid {grid}.'
embed = discord.Embed(title=msg, description=str(e), colour=self.gs.colours.bad) embed = discord.Embed(title=msg, description=str(e),
colour=self.gs.colours.bad,
timestamp=datetime.utcnow())
embed.set_footer(text=ctx.author.name,
icon_url=str(ctx.author.avatar_url))
else: else:
R = 6371 R = 6371
try: try:
@ -92,10 +110,18 @@ class GridCog(commands.Cog):
des = f'**Distance:** {d:.1f} km ({d_mi:.1f} mi)\n**Bearing:** {bearing:.1f}°' des = f'**Distance:** {d:.1f} km ({d_mi:.1f} mi)\n**Bearing:** {bearing:.1f}°'
embed = discord.Embed(title=f'Great Circle Distance and Bearing from {grid} to {grid2}', embed = discord.Embed(title=f'Great Circle Distance and Bearing from {grid} to {grid2}',
description=des, colour=self.gs.colours.good) description=des,
colour=self.gs.colours.good,
timestamp=datetime.utcnow())
embed.set_footer(text=ctx.author.name,
icon_url=str(ctx.author.avatar_url))
except Exception as e: except Exception as e:
msg = f'Error generating great circle distance and bearing from {grid} and {grid2}.' msg = f'Error generating great circle distance and bearing from {grid} and {grid2}.'
embed = discord.Embed(title=msg, description=str(e), colour=self.gs.colours.bad) embed = discord.Embed(title=msg, description=str(e),
colour=self.gs.colours.bad,
timestamp=datetime.utcnow())
embed.set_footer(text=ctx.author.name,
icon_url=str(ctx.author.avatar_url))
await ctx.send(embed=embed) await ctx.send(embed=embed)
def getCoords(self, grid: str): def getCoords(self, grid: str):

View File

@ -28,11 +28,16 @@ class HamCog(commands.Cog):
'''Look up a Q Code.''' '''Look up a Q Code.'''
with ctx.typing(): with ctx.typing():
q = q.upper() q = q.upper()
try: if q in self.qcodes:
code = self.qcodes[q] embed = discord.Embed(title=q, description=self.qcodes[q],
embed = discord.Embed(title=q, description=self.qcodes[q], colour=self.gs.colours.good) colour=self.gs.colours.good,
except: timestamp=datetime.utcnow())
embed = discord.Embed(title=f'Q Code {q} not found', colour=self.gs.colours.bad) else:
embed = discord.Embed(title=f'Q Code {q} not found',
colour=self.gs.colours.bad,
timestamp=datetime.utcnow())
embed.set_footer(text=ctx.author.name,
icon_url=str(ctx.author.avatar_url))
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="phonetics", aliases=['ph', 'phoneticize', 'phoneticise', 'phone']) @commands.command(name="phonetics", aliases=['ph', 'phoneticize', 'phoneticise', 'phone'])
@ -47,7 +52,12 @@ class HamCog(commands.Cog):
else: else:
result += char result += char
result += ' ' result += ' '
embed = discord.Embed(title=f'Phonetics for {msg}', description=result.title(), colour=self.gs.colours.good) embed = discord.Embed(title=f'Phonetics for {msg}',
description=result.title(),
colour=self.gs.colours.good,
timestamp=datetime.utcnow())
embed.set_footer(text=ctx.author.name,
icon_url=str(ctx.author.avatar_url))
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="utc", aliases=['z']) @commands.command(name="utc", aliases=['z'])
@ -56,7 +66,12 @@ class HamCog(commands.Cog):
with ctx.typing(): with ctx.typing():
d = datetime.utcnow() d = datetime.utcnow()
result = '**' + d.strftime('%Y-%m-%d %H:%M') + 'Z**' result = '**' + d.strftime('%Y-%m-%d %H:%M') + 'Z**'
embed = discord.Embed(title='The current time is:', description=result, colour=self.gs.colours.good) embed = discord.Embed(title='The current time is:',
description=result,
colour=self.gs.colours.good,
timestamp=datetime.utcnow())
embed.set_footer(text=ctx.author.name,
icon_url=str(ctx.author.avatar_url))
await ctx.send(embed=embed) await ctx.send(embed=embed)

View File

@ -11,6 +11,8 @@ import discord
import discord.ext.commands as commands import discord.ext.commands as commands
import json import json
from datetime import datetime
class MorseCog(commands.Cog): class MorseCog(commands.Cog):
def __init__(self, bot): def __init__(self, bot):
@ -31,8 +33,12 @@ class MorseCog(commands.Cog):
except: except:
result += '<?>' result += '<?>'
result += ' ' result += ' '
embed = discord.Embed(title=f'Morse Code for {msg}', description=result, embed = discord.Embed(title=f'Morse Code for {msg}',
colour=self.gs.colours.good) description=result,
colour=self.gs.colours.good,
timestamp=datetime.utcnow())
embed.set_footer(text=ctx.author.name,
icon_url=str(ctx.author.avatar_url))
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="unmorse", aliases=['demorse', 'uncw', 'decw']) @commands.command(name="unmorse", aliases=['demorse', 'uncw', 'decw'])
@ -50,8 +56,12 @@ class MorseCog(commands.Cog):
except: except:
result += '<?>' result += '<?>'
result += ' ' result += ' '
embed = discord.Embed(title=f'ASCII for {msg0}', description=result, embed = discord.Embed(title=f'ASCII for {msg0}',
colour=self.gs.colours.good) description=result,
colour=self.gs.colours.good,
timestamp=datetime.utcnow())
embed.set_footer(text=ctx.author.name,
icon_url=str(ctx.author.avatar_url))
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="weight", aliases=["cwweight", 'cww']) @commands.command(name="weight", aliases=["cwweight", 'cww'])
@ -69,8 +79,12 @@ class MorseCog(commands.Cog):
await ctx.send(res) await ctx.send(res)
return return
res = f'The CW weight is **{weight}**' res = f'The CW weight is **{weight}**'
embed = discord.Embed(title=f'CW Weight of {msg}', description=res, embed = discord.Embed(title=f'CW Weight of {msg}',
colour=self.gs.colours.good) description=res,
colour=self.gs.colours.good,
timestamp=datetime.utcnow())
embed.set_footer(text=ctx.author.name,
icon_url=str(ctx.author.avatar_url))
await ctx.send(embed=embed) await ctx.send(embed=embed)

View File

@ -13,6 +13,8 @@ import discord.ext.commands as commands
import random import random
import json import json
import aiohttp import aiohttp
from datetime import datetime
class StudyCog(commands.Cog): class StudyCog(commands.Cog):
def __init__(self, bot): def __init__(self, bot):
@ -62,7 +64,11 @@ class StudyCog(commands.Cog):
pool_questions = random.choice(pool_section)['questions'] pool_questions = random.choice(pool_section)['questions']
question = random.choice(pool_questions) question = random.choice(pool_questions)
embed = discord.Embed(title=question['id'], colour=self.gs.colours.good) embed = discord.Embed(title=question['id'],
colour=self.gs.colours.good,
timestamp=datetime.utcnow())
embed.set_footer(text=ctx.author.name,
icon_url=str(ctx.author.avatar_url))
embed = embed.add_field(name='Question:', value=question['text'], inline=False) embed = embed.add_field(name='Question:', value=question['text'], inline=False)
embed = embed.add_field(name='Answers:', value= embed = embed.add_field(name='Answers:', value=
'**A:** ' + question['answers']['A'] + '**A:** ' + question['answers']['A'] +
@ -86,13 +92,25 @@ class StudyCog(commands.Cog):
ans = ans.upper() ans = ans.upper()
if ans == correct_ans: if ans == correct_ans:
result = f'Correct! The answer to {q_num} was **{correct_ans}**.' result = f'Correct! The answer to {q_num} was **{correct_ans}**.'
embed = discord.Embed(title=f'{q_num} Answer', description=result, colour=self.gs.colours.good) embed = discord.Embed(title=f'{q_num} Answer',
description=result,
colour=self.gs.colours.good,
timestamp=datetime.utcnow())
else: else:
result = f'Incorrect. The answer to {q_num} was **{correct_ans}**, not **{ans}**.' result = f'Incorrect. The answer to {q_num} was **{correct_ans}**, not **{ans}**.'
embed = discord.Embed(title=f'{q_num} Answer', description=result, colour=self.gs.colours.bad) embed = discord.Embed(title=f'{q_num} Answer',
description=result,
colour=self.gs.colours.bad,
timestamp=datetime.utcnow())
else: else:
result = f'The correct answer to {q_num} was **{correct_ans}**.' result = f'The correct answer to {q_num} was **{correct_ans}**.'
embed = discord.Embed(title=f'{q_num} Answer', description=result, colour=self.gs.colours.neutral) embed = discord.Embed(title=f'{q_num} Answer',
description=result,
colour=self.gs.colours.neutral,
timestamp=datetime.utcnow())
embed.set_footer(text=ctx.author.name,
icon_url=str(ctx.author.avatar_url))
await ctx.send(embed=embed) await ctx.send(embed=embed)