Exemplo n.º 1
0
 async def role(self, ctx, color, *, role_name):
     member = ctx.author
     role_lock = get(ctx.guild.roles,
                     id=getops(ctx.guild.id, "roles", "customRoleLock"))
     if role_lock in member.roles or role_lock == None:
         try:
             result = getops(ctx.guild.id, "customRoles", str(member.id))
         except KeyError:
             result = None
         hex_code_match = search(r"(?:[0-9a-fA-F]{3}){1,2}$", color)
         if result and ctx.guild.get_role(int(result)):
             if hex_code_match:
                 role = ctx.guild.get_role(int(result))
                 await role.edit(name=role_name,
                                 color=discord.Color(int(color, 16)))
                 await member.add_roles(role)
                 await ctx.send(f"Role {role.mention} edited.")
             else:
                 await ctx.send(f"Invalid hex code `{color}`.")
         else:
             if hex_code_match:
                 role_color = discord.Color(int(color, 16))
                 role = await ctx.guild.create_role(name=role_name,
                                                    colour=role_color)
                 await member.add_roles(role)
                 updop(ctx.guild.id, "customRoles", str(member.id),
                       str(role.id))
                 await ctx.send(f"Role {role.mention} created and given.")
             else:
                 await ctx.send("Invalid hex code.")
     else:
         await ctx.send(
             f"{member.mention}, this is only for users with the {role_lock} role."
         )
Exemplo n.º 2
0
 async def toggle_option(self, ctx, option, disable_message,
                         enable_message):
     status = getops(ctx.guild.id, "toggles", option)
     updop(ctx.guild.id, "toggles", option, not status)
     if status:
         await ctx.send(disable_message)
     else:
         await ctx.send(enable_message)
Exemplo n.º 3
0
 async def del_censor(self, ctx, word):
     all_bads = getops(ctx.guild.id, "censorList")
     word = word.lower()
     if word not in all_bads:
         await ctx.send("That word is not in the filter.")
     else:
         all_bads.remove(word)
         all_bads.sort()
         updop(ctx.guild.id, "lists", "censorList", all_bads)
         await ctx.send("Word removed from the filter.")
Exemplo n.º 4
0
 async def add_censor(self, ctx, word):
     all_bads = getops(ctx.guild.id, "censorList")
     word = word.lower()
     if word in all_bads:
         await ctx.send("That word is already in the filter.")
     else:
         all_bads.append(word)
         all_bads.sort()
         updop(ctx.guild.id, "lists", "censorList", all_bads)
         await ctx.send("Word added to the filter.")
Exemplo n.º 5
0
 async def wipe_censor(self, ctx):
     if not self.wipe_censor_confirm:
         await ctx.send(
             "Are you *really* sure you want to wipe the filter? Type the command again to confirm. This will expire in 10 seconds."
         )
         self.wipe_censor_confirm = True
         await sleep(10)
         if self.wipe_censor_confirm:
             self.wipe_censor_confirm = False
             await ctx.send("Pending wipe expired.")
     elif self.wipe_censor_confirm:
         updop(ctx.guild.id, "lists", "censorList", [])
         await ctx.send("Filter wiped.")
         self.wipe_censor_confirm = False
Exemplo n.º 6
0
 async def change_goodbye_message(self, ctx, *, message: str):
     updop(ctx.guild.id, "messages", "goodbyeMessage", message)
     await ctx.send(f'Goodbye message set to "{message}".')
Exemplo n.º 7
0
 async def change_welcome_message(self, ctx, *, message: str):
     updop(ctx.guild.id, "messages", "welcomeMessage", message)
     await ctx.send(f'Welcome message set to "{message}".')
Exemplo n.º 8
0
 async def change_welcome_channel(self, ctx, *,
                                  channel: discord.TextChannel):
     updop(ctx.guild.id, "channels", "welcomeChannel", channel.id)
     await ctx.send(f"Channel {channel} is now the welcome channel.")
Exemplo n.º 9
0
 async def change_suggestions_channel(self, ctx, *,
                                      channel: discord.TextChannel):
     updop(ctx.guild.id, "channels", "suggestionsChannel", channel.id)
     await ctx.send(f"Channel {channel} is now the suggestions channel.")
Exemplo n.º 10
0
 async def change_mute_role(self, ctx, *, role: discord.Role):
     updop(ctx.guild.id, "roles", "muteRole", role.id)
     await ctx.send(f"Role {role} is now set as the muted role.")
Exemplo n.º 11
0
 async def change_required_role(self, ctx, *, role: discord.Role):
     updop(ctx.guild.id, "roles", "customRoleLock", role.id)
     await ctx.send(f"Role {role} is now required for custom roles.")