|
|
@ -1,3 +1,4 @@
|
|
|
|
|
|
|
|
import logging
|
|
|
|
from typing import Union
|
|
|
|
from typing import Union
|
|
|
|
|
|
|
|
|
|
|
|
import discord
|
|
|
|
import discord
|
|
|
@ -5,7 +6,7 @@ from redbot.core import Config, checks, commands
|
|
|
|
from redbot.core.bot import Red
|
|
|
|
from redbot.core.bot import Red
|
|
|
|
from redbot.core.commands import Cog
|
|
|
|
from redbot.core.commands import Cog
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log = logging.getLogger("red.fox_v3.stealemoji")
|
|
|
|
# Replaced with discord.Asset.read()
|
|
|
|
# Replaced with discord.Asset.read()
|
|
|
|
# async def fetch_img(session: aiohttp.ClientSession, url: StrOrURL):
|
|
|
|
# async def fetch_img(session: aiohttp.ClientSession, url: StrOrURL):
|
|
|
|
# async with session.get(url) as response:
|
|
|
|
# async with session.get(url) as response:
|
|
|
@ -45,7 +46,13 @@ class StealEmoji(Cog):
|
|
|
|
super().__init__()
|
|
|
|
super().__init__()
|
|
|
|
self.bot = red
|
|
|
|
self.bot = red
|
|
|
|
self.config = Config.get_conf(self, identifier=11511610197108101109111106105)
|
|
|
|
self.config = Config.get_conf(self, identifier=11511610197108101109111106105)
|
|
|
|
default_global = {"stolemoji": {}, "guildbanks": [], "on": False, "notify": 0, "generate": False}
|
|
|
|
default_global = {
|
|
|
|
|
|
|
|
"stolemoji": {},
|
|
|
|
|
|
|
|
"guildbanks": [],
|
|
|
|
|
|
|
|
"on": False,
|
|
|
|
|
|
|
|
"notify": 0,
|
|
|
|
|
|
|
|
"autobank": False,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
self.config.register_global(**default_global)
|
|
|
|
self.config.register_global(**default_global)
|
|
|
|
|
|
|
|
|
|
|
@ -126,6 +133,17 @@ class StealEmoji(Cog):
|
|
|
|
|
|
|
|
|
|
|
|
await ctx.maybe_send_embed("Collection is now " + str(not curr_setting))
|
|
|
|
await ctx.maybe_send_embed("Collection is now " + str(not curr_setting))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@checks.is_owner()
|
|
|
|
|
|
|
|
@stealemoji.command(name="autobank")
|
|
|
|
|
|
|
|
async def se_autobank(self, ctx):
|
|
|
|
|
|
|
|
"""Toggles automatically creating new guilds as emoji banks"""
|
|
|
|
|
|
|
|
curr_setting = await self.config.autobank()
|
|
|
|
|
|
|
|
await self.config.autobank.set(not curr_setting)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.is_on = await self.config.autobank()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await ctx.maybe_send_embed("AutoBanking is now " + str(not curr_setting))
|
|
|
|
|
|
|
|
|
|
|
|
@checks.is_owner()
|
|
|
|
@checks.is_owner()
|
|
|
|
@commands.guild_only()
|
|
|
|
@commands.guild_only()
|
|
|
|
@stealemoji.command(name="bank")
|
|
|
|
@stealemoji.command(name="bank")
|
|
|
@ -205,10 +223,18 @@ class StealEmoji(Cog):
|
|
|
|
break
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
if guildbank is None:
|
|
|
|
if guildbank is None:
|
|
|
|
if await self.config.generate():
|
|
|
|
if await self.config.autobank():
|
|
|
|
guild_template = await self.bot.fetch_template("https://discord.new/S93bqTqKQ9rM")
|
|
|
|
try:
|
|
|
|
guildbank: discord.Guild = await self.bot.create_guild("StealEmoji Guildbank", code=guild_template)
|
|
|
|
guildbank: discord.Guild = await self.bot.create_guild(
|
|
|
|
await self.bot.send_to_owners(guildbank.channels)
|
|
|
|
"StealEmoji Guildbank", code="S93bqTqKQ9rM"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
except discord.HTTPException:
|
|
|
|
|
|
|
|
await self.config.autobank.set(False)
|
|
|
|
|
|
|
|
log.exception("Unable to create guilds, disabling autobank")
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
invite = await guildbank.text_channels[0].create_invite()
|
|
|
|
|
|
|
|
await self.bot.send_to_owners(invite)
|
|
|
|
|
|
|
|
log.info(f"Guild created id {guildbank.id}. Invite: {invite}")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|