示例#1
0
async def logEdit(before, after):
    r = DictionaryReader()

    emb = Embed()
    emb.title = 'Message Edited in {0.channel.name}'.format(before)
    emb.type = 'rich'
    emb.url = after.jump_url
    emb.colour = Colour.blue()
    emb.set_footer(text='UserID: {0.author.id}'.format(before),
                   icon_url=before.author.avatar_url)
    emb.set_author(name=before.author.name, icon_url=before.author.avatar_url)
    emb.add_field(name='Before', value=before.content)
    emb.add_field(name='After', value=after.content, inline=False)

    logChannel = client.get_channel(int(r.moderationLogChannel()))
    await logChannel.send(embed=emb)
示例#2
0
async def logDelete(message):
    r = DictionaryReader()
    logChannel = client.get_channel(int(r.moderationLogChannel()))

    if not message.guild:
        return

    deletedBy = message.author

    # Checks if the bot can see the audit log
    if message.guild.me.guild_permissions.view_audit_log:
        auditLogs = message.guild.audit_logs(
            limit=100, action=discord.AuditLogAction.message_delete)
        logs = await auditLogs.flatten()
        deletionLog = None
        for log in logs:
            if log.target.id == message.author.id:
                deletionLog = log
                break

        deletedBy = deletionLog.user if deletionLog else deletedBy

    emb = Embed()
    emb.title = 'Message Deleted in {0.channel.name}'.format(message)
    emb.type = 'rich'
    emb.url = message.jump_url
    emb.colour = Colour.red()
    emb.set_footer(text='Timestamp: ' + time.strftime("%Y-%m-%d %H:%M:%S"))
    emb.set_author(name=message.author.name,
                   icon_url=message.author.avatar_url)
    emb.add_field(name='Author', value=message.author.name)
    emb.add_field(name='Deleted by', value=deletedBy.name)
    if not message.guild.me.guild_permissions.view_audit_log:
        emb.add_field(name='Warning', value='Bot cant see AuditLog')
    emb.add_field(name='Message', value=message.content, inline=False)

    await logChannel.send(embed=emb)
示例#3
0
async def logBan(guild, user):
    r = DictionaryReader()
    logChannel = client.get_channel(int(r.moderationLogChannel()))

    if not guild:
        return

    bannedBy = guild.me
    banReason = ''

    # Checks if the bot can see the audit log
    if guild.me.guild_permissions.view_audit_log:
        auditLogs = guild.audit_logs(limit=100,
                                     action=discord.AuditLogAction.ban)
        logs = await auditLogs.flatten()
        banLog = None
        for log in logs:
            if log.target.id == user.id:
                banLog = log
                break

        bannedBy = banLog.user if banLog else bannedBy
        banReason = banLog.reason

    emb = Embed()
    emb.title = 'User {0.name} Banned'.format(user)
    emb.type = 'rich'
    emb.colour = Colour.dark_red()
    emb.set_footer(text='Timestamp: ' + time.strftime("%Y-%m-%d %H:%M:%S"))
    emb.set_author(name=user.name, icon_url=user.avatar_url)
    emb.add_field(name='Banned by', value=bannedBy.name)
    if not guild.me.guild_permissions.view_audit_log:
        emb.add_field(name='Warning', value='Bot cant see AuditLog')
    emb.add_field(name='Reason', value=banReason, inline=False)

    await logChannel.send(embed=emb)