import discord
from discord.ext import commands, tasks
from utils.skypy import skypy
from utils.embed import Embed
from utils.util import get_user_guilds, is_verified
import copy

skypy.enable_advanced_mode()

rankColors = {'MVP++': 0xFFAA00,
                'MVP+': 0x00FFFF,
                'MVP': 0x00FFFF,
                'VIP+': 0x00FF00,
                'VIP': 0x00FF00}

async def update_all_guilds(bot, user, name, uuid):
    user_guilds = await get_user_guilds(bot, user)
    for guild in user_guilds:
        await update_guild(bot, guild, user, name, uuid)
        

async def update_guild(bot, guild, user, name, uuid):
    #banscammers
    try:
        doc = await bot.guilds_db["banscammers"].find_one({"_id": guild.id})
        if doc and doc["on"] and await bot.scammer_db["scammer_list"].find_one({"_id": uuid}) and await is_verified(bot, user):
            await guild.ban(user, reason="verified as scammer")
            return
    except (KeyError, discord.Forbidden):
        pass
        # if isinstance(e, discord.Forbidden):
 def __init__(self, bot):
     self.bot : commands.AutoShardedBot = bot
     self.connections = self.bot.users_db["connections"]
     skypy.enable_advanced_mode()