Forgot info file and errors

Signed-off-by: Bobloy <alboblexloy@gmail.com>
pull/5/head
Bobloy 7 years ago
parent 0e991dc81e
commit dc1cc2f0d2

@ -0,0 +1,20 @@
{
"author": [
"Bobloy"
],
"bot_version": [
3,
0,
0
],
"description": "Steals custom emojis the bot sees and moves them to an emoji server",
"hidden": true,
"install_msg": "Thank you for installing StealEmoji",
"requirements": [],
"short": "Steals custom emojis",
"tags": [
"bobloy",
"utils",
"emoji"
]
}

@ -1,18 +1,11 @@
import asyncio
import aiohttp import aiohttp
from urllib.parse import urlparse
import os
from typing import List, Union
import discord import discord
from discord.ext import commands from discord.ext import commands
from redbot.core import Config from redbot.core import Config, RedContext
from redbot.core.bot import Red from redbot.core.bot import Red
# from redbot.core import data_manager
async def fetch_img(session, url): async def fetch_img(session, url):
with aiohttp.Timeout(10): with aiohttp.Timeout(10):
@ -26,15 +19,6 @@ class StealEmoji:
This cog steals emojis and creates servers for them This cog steals emojis and creates servers for them
""" """
def __init__(self, red: Red):
self.bot = red
self.config = Config.get_conf(self, identifier=11511610197108101109111106105)
default_global = {
"stolemoji": {},
"guildbanks": [],
"on": False
}
default_stolemoji = { default_stolemoji = {
"guildbank": None, "guildbank": None,
"name": None, "name": None,
@ -45,10 +29,19 @@ class StealEmoji:
"animated": False "animated": False
} }
def __init__(self, red: Red):
self.bot = red
self.config = Config.get_conf(self, identifier=11511610197108101109111106105)
default_global = {
"stolemoji": {},
"guildbanks": [],
"on": False
}
self.config.register_global(**default_global) self.config.register_global(**default_global)
@commands.group() @commands.group()
async def stealemoji(self, ctx: commands.Context): async def stealemoji(self, ctx: RedContext):
""" """
Base command for this cog. Check help for the commands list. Base command for this cog. Check help for the commands list.
""" """
@ -58,9 +51,9 @@ class StealEmoji:
@stealemoji.command(name="collect") @stealemoji.command(name="collect")
async def se_collect(self, ctx): async def se_collect(self, ctx):
"""Toggles whether emoji's are collected or not""" """Toggles whether emoji's are collected or not"""
currSetting = await self.config.on() curr_setting = await self.config.on()
await self.config.on.set(not currSetting) await self.config.on.set(not curr_setting)
await ctx.send("Collection is now "+str(not currSetting)) await ctx.send("Collection is now " + str(not curr_setting))
@stealemoji.command(name="bank") @stealemoji.command(name="bank")
async def se_bank(self, ctx): async def se_bank(self, ctx):
@ -100,7 +93,6 @@ class StealEmoji:
# This is now a custom emoji that the bot doesn't have access to, time to steal it # 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? # First, do I have an available guildbank?
guildbank = None guildbank = None
banklist = await self.config.guildbanks() banklist = await self.config.guildbanks()
for guild_id in banklist: for guild_id in banklist:
@ -135,15 +127,14 @@ class StealEmoji:
# f.write(img) # f.write(img)
# urllib.urlretrieve(emoji.url, emoji.name+ext) # urllib.urlretrieve(emoji.url, emoji.name+ext)
try: try:
await guildbank.create_custom_emoji(name=emoji.name, image=img, reason="Stole from " + str(user)) await guildbank.create_custom_emoji(name=emoji.name, image=img, reason="Stole from " + str(user))
except Forbidden as e: except discord.Forbidden as e:
print("PermissionError - no permission to add emojis") print("PermissionError - no permission to add emojis")
raise PermissionError("No permission to add emojis") from e raise PermissionError("No permission to add emojis") from e
except HTTPException: except discord.HTTPException as e:
print("HTTPException exception") print("HTTPException exception")
raise HTTPException # Unhandled error raise e # Unhandled error
# If you get this far, YOU DID IT # If you get this far, YOU DID IT
@ -163,4 +154,3 @@ class StealEmoji:
# owner = await self.bot.application_info() # owner = await self.bot.application_info()
# owner = owner.owner # owner = owner.owner
# await owner.send("Just added emoji "+str(emoji)+" to server "+str(guildbank)) # await owner.send("Just added emoji "+str(emoji)+" to server "+str(guildbank))

Loading…
Cancel
Save