Exemplo n.º 1
0
async def on_member_remove(member):  # Log left/kicked/banned members
    guild = member.guild
    if not guild_config.getlog(guild, 'usrlog'):
        return
    member_stalker.update('first_join', member)
    member_stalker.update('last_roles', member)
    now = datetime.utcnow()
    lastseen = member_stalker.get('last_seen', member)
    if lastseen is not None:
        lastseenmsg = (
            f'This user was last seen on `{lastseen.strftime("%d/%m/%Y %H:%M:%S")}` '
            f'({max(0, (now-lastseen).days)} days ago)')
    else:
        lastseenmsg = 'This user has not spoken to my knowledge.'
    embed = dc.Embed(
        color=dc.Color.red(),
        timestamp=now,
        description=f':red_circle: **{member}** has left **{guild}**!\n'
        f'The guild now has {guild.member_count} members!\n{lastseenmsg}')
    embed.set_author(name=f'A user left or got bucked off.')
    embed.set_thumbnail(url=member.avatar_url)
    embed.add_field(
        name='**Roles Snagged:**',
        value=(', '.join(f'`{guild.get_role(role).name}`'
                         for role in member_stalker.get('last_roles', member))
               or None),
        inline=False)
    embed.add_field(name='**User ID:**', value=f'`{member.id}`')
    await guild_config.log(guild, 'usrlog', embed=embed)
Exemplo n.º 2
0
async def on_member_ban(guild, user):  # Log member full bans
    if not guild_config.getlog(guild, 'modlog'):
        return
    async for entry in guild.audit_logs(limit=256,
                                        action=dc.AuditLogAction.ban):
        if entry.target.id == user.id:
            break
    else:
        await guild_config.log(
            guild,
            f'The last ban of {user} `{user.id}` could not be found in the audit log.',
        )
        return
    author = entry.user
    embed = dc.Embed(
        color=author.color,
        timestamp=datetime.utcnow(),
        description=f'**{author}** has full banned :hammer: **{user}**!')
    embed.set_author(name=f'Good riddance.', icon_url=author.avatar_url)
    embed.set_thumbnail(url=user.avatar_url)
    embed.add_field(
        name='**Reason:**',
        value=entry.reason or 'None specified.',
        inline=False,
    )
    embed.add_field(
        name='**Roles Snagged:**',
        value=(', '.join(f'`{guild.get_role(role).name}`'
                         for role in member_stalker.get('last_roles', user))
               or None),
        inline=False)
    embed.add_field(name='**User ID:**', value=f'`{user.id}`')
    await guild_config.log(guild, 'modlog', embed=embed)
Exemplo n.º 3
0
dt_format = '%d/%m/%Y at %H:%M:%S UTC'


@bot.command(aliases=['peek'])
@commands.bot_has_permissions(send_messages=True)
async def info(ctx, *, name=None):
    if name is None:
        member = ctx.author
    elif (member := await commands.MemberConverter().convert(ctx,
                                                             name)) is None:
        await ctx.send(
            'D--> It seems that user can\'t be found. Please check your spelling.'
        )
        return
    now = datetime.utcnow()
    firstjoin = member_stalker.get('first_join', member) or member.joined_at
    embed = dc.Embed(color=member.color, timestamp=now)
    embed.set_author(name=f'Information for {member}')
    embed.set_thumbnail(url=member.avatar_url)
    if ctx.author != member and ctx.author != bot.user:
        lastseen = member_stalker.get('last_seen', member)
        if lastseen is not None:
            lastseenmsg = (f'```{lastseen.strftime(dt_format)}\n'
                           f'{max(0, (now-lastseen).days)} day(s) ago```')
        else:
            lastseenmsg = '```This user has not spoken to my knowledge!```'
        embed.add_field(name='This user was last seen on:',
                        value=lastseenmsg,
                        inline=False)
    embed.add_field(name='Account Created On:',
                    value=f'```{member.created_at.strftime(dt_format)}\n'