-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9eb0570
commit 8995913
Showing
4 changed files
with
43 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import random | ||
|
||
from classes.bot import CustomClient | ||
from disnake.ext import commands, tasks | ||
from utility.constants import BADGE_GUILDS | ||
|
||
class EmojiRefresh(commands.Cog): | ||
|
||
def __init__(self, bot: CustomClient): | ||
self.bot = bot | ||
self.refresh.start() | ||
|
||
@tasks.loop(seconds=600) | ||
async def refresh(self): | ||
emoji_map = {} | ||
for guild_id in BADGE_GUILDS: | ||
guild = await self.bot.getch_guild(guild_id) | ||
if guild is not None: | ||
while len(guild.emojis) >= 46: | ||
num_to_delete = random.randint(1, 5) | ||
for emoji in guild.emojis[:num_to_delete]: | ||
await guild.delete_emoji(emoji=emoji) | ||
for emoji in guild.emojis: | ||
emoji_map[emoji.name] = f"<:{emoji.name}:{emoji.id}>" | ||
self.bot.clan_badge_emoji_map = emoji_map | ||
|
||
|
||
def setup(bot: CustomClient): | ||
bot.add_cog(EmojiRefresh(bot)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters