Example #1
0
 async def list_rooli(self, context):
     """Lists all ranks."""
     m = context.message
     u = m.author
     if u.guild_permissions.manage_roles:
         s = ""
         for name in db_handler.get_flairs():
             s += name + ":\t" + str(len(user_list(
                 name, m.guild))) + " käyttäjää\n"
         await context.send(s.strip() if s is not "" else "/")
     else:
         await context.send(
             "You don't have permission to use this command.")
Example #2
0
 async def rooli(self, context):
     """Gives the user the requested role (if on rank list)"""
     m = context.message
     u = m.author
     pos = m.content.find(" ")
     if pos > 0:
         name = m.content[pos:].strip()
         role = discord.utils.get(m.guild.roles, name=name)
         if name in db_handler.get_flairs():
             await u.add_roles(role)
             await context.send("Liityit rooliin {}.".format(role.name))
         else:
             await context.send("Ei roolia nimeltä {}!".format(name))
     else:
         await context.send("Kerro roolin nimi")
Example #3
0
 async def poistu(self, context):
     """Removes requested role from user."""
     m = context.message
     u = m.author
     pos = m.content.find(" ")
     if pos > 0:
         name = m.content[pos:].strip()
         role = discord.utils.get(m.guild.roles, name=name)
         if role in u.roles and name in db_handler.get_flairs():
             await u.remove_roles(role)
             await context.send("Poistuit roolista {}.".format(
                 role.name))
         else:
             await context.send("Ei roolia nimeltä {}!".format(name))
     else:
         await context.send("Kerro roolin nimi")
Example #4
0
 async def remove_rooli(self, context):
     """Removes a role from allowed ranks, without deleting the role.
     Only usable with manage roles permission."""
     m = context.message
     u = m.author
     if u.guild_permissions.manage_roles:
         pos = m.content.find(" ")
         if pos > 0:
             name = m.content[pos:].strip()
             if name in db_handler.get_flairs():
                 await context.send("Removed role {}.".format(name))
                 db_handler.remove_flair(name)
             else:
                 await context.send("This is not a valid role.")
         else:
             await context.send("Please provide a name.")
     else:
         await context.send(
             "You don't have permission to use this command.")
Example #5
0
 async def delete_rooli(self, context):
     """Deletes a role in allowed ranks.
     Only usable with manage roles permission."""
     m = context.message
     u = m.author
     if u.guild_permissions.manage_roles:
         pos = m.content.find(" ")
         if pos > 0:
             name = m.content[pos:].strip()
             if name in db_handler.get_flairs():
                 role = discord.utils.get(m.guild.roles, name=name)
                 await context.send("Deleted role {}.".format(name))
                 db_handler.remove_flair(name)
                 await role.delete()
             else:
                 await context.send("This is not a valid role.")
         else:
             await context.send("Please provide a name.")
     else:
         await context.send(
             "You don't have permission to use this command.")