# Path: dozer/cogs/actionlogs.py
# class CustomJoinLeaveMessages(db.DatabaseTable):
#     """Holds custom join leave messages"""
#     __tablename__ = 'memberlogconfig'
#     __uniques__ = 'guild_id'
# 
#     @classmethod
#     async def initial_create(cls):
#         """Create the table in the database"""
#         async with db.Pool.acquire() as conn:
#             await conn.execute(f"""
#             CREATE TABLE {cls.__tablename__} (
#             guild_id bigint PRIMARY KEY NOT NULL,	            
#             memberlog_channel bigint NOT NULL,	   
#             name varchar NOT NULL
#             )""")
# 
#     def __init__(self, guild_id, channel_id=None, ping=None, join_message=None, leave_message=None):
#         super().__init__()
#         self.guild_id = guild_id
#         self.channel_id = channel_id
#         self.ping = ping
#         self.join_message = join_message
#         self.leave_message = leave_message
# 
#     @classmethod
#     async def get_by(cls, **kwargs):
#         results = await super().get_by(**kwargs)
#         result_list = []
#         for result in results:
#             obj = CustomJoinLeaveMessages(guild_id=result.get("guild_id"), channel_id=result.get("channel_id"),
#                                           ping=result.get("ping"),
#                                           join_message=result.get("join_message"),
#                                           leave_message=result.get("leave_message"))
#             result_list.append(obj)
#         return result_list
# 
#     async def version_1(self):
#         """DB migration v1"""
#         async with db.Pool.acquire() as conn:
#             await conn.execute(f"""
#             alter table memberlogconfig rename column memberlog_channel to channel_id;
#             alter table memberlogconfig alter column channel_id drop not null;
#             alter table {self.__tablename__} drop column IF EXISTS name;
#             alter table {self.__tablename__}
#                 add IF NOT EXISTS ping boolean default False;
#             alter table {self.__tablename__}
#                 add IF NOT EXISTS join_message text default null;
#             alter table {self.__tablename__}
#                 add IF NOT EXISTS leave_message text default null;
#             """)
# 
#     __versions__ = [version_1]
# 
# Path: dozer/bot.py
# DOZER_LOGGER = logging.getLogger('dozer')


import asyncio
import time
import typing
import discord
import discord.utils
from discord.ext.commands import cooldown, BucketType, has_permissions, BadArgument, guild_only
from discord_slash import cog_ext, SlashContext
from ._utils import *
from .actionlogs import CustomJoinLeaveMessages
from .. import db
from ..bot import DOZER_LOGGER
from ..db import *
            await self.del_from_message(message, reaction[0])
            await ReactionRole.delete(message_id=message.id, role_id=role.id)
        if menu:
            await self.update_role_menu(ctx, menu)

        e = discord.Embed(color=blurple)
        link = f"https://discordapp.com/channels/{ctx.guild.id}/{message.channel.id}/{message_id}"
        shortcut = f"[{menu.name}]({link})" if menu else f"[{message_id}]({link})"
        e.add_field(name='Success!', value=f"I removed {role.mention} from message {shortcut}")
        e.set_footer(text='Triggered by ' + ctx.author.display_name)
        await ctx.send(embed=e)

    delrole.example_usage = """
    -----To target a role menu use this format-----
    `{prefix}rolemenu delrole <message id> <@robots or "Robots">`
    -----To target a custom message use this format-----
    `{prefix}rolemenu delrole <channel> <message id> <@robots or "Robots">`
    """


class RoleMenu(db.DatabaseTable):
    """Contains a role menu, used for editing and initial create"""
    __tablename__ = 'role_menus'
    __uniques__ = 'message_id'

    @classmethod
    async def initial_create(cls):
        """Create the table in the database"""
        async with db.Pool.acquire() as conn:
            await conn.execute(f"""

# Path: dozer/cogs/actionlogs.py
# class CustomJoinLeaveMessages(db.DatabaseTable):
#     """Holds custom join leave messages"""
#     __tablename__ = 'memberlogconfig'
#     __uniques__ = 'guild_id'
# 
#     @classmethod
#     async def initial_create(cls):
#         """Create the table in the database"""
#         async with db.Pool.acquire() as conn:
#             await conn.execute(f"""
#             CREATE TABLE {cls.__tablename__} (
#             guild_id bigint PRIMARY KEY NOT NULL,	            
#             memberlog_channel bigint NOT NULL,	   
#             name varchar NOT NULL
#             )""")
# 
#     def __init__(self, guild_id, channel_id=None, ping=None, join_message=None, leave_message=None):
#         super().__init__()
#         self.guild_id = guild_id
#         self.channel_id = channel_id
#         self.ping = ping
#         self.join_message = join_message
#         self.leave_message = leave_message
# 
#     @classmethod
#     async def get_by(cls, **kwargs):
#         results = await super().get_by(**kwargs)
#         result_list = []
#         for result in results:
#             obj = CustomJoinLeaveMessages(guild_id=result.get("guild_id"), channel_id=result.get("channel_id"),
#                                           ping=result.get("ping"),
#                                           join_message=result.get("join_message"),
#                                           leave_message=result.get("leave_message"))
#             result_list.append(obj)
#         return result_list
# 
#     async def version_1(self):
#         """DB migration v1"""
#         async with db.Pool.acquire() as conn:
#             await conn.execute(f"""
#             alter table memberlogconfig rename column memberlog_channel to channel_id;
#             alter table memberlogconfig alter column channel_id drop not null;
#             alter table {self.__tablename__} drop column IF EXISTS name;
#             alter table {self.__tablename__}
#                 add IF NOT EXISTS ping boolean default False;
#             alter table {self.__tablename__}
#                 add IF NOT EXISTS join_message text default null;
#             alter table {self.__tablename__}
#                 add IF NOT EXISTS leave_message text default null;
#             """)
# 
#     __versions__ = [version_1]
# 
# Path: dozer/bot.py
# DOZER_LOGGER = logging.getLogger('dozer')


# Path: dozer/cogs/roles.py
import asyncio
import time
import typing
import discord
import discord.utils
from discord.ext.commands import cooldown, BucketType, has_permissions, BadArgument, guild_only
from discord_slash import cog_ext, SlashContext
from ._utils import *
from .actionlogs import CustomJoinLeaveMessages
from .. import db
from ..bot import DOZER_LOGGER
from ..db import *

            await self.del_from_message(message, reaction[0])
            await ReactionRole.delete(message_id=message.id, role_id=role.id)
        if menu:
            await self.update_role_menu(ctx, menu)

        e = discord.Embed(color=blurple)
        link = f"https://discordapp.com/channels/{ctx.guild.id}/{message.channel.id}/{message_id}"
        shortcut = f"[{menu.name}]({link})" if menu else f"[{message_id}]({link})"
        e.add_field(name='Success!', value=f"I removed {role.mention} from message {shortcut}")
        e.set_footer(text='Triggered by ' + ctx.author.display_name)
        await ctx.send(embed=e)

    delrole.example_usage = """
    -----To target a role menu use this format-----
    `{prefix}rolemenu delrole <message id> <@robots or "Robots">`
    -----To target a custom message use this format-----
    `{prefix}rolemenu delrole <channel> <message id> <@robots or "Robots">`
    """


class RoleMenu(db.DatabaseTable):
    """Contains a role menu, used for editing and initial create"""
    __tablename__ = 'role_menus'
    __uniques__ = 'message_id'

    @classmethod
    async def initial_create(cls):
        """Create the table in the database"""
        async with db.Pool.acquire() as conn:
            await conn.execute(f"""

            CREATE TABLE {cls.__tablename__} (