def entries(): for i, (expires, channel_id, message) in enumerate(reminders, start=1): channel = f'<#{channel_id}>' if channel_id else 'Direct Message' name = f'{i}. In {human_timedelta(expires)} from now.' value = truncate(f'{channel}: {message}', 1024, '...') yield name, value
def name_values(): sorted_entities = sorted(entities, key=_get_class_name) for k, group in itertools.groupby(sorted_entities, _get_class_name): group = list(group) name = f'{k}{"s" * (len(group) != 1)}' value = truncate(', '.join(map(str, group)), 1024, '...') yield name, value
def name_values(): for thing in map( list, partition(lambda e: isinstance(e, discord.TextChannel), entries)): if not thing: continue name = f'{_get_class_name(thing[0])}{"s" * (len(thing) != 1)}' value = truncate(', '.join(map(str, thing)), 1024, '...') yield name, value
async def _blacklist_embed(self, ctx, action, icon, thing, reason, time): type_name = 'Server' if isinstance(thing, discord.Guild) else 'User' reason = truncate(reason, 1024, '...') if reason else 'None' embed = (discord.Embed( timestamp=time, color=random_color()).set_author( name=f'{type_name} {action}', icon_url=icon).add_field(name='Name:', value=thing).add_field( name='ID:', value=thing.id).add_field(name='Reason:', value=reason, inline=False)) await ctx.send(embed=embed)