|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
import asyncio
|
|
|
|
|
import aiohttp
|
|
|
|
|
|
|
|
|
|
from urllib.parse import urlparse
|
|
|
|
|
|
|
|
|
@ -62,17 +63,18 @@ class StealEmoji:
|
|
|
|
|
await self.config.on.set(not currSetting)
|
|
|
|
|
await ctx.send("Collection is now "+str(not currSetting))
|
|
|
|
|
|
|
|
|
|
@stealemoji.command(name="bank")
|
|
|
|
|
async def se_bank(self, ctx):
|
|
|
|
|
"""Add current server as emoji bank"""
|
|
|
|
|
await ctx.send("This will upload custom emojis to this server\n"
|
|
|
|
|
"Are you sure you want to make the current server an emoji bank? (y/n)"
|
|
|
|
|
"Are you sure you want to make the current server an emoji bank? (y/n)")
|
|
|
|
|
|
|
|
|
|
def check(m):
|
|
|
|
|
return upper(m.content) in ["Y","YES","N","NO"] and m.channel == ctx.channel and m.author == ctx.author
|
|
|
|
|
return m.content.upper() in ["Y","YES","N","NO"] and m.channel == ctx.channel and m.author == ctx.author
|
|
|
|
|
|
|
|
|
|
msg = await client.wait_for('message', check=check)
|
|
|
|
|
msg = await self.bot.wait_for('message', check=check)
|
|
|
|
|
|
|
|
|
|
if msg.content in ["N","NO"]
|
|
|
|
|
if msg.content in ["N","NO"]:
|
|
|
|
|
await ctx.send("Cancelled")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
@ -84,13 +86,16 @@ class StealEmoji:
|
|
|
|
|
async def on_reaction_add(self, reaction: discord.Reaction, user: discord.User):
|
|
|
|
|
"""Event handler for reaction watching"""
|
|
|
|
|
if not reaction.custom_emoji:
|
|
|
|
|
print("Not a custom emoji")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if not (await self.config.on()):
|
|
|
|
|
print("Collecting is off")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
emoji = reaction.emoji
|
|
|
|
|
if emoji in self.bot.emojis:
|
|
|
|
|
print("Emoji already in bot.emojis")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
# This is now a custom emoji that the bot doesn't have access to, time to steal it
|
|
|
|
@ -106,6 +111,7 @@ class StealEmoji:
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
if guildbank is None:
|
|
|
|
|
print("No guildbank to store emoji")
|
|
|
|
|
# Eventually make a new banklist
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
@ -114,13 +120,15 @@ class StealEmoji:
|
|
|
|
|
stolemojis = await self.config.stolemoji()
|
|
|
|
|
|
|
|
|
|
if emoji.id in stolemojis:
|
|
|
|
|
print("Emoji has already been stolen")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
# Alright, time to steal it for real
|
|
|
|
|
path = urlparse(emoji.url).path
|
|
|
|
|
ext = os.path.splitext(path)[1]
|
|
|
|
|
|
|
|
|
|
img = await fetch_img(emoji.url)
|
|
|
|
|
async with aiohttp.ClientSession() as session:
|
|
|
|
|
img = await fetch_img(session, emoji.url)
|
|
|
|
|
|
|
|
|
|
with open("\\cogs\\stealemoji\\"+emoji.name+ext, "wb") as f:
|
|
|
|
|
f.write(img)
|
|
|
|
|