Add user_events module and user_update event
This commit is contained in:
parent
876bd54687
commit
a318f129c9
@ -3,6 +3,7 @@
|
|||||||
"admin",
|
"admin",
|
||||||
"exec",
|
"exec",
|
||||||
"message_events",
|
"message_events",
|
||||||
|
"user_events",
|
||||||
"tickets"
|
"tickets"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
29
geeksbot/exts/user_events.py
Normal file
29
geeksbot/exts/user_events.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
from datetime import datetime
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
user_logger = logging.getLogger('UserEvents')
|
||||||
|
|
||||||
|
|
||||||
|
class UserEvents(commands.Cog):
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
@commands.Cog.listner()
|
||||||
|
async def on_user_update(self, before, after):
|
||||||
|
data = {
|
||||||
|
'username': after.name,
|
||||||
|
'discriminator': after.discriminator,
|
||||||
|
'animated': after.is_avatar_animated(),
|
||||||
|
'avatar': after.avatar or str(after.default_avatar)
|
||||||
|
}
|
||||||
|
resp = await self.bot.aio_session.put(f'{self.bot.api_base}/users/{after.id}/',
|
||||||
|
headers=self.bot.auth_header,
|
||||||
|
json=data)
|
||||||
|
user_logger.info(f'User Update Response:\n{await resp.json()}')
|
||||||
|
|
||||||
|
|
||||||
|
def setup(bot):
|
||||||
|
bot.add_cog(UserEvents(bot))
|
||||||
Loading…
x
Reference in New Issue
Block a user