From 4a9f0b9e7459b2423a5835c26b7505f56b6f18c0 Mon Sep 17 00:00:00 2001 From: bobloy Date: Wed, 19 Aug 2020 18:14:56 -0400 Subject: [PATCH] Template guilds --- stealemoji/stealemoji.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/stealemoji/stealemoji.py b/stealemoji/stealemoji.py index b1c7de5..70fc644 100644 --- a/stealemoji/stealemoji.py +++ b/stealemoji/stealemoji.py @@ -1,3 +1,5 @@ +from typing import Union + import discord from redbot.core import Config, checks, commands from redbot.core.bot import Red @@ -43,7 +45,7 @@ class StealEmoji(Cog): super().__init__() self.bot = red self.config = Config.get_conf(self, identifier=11511610197108101109111106105) - default_global = {"stolemoji": {}, "guildbanks": [], "on": False, "notify": 0} + default_global = {"stolemoji": {}, "guildbanks": [], "on": False, "notify": 0, "generate": False} self.config.register_global(**default_global) @@ -193,7 +195,7 @@ class StealEmoji(Cog): # This is now a custom emoji that the bot doesn't have access to, time to steal it # First, do I have an available guildbank? - guildbank = None + guildbank: Union[discord.Guild, None] = None banklist = await self.config.guildbanks() for guild_id in banklist: guild: discord.Guild = self.bot.get_guild(guild_id) @@ -203,9 +205,12 @@ class StealEmoji(Cog): break if guildbank is None: - # print("No guildbank to store emoji") - # Eventually make a new banklist - return + if await self.config.generate(): + guild_template = await self.bot.fetch_template("https://discord.new/S93bqTqKQ9rM") + guildbank: discord.Guild = await self.bot.create_guild("StealEmoji Guildbank", code=guild_template) + await self.bot.send_to_owners(guildbank.channels) + else: + return # Next, have I saved this emoji before (because uploaded emoji != orignal emoji)