import discord
from discord.ext import commands
from dep import is_dev_or_admin
from dep import is_owner_or_admin


class Roles:
    def __init__(self, bot):
        self.bot = bot

    @commands.command()
    @commands.guild_only()
    @commands.check(is_dev_or_admin)
    async def nick(self, ctx, nick,  member: discord.Member):
        """veranderd iemands naampje"""
        await member.edit(nick=nick, reason='Gewoon omdat het kan')
        await ctx.send(f"{member.name} z'n naam is nu {nick}")

    @commands.command()
    @commands.guild_only()
    @commands.check(is_owner_or_admin)
    async def ban(self, ctx, member: discord.Member):
        """dropt een ban op een anime-hater"""
        await member.ban()
        await ctx.send('Baka!')

    @commands.command()
    @commands.guild_only()
    @commands.check(is_owner_or_admin)
    async def kick(self, ctx, member: discord.Member):
        """trapt iemand deze zeer educatiefe plek uit"""
        await member.kick()
        await ctx.send('Baka!')

    @commands.command()
    @commands.guild_only()
    @commands.check(is_dev_or_admin)
    async def kousloos(self, ctx, member: discord.Member, reason="hij/zij is een pannenkoek"):
        """neemt iemands kousjes weg"""
        kousloos_c = discord.utils.get(ctx.guild.channels, name="kouslozingen")
        role = discord.utils.get(ctx.guild.roles, name="Kousloos")
        user_roles = member.roles
        if role in user_roles:
            await ctx.send(f'{member.display_name} is al kousloos')
            return
        else:
            await member.add_roles(role, reason=reason)
            await kousloos_c.send(f'{member.display_name} is gekousloost want {reason}')


def setup(bot):
    bot.add_cog(Roles(bot))
