Пример #1
0
async def on_member_update(before, after):
    descr = ''
    if not before.display_name == after.display_name:
        descr = "Name changed from {} to {}".format(before.display_name, after.display_name)
    if not str(before.roles) == str(after.roles):
        changedrole = str(set(before.roles) ^ set(after.roles))
        changedrole = changedrole.split('\'')[1]
        if changedrole in str(before.roles):
            changedrole = changedrole + ' has been removed.'
        else:
            changedrole = changedrole + ' has been added.'
        if not descr == '':
            descr = descr + "\n Role {}".format(changedrole)
        else:
            descr = "Role " + changedrole
    if not descr == '':
        embed = discord.Embed(title="User {} : {} has been updated.".format(str(before), before.id), description=descr,
                              timestamp=datetime.datetime.utcnow())
        await bot.get_channel(Database.getLogChannel(before.guild.id)).send(embed=embed)
Пример #2
0
async def on_member_unban(guild, user):
    async for entry in guild.audit_logs(limit=None, target=user, action=discord.AuditLogAction.unban):
        embed = discord.Embed(title=f"User {str(user)} : {user.id} has been unbanned.",
                              description=f"Audit #{entry.id}, user unbanned by {entry.user}",
                              timestamp=entry.created_at)
        await bot.get_channel(Database.getLogChannel(guild.id)).send(embed=embed)
Пример #3
0
async def on_guild_role_delete(role):
    await bot.get_channel(Database.getLogChannel(role.guild.id)).send("Role {} has been deleted.".format(role.name))
Пример #4
0
async def on_guild_channel_delete(channel):
    await bot.get_channel(Database.getLogChannel(channel.guild.id)).send(
        "{} {} has been deleted.".format(str(type(channel)).split('.')[2][:-2], channel.name))
Пример #5
0
async def on_member_remove(member):
    await bot.get_channel(Database.getLogChannel(member.guild.id)).send(str(member) + " has left the server.")
Пример #6
0
async def on_member_join(member):
    await bot.get_channel(Database.getLogChannel(member.guild.id)).send(str(member) + " has joined the server.")
    await member.add_roles(discord.utils.get(member.guild.roles, name="Member"))
Пример #7
0
from config import config