diff --git a/cogs/sar.py b/cogs/sar.py new file mode 100644 index 0000000..4feda4a --- /dev/null +++ b/cogs/sar.py @@ -0,0 +1,48 @@ +import config +from discord.ext import commands +from discord.ext.commands import Cog +from helpers.checks import check_if_staff_or_ot + + +class SAR(Cog): + def __init__(self, bot): + self.bot = bot + + @commands.guild_only() + @commands.command() + @commands.check(check_if_staff_or_ot) + async def sar(self, ctx, role: str): + """Gets you a self assignable role.""" + return await ctx.send( + "Self assignable roles in this guild: " + + ",".join(config.self_assignable_roles) + + f"\nRun {config.prefixes[0]}iam role_name_goes_here to get or remove one." + ) + + @commands.cooldown(1, 30, type=commands.BucketType.user) + @commands.guild_only() + @commands.command(aliases=["iamnot"]) + @commands.check(check_if_staff_or_ot) + async def iam(self, ctx, role: str): + """Gets you a self assignable role.""" + if role not in config.self_assignable_roles: + return await ctx.send( + "There's no self assignable role with that name. Run .sar to see what you can self assign." + ) + + target_role = ctx.guild.get_role(config.self_assignable_roles[role]) + + if target_role in ctx.author.roles: + await ctx.author.remove_roles(target_role, reason=str(ctx.author)) + await ctx.send( + f"{ctx.author.mention}: Successfully removed your `{role}` role. Run the command again if you want to add it again." + ) + else: + await ctx.author.add_roles(target_role, reason=str(ctx.author)) + await ctx.send( + f"{ctx.author.mention}: Successfully gave you the `{role}` role. Run the command again if you want to remove it." + ) + + +def setup(bot): + bot.add_cog(SAR(bot)) diff --git a/config_template.py b/config_template.py index b662def..cc5bc6f 100644 --- a/config_template.py +++ b/config_template.py @@ -135,19 +135,19 @@ suspect_words = [ "tx", # piracy-enabling cfw "reinx", # piracy-enabling cfw "gomanx", # piracy-enabling cfw - "neutos", # piracy-enabling cfw - "underpack", # piracy-enabling cfw - "underos", # piracy-enabling cfw + "neutos", # piracy-enabling cfw + "underpack", # piracy-enabling cfw + "underos", # piracy-enabling cfw "tinfoil", # title manager "dz", # title manager "goldleaf", # potential title manager "lithium", # title manager "cracked", # older term for pirated games "xci", # "backup" format - "xcz", # "backup" format + "xcz", # "backup" format "nsz", # "backup" format - "hbg", # piracy source - "jits", # piracy source + "hbg", # piracy source + "jits", # piracy source ] # List of words that will be ignored if they match one of the @@ -311,3 +311,8 @@ list_files_channel = 0 # == Only if you want to use cogs.lists == # Channels that are lists that are controlled by the lists cog. list_channels = [] + +# == Only if you want to use cogs.sar == +self_assignable_roles = { + "streamnotifs": 715158689060880384, +}