Ejemplo n.º 1
0
 async def role(self, ctx, *, role: str):
     """Set the role to be added to a user whne they join"""
     server = ctx.guild
     role = arg.get_role(ctx, role)
     if not role:
         return await ctx.send("I could not find that role :no_entry:")
     r.table("autorole").get(str(server.id)).update({
         "role": str(role.id)
     }).run(durability="soft")
     await ctx.send(
         "The autorole role is now **{}** <:done:403285928233402378>".
         format(role.name))
Ejemplo n.º 2
0
 async def _remove(self, ctx, message_id: int, *, role: str):
     """Removes an emote and role from the reaction role message"""
     serverdata = r.table("reactionrole").get(str(ctx.guild.id))
     role = arg.get_role(ctx, role)
     if not role:
         return await ctx.send("Invalid Role :no_entry:")
     if str(message_id) in serverdata["messages"].map(
             lambda x: x["id"]).run():
         message_db = serverdata["messages"].filter(
             lambda x: x["id"] == str(message_id))[0]
         message = await self.bot.get_channel(
             int(message_db["channel"].run())).get_message(message_id)
         if str(role.id) not in message_db["roles"].map(
                 lambda x: x["id"]).run():
             return await ctx.send(
                 "This role is not on this reaction role message :no_entry:"
             )
         else:
             role_db = message_db["roles"].filter(
                 lambda x: x["id"] == str(role.id))[0]
             emote_db = role_db["emote"].run()
             if emote_db.isdigit():
                 emote = self.bot.get_emoji(int(emote_db))
             else:
                 emote = emote_db
         s = message.embeds[0]
         content = "{}: {}\n\n".format(str(emote), "<@&{}>".format(role.id))
         try:
             before = s.description
             s.description = s.description.replace(content, "")
             if before == s.description:
                 content = "\n\n{}: {}".format(str(emote),
                                               "<@&{}>".format(role.id))
                 s.description = s.description.replace(content, "")
         except:
             pass
         await message.edit(embed=s)
         await message.remove_reaction(emote, ctx.me)
         role_db = {"id": str(role.id), "emote": emote_db}
         new_message = message_db.run()
         new_message["roles"].remove(role_db)
         message_new = serverdata["messages"].run()
         message_new.remove(message_db.run())
         message_new.append(new_message)
         await ctx.send(
             "The role `{}` has been removed from the reaction role".format(
                 role.name))
         serverdata.update({"messages": message_new}).run(durability="soft")
     else:
         return await ctx.send("Invalid Message :no_entry:")
Ejemplo n.º 3
0
 async def _add(self, ctx, message_id: int, emote: str, *, role: str):
     """Adds an emote and role to the reaction role message"""
     serverdata = r.table("reactionrole").get(str(ctx.guild.id))
     role = arg.get_role(ctx, role)
     if not role:
         return await ctx.send("Invalid Role :no_entry:")
     if str(message_id) in serverdata["messages"].map(
             lambda x: x["id"]).run():
         message_db = serverdata["messages"].filter(
             lambda x: x["id"] == str(message_id))[0]
         message = await self.bot.get_channel(
             int(message_db["channel"].run())).get_message(message_id)
         if not message:
             return await ctx.send(
                 "That message has been deleted :no_entry:")
         if str(role.id) in message_db["roles"].map(
                 lambda x: x["id"]).run():
             return await ctx.send(
                 "This role is already on this reaction role message :no_entry:"
             )
         s = message.embeds[0]
         if len(message.reactions) >= 20:
             return await ctx.send(
                 "This message has hit the reaction cap of 20 :no_entry:")
         if re_emoji.match(emote):
             if str(
                     re_emoji.match(emote).group(1)
             ) in message_db["roles"].map(lambda x: x["emote"]).run():
                 return await ctx.send(
                     "This emote is already being used in this reaction role message :no_entry:"
                 )
             emote = self.bot.get_emoji(int(re_emoji.match(emote).group(1)))
             if not emote:
                 return await ctx.send(
                     "I'm not able to use that emoji or It's Invalid :no_entry:"
                 )
             else:
                 emote_db = str(emote.id)
                 await message.add_reaction(emote)
         else:
             if emote in message_db["roles"].map(
                     lambda x: x["emote"]).run():
                 return await ctx.send(
                     "This emote is already being used in this reaction role message :no_entry:"
                 )
             try:
                 await message.add_reaction(emote)
                 emote_db = str(emote)
             except:
                 return await ctx.send("Inavlid Emoji :no_entry:")
         if not message_db["roles"].run():
             s.description = "{}: {}".format(str(emote), role.mention)
         else:
             s.description += "\n\n{}: {}".format(str(emote), role.mention)
         await message.edit(embed=s)
         role_db = {"id": str(role.id), "emote": emote_db}
         new_message = message_db.run()
         new_message["roles"].append(role_db)
         message_new = serverdata["messages"].run()
         message_new.remove(message_db.run())
         message_new.append(new_message)
         await ctx.send(
             "The role `{}` will now be given when reacting with {}".format(
                 role.name, emote))
         serverdata.update({"messages": message_new}).run(durability="soft")
     else:
         return await ctx.send(
             "That message is not a reaction role message :no_entry:")