Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def paginated_splatoon2_schedule(self, ctx, mode):
try:
data = self.sp2_map_data[mode]
except KeyError:
return await ctx.send('Sorry, no map data found...')
entries = [
(f'Now: {r.mode}' if r.current else f'In {time.human_timedelta(r.start_time)}: {r.mode}',
f'{r.stage_a} and {r.stage_b}')
for r in data
]
try:
p = FieldPages(ctx, entries=entries, per_page=4)
p.embed.colour = 0xF02D7D
await p.paginate()
except Exception as e:
await ctx.send(e)
def format_date(dt):
if dt is None:
return 'N/A'
return f'{dt:%Y-%m-%d %H:%M} ({time.human_timedelta(dt, accuracy=3)})'
async def reps_(self, ctx, member: typing.Optional[commands.MemberConverter]):
"""How many reps do you have?"""
member = member or ctx.author
user = await self.bot.db.get_user(member.id, get_reps=True)
reps = len(user.reps)
ret = f'{member.display_name} has received `{reps}` reps'
if reps > 0:
last_rep = max(user.reps, key=lambda r: r.repped_at)
ret += f'\nLast rep: {human_timedelta(last_rep.repped_at)}'
await ctx.send(ret)
def get_bot_uptime(self, *, brief=False):
return time.human_timedelta(self.bot.uptime, accuracy=None, brief=brief, suffix=False)
def human_delta(self):
return time.human_timedelta(self.created_at)
def prepare_embed(self, salmon, page, *, first=False):
self.embed = e = discord.Embed(colour=0xFF7500, title='Salmon Run')
if salmon.image:
e.set_image(url=salmon.image)
now = datetime.datetime.utcnow()
if now <= salmon.start_time:
e.set_footer(text='Starts').timestamp = salmon.start_time
e.description = f'Starts in {time.human_timedelta(salmon.start_time)}'
elif now <= salmon.end_time:
e.set_footer(text='Ends').timestamp = salmon.end_time
e.description = f'Ends in {time.human_timedelta(salmon.end_time)}'
e.add_field(name='Weapons', value='\n'.join(salmon.weapons) or 'Unknown')
e.add_field(name='Map', value=salmon.stage or 'Unknown')
if self.maximum_pages > 1:
e.title = f'Salmon Run {page} out of {self.maximum_pages}'
records = await ctx.db.fetch(query, str(ctx.author.id))
if len(records) == 0:
return await ctx.send('No currently running reminders.')
e = discord.Embed(colour=discord.Colour.blurple(), title='Reminders')
if len(records) == 10:
e.set_footer(text='Only showing up to 10 reminders.')
else:
e.set_footer(text=f'{len(records)} reminder{"s" if len(records) > 1 else ""}')
for _id, expires, message in records:
shorten = textwrap.shorten(message, width=512)
e.add_field(name=f'{_id}: In {time.human_timedelta(expires)}', value=shorten, inline=False)
await ctx.send(embed=e)