Example #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)
Example #2
0
async def on_message(msg):  # Message posted event
    if msg.guild is None:
        return
    member_stalker.update('last_seen', msg)
    ctx = await bot.get_context(msg)
    if ctx.valid:
        if guild_config.getcmd(ctx):
            await bot.process_commands(msg)
    elif guild_config.getcmd(
            ctx) and msg.content.strip().lower() in query_bank.affirmation:
        await msg.channel.send(response_bank.affirmation_response)
    elif (msg.channel.id in guild_config.getlog(msg.guild, 'autoreact')
          and any(
              any(map(att.url.lower().endswith, image_exts))
              for att in msg.attachments)):
        await msg.add_reaction('❤️')
Example #3
0
async def on_member_join(member):  # Log joined members
    guild = member.guild
    if not guild_config.getlog(guild, 'usrlog'):
        return
    member_stalker.update('first_join', member)
    await member_stalker.load_roles(member)
    embed = dc.Embed(
        color=dc.Color.green(),
        timestamp=datetime.utcnow(),
        description=
        f':green_circle: {member.mention}: ``{member}`` has joined **{guild}**!\n'
        f'The guild now has {guild.member_count} members!\n'
        f'This account was created on `{member.created_at.strftime("%d/%m/%Y %H:%M:%S")}`'
    )
    embed.set_author(name=f'A user has joined the server!')
    embed.set_thumbnail(url=member.avatar_url)
    embed.add_field(name='**User ID**', value=f'`{member.id}`')
    await guild_config.log(guild, 'usrlog', embed=embed)