mirror of
https://github.com/uhIgnacio/EmoteManager.git
synced 2024-08-15 02:23:13 +00:00
change avatars every 30 minutes
This commit is contained in:
parent
5d13b2fec6
commit
ee9f8a0af9
1 changed files with 13 additions and 0 deletions
13
bot.py
13
bot.py
|
@ -1,10 +1,15 @@
|
|||
#!/usr/bin/env python3
|
||||
# encoding: utf-8
|
||||
|
||||
import random
|
||||
import asyncio
|
||||
import logging
|
||||
import os.path
|
||||
import traceback
|
||||
from glob import glob
|
||||
|
||||
import discord
|
||||
import aiofiles
|
||||
from discord.ext import commands
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
|
@ -26,6 +31,14 @@ class Bot(commands.AutoShardedBot):
|
|||
|
||||
async def on_ready(self):
|
||||
logger.info('Logged on as {0} (ID: {0.id})'.format(self.user))
|
||||
bot.loop.create_task(self.change_avatar_loop())
|
||||
|
||||
async def change_avatar_loop(self):
|
||||
while await asyncio.sleep(30*60, True):
|
||||
glob_pattern = os.path.join('avatars', '*')
|
||||
|
||||
async with aiofiles.open(random.choice(glob(glob_pattern)), 'rb') as f:
|
||||
await self.user.edit(avatar=await f.read())
|
||||
|
||||
# https://github.com/Rapptz/RoboDanny/blob/ca75fae7de132e55270e53d89bc19dd2958c2ae0/bot.py#L77-L85
|
||||
async def on_command_error(self, context, error):
|
||||
|
|
Loading…
Reference in a new issue