Ejemplo n.º 1
0
    async def autorole_add(self,
                           ctx,
                           role: typing.Optional[discord.Role] = None):
        if not role:
            message = rockutils._(
                "No {format} was mentioned. Either mention it, provide the id or name. If you are using the name, make sure you cover it in quotes like: `\"{format} name\"`",
                ctx).format(format="role")
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)

        rules = ctx.guildinfo['ar']['r']
        rules.append(str(role.id))
        success = await self.bot.update_info(ctx, ["r.r", rules])

        if success:
            message = rockutils._("{key} has been successfully {value}",
                                  ctx).format(key=role.name, value="added")
            return await ctx.send(f"{self.bot.get_emote('check')}  | " +
                                  message)
        else:
            message = rockutils._(
                "There was a problem when saving changes. Please try again",
                ctx)
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)
Ejemplo n.º 2
0
    async def tempchannel_purge(self, ctx):
        category = discord.utils.get(ctx.guild.channels,
                                     id=int(ctx.guildinfo['tc']['c'] or 0))
        if not category:
            message = rockutils._("The {key} set no longer exists",
                                  ctx).format(key="tempchannel category")
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)

        try:
            purged = 0
            for channel in category.channels:
                if isinstance(channel, discord.VoiceChannel):
                    if len(channel.members) == 0:
                        await channel.delete(
                            reason=f"Tempchannel Purge requested by {ctx.author}"
                        )
                        purged += 1
            message = rockutils._("{value} channel(s) have been purged",
                                  ctx).format(value=purged)
            return await ctx.send(f"{self.bot.get_emote('check')}  | " +
                                  message)
        except Exception as e:
            message = rockutils._(
                "A problem has occured during this operation: {error}",
                ctx).format(error=str(e))
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)
Ejemplo n.º 3
0
    async def guild_blacklist_add(self,
                                  ctx,
                                  channel: typing.Optional[
                                      discord.TextChannel] = None):
        if not channel:
            message = rockutils._(
                "No {format} was mentioned. Either mention it, provide the id or name. If you are using the name, make sure you cover it in quotes like: `\"{format} name\"`",
                ctx).format(format="text channel")
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)

        if str(channel.id) not in ctx.guildinfo['ch']['b']['c']:
            ctx.guildinfo['ch']['b']['c'].append(str(channel.id))

        success = await self.bot.update_info(
            ctx, ["ch.w.c", ctx.guildinfo['ch']['b']['c']])
        if success:
            message = rockutils._("{value} has been added to {key}",
                                  ctx).format(key="Channel Blacklist",
                                              value=channel.mention)
            return await ctx.send(f"{self.bot.get_emote('check')}  | " +
                                  message)
        else:
            message = rockutils._(
                "There was a problem when saving changes. Please try again",
                ctx)
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)
Ejemplo n.º 4
0
    async def staff_add(self,
                        ctx,
                        member: typing.Optional[discord.Member] = None):
        if not member:
            message = rockutils._(
                "No {target}, which is required, was specified",
                ctx).format(target="member")
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)

        staff = ctx.guildinfo['st']['u']
        staff = list(filter(lambda o: o[0] != str(member.id), staff))
        staff.append([str(member.id), True])
        success = await self.bot.update_info(ctx, ["st.u", staff])
        if success:
            message = rockutils._("{key} has been successfully {value}",
                                  ctx).format(key=str(member), value="added")
            return await ctx.send(f"{self.bot.get_emote('check')}  | " +
                                  message)
        else:
            message = rockutils._(
                "There was a problem when saving changes. Please try again",
                ctx)
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)
Ejemplo n.º 5
0
    async def guild_changeprefix(self, ctx, name="+"):
        name = name.strip() or "+"

        if len(name) == 0:
            message = rockutils._(
                "Invalid argument for `{argument_name}`. Expected `{expects}` but received `{received}`",
                ctx).format(argument_name="prefix",
                            expects="string",
                            received=name)
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)

        success = await self.bot.update_info(ctx, ["d.b.p", name])
        if success:
            message = rockutils._(
                "{key} has been successfully changed to `{value}`",
                ctx).format(key="Prefix", value=name)
            return await ctx.send(f"{self.bot.get_emote('check')}  | " +
                                  message)
        else:
            message = rockutils._(
                "There was a problem when saving changes. Please try again",
                ctx)
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)
Ejemplo n.º 6
0
    async def automod_regex_add(self, ctx, *, message=None):
        if not message:
            message = rockutils._(
                "No {target}, which is required, was specified",
                ctx).format(target="rule")
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)

        try:
            re.compile(message)
        except Exception as e:
            message = rockutils._(
                "Encountered an error whilst checking your regex. Use <{site}> and set the flavour to python to test out the regex the bot will use\n```{error}```",
                ctx).format(site="https://regex101.com/", error=str(e))
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)

        rules = ctx.guildinfo['am']['r']
        rules.append(message)
        success = await self.bot.update_info(ctx, ["am.r", rules])
        if success:
            message = rockutils._("{key} has been successfully {value}",
                                  ctx).format(key="Rule", value="added")
            return await ctx.send(f"{self.bot.get_emote('check')}  | " +
                                  message)
        else:
            message = rockutils._(
                "There was a problem when saving changes. Please try again",
                ctx)
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)
Ejemplo n.º 7
0
    async def borderwall_setmessage(self, ctx, mtype=None, *, message=None):
        if mtype is not None:
            mtype = mtype.lower()

        if mtype not in ['verify', 'verified']:
            message = rockutils._(
                "Invalid argument for `{argument_name}`. Expected `{expects}` but received `{received}`",
                ctx).format(
                    argument_name="message type",
                    expects="verify, verified",
                    received=mtype)
            return await ctx.send(f"{self.bot.get_emote('alert')}  | " + message)

        if not message:
            message = rockutils._(
                "No {target}, which is required, was specified",
                ctx).format(
                    target="message")
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " + message)

        key = "bw.mv" if mtype == "verified" else "bw.m"
        success = await self.bot.update_info(ctx, [key, message])
        if success:
            message = rockutils._(
                "{key} has been successfully set to {value}",
                ctx).format(
                    key=f"{'Verified' if mtype == 'verified' else 'Verify'} message",
                    value=message)
            return await ctx.send(f"{self.bot.get_emote('check')}  | " + message)
        else:
            message = rockutils._(
                "There was a problem when saving changes. Please try again", ctx)
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " + message)
Ejemplo n.º 8
0
    async def guild_setlocale(self, ctx, name="en-gb"):
        locales = os.listdir("locale")
        name = name.lower()

        if name not in locales:
            message = rockutils._(
                "Invalid argument for `{argument_name}`. Expected `{expects}` but received `{received}`",
                ctx).format(argument_name="locale",
                            expects=", ".join(locales),
                            received=name)
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)

        success = await self.bot.update_info(ctx, ["d.b.l", name])
        if success:
            message = rockutils._(
                "{key} has been successfully changed to `{value}`",
                ctx).format(key="Locale", value=name)
            return await ctx.send(f"{self.bot.get_emote('check')}  | " +
                                  message)
        else:
            message = rockutils._(
                "There was a problem when saving changes. Please try again",
                ctx)
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)
Ejemplo n.º 9
0
    async def guild_whitelist_remove(self,
                                     ctx,
                                     channel: typing.Union[discord.TextChannel,
                                                           int] = None):
        if not channel:
            message = rockutils._(
                "No {format} was mentioned. Either mention it, provide the id or name. If you are using the name, make sure you cover it in quotes like: `\"{format} name\"`",
                ctx).format(format="text channel")
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)

        if isinstance(channel, discord.TextChannel):
            _id = str(channel.id)
            channel = channel.mention
        else:
            _id = str(channel)

        if _id in ctx.guildinfo['ch']['w']['c']:
            ctx.guildinfo['ch']['w']['c'].remove(_id)

        success = await self.bot.update_info(
            ctx, ["ch.w.c", ctx.guildinfo['ch']['w']['c']])
        if success:
            message = rockutils._("{value} has been removed from {key}",
                                  ctx).format(key="Channel Whitelist",
                                              value=channel)
            return await ctx.send(f"{self.bot.get_emote('check')}  | " +
                                  message)
        else:
            message = rockutils._(
                "There was a problem when saving changes. Please try again",
                ctx)
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)
Ejemplo n.º 10
0
    async def welcomer_test(self,
                            ctx,
                            member: typing.Optional[discord.Member] = None):
        if not member:
            member = ctx.author

        if not ("Worker" in self.bot.cogs
                and hasattr(self.bot.cogs['Worker'], "execute_leaver")):
            message = rockutils._(
                "A problem has occured during this operation: {error}",
                ctx).format(
                    error="Could not find leaver executor in worker cog")
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)

        try:
            await self.bot.cogs['Worker'].execute_leaver(member, ctx.guild.id)
            message = rockutils._("Operation completed successfully", ctx)
            return await ctx.send(f"{self.bot.get_emote('check')}  | " +
                                  message)
        except Exception as e:
            exc_info = sys.exc_info()
            traceback.print_exception(*exc_info)
            message = rockutils._(
                "A problem has occured during this operation: {error}",
                ctx).format(error=str(e))
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)
Ejemplo n.º 11
0
    async def rules_remove(self, ctx, number: typing.Optional[int] = None):
        if number is None:
            message = rockutils._(
                "No {target}, which is required, was specified",
                ctx).format(
                    target="rule number")
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " + message)

        rules = ctx.guildinfo['r']['r']

        if number < 1 or number > len(rules):
            message = rockutils._(
                "Invalid {format} specified",
                ctx).format(
                    format="rule number")
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " + message)

        rules.remove(rules[number - 1])

        success = await self.bot.update_info(ctx, ["r.r", rules])
        if success:
            message = rockutils._(
                "{key} has been successfully {value}",
                ctx).format(
                    key=f"Rule {number}",
                    value="removed")
            return await ctx.send(f"{self.bot.get_emote('check')}  | " + message)
        else:
            message = rockutils._(
                "There was a problem when saving changes. Please try again", ctx)
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " + message)
Ejemplo n.º 12
0
    async def guild_channelbypass(self, ctx, option=None):
        if option is not None:
            option = option.lower()

        if option not in [
                'disable', 'disabled', 'enable', 'enabled', 'no', 'off', 'on',
                'yes'
        ]:
            value = not ctx.guildinfo['ch']['by']
        else:
            value = True if option in ['enable', 'enabled', 'on', 'yes'
                                       ] else False

        success = await self.bot.update_info(ctx, ["ch.by", value])
        if success:
            message = rockutils._("{key} has been successfully {value}",
                                  ctx).format(
                                      key="Channel Bypass",
                                      value="enabled" if value else "disabled")
            return await ctx.send(f"{self.bot.get_emote('check')}  | " +
                                  message)
        else:
            message = rockutils._(
                "There was a problem when saving changes. Please try again",
                ctx)
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)
Ejemplo n.º 13
0
    async def guild_massremoverole(self,
                                   ctx,
                                   target: discord.Role = None,
                                   role: discord.Role = None):
        await ctx.guild.chunk(cache=True)
        if not target:
            message = rockutils._(
                "No {format} was mentioned. Either mention it, provide the id or name. If you are using the name, make sure you cover it in quotes like: `\"{format} name\"`",
                ctx).format(format="target role")
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)
        if not role:
            message = rockutils._(
                "No {format} was mentioned. Either mention it, provide the id or name. If you are using the name, make sure you cover it in quotes like: `\"{format} name\"`",
                ctx).format(format="assigned role")
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)

        members = target.members
        done = 0
        seconds = len(members)
        start = time.time()

        _lastcheck = start

        lm, ls = list(map(lambda o: str(math.ceil(o)), divmod(seconds, 60)))
        message = await ctx.send(
            f"{self.bot.get_emote('loading')}  | {done}/{seconds} (0/s) (**0%**) - 0:00 / {lm}:{ls.rjust(2, '0')}"
        )

        for member in members:
            _time = time.time()
            if role.id in [_role.id for _role in member.roles]:
                await member.remove_roles(role)
            done += 1

            _length = _time - start
            if _time - _lastcheck > 5:
                tm, ts = list(
                    map(lambda o: str(math.ceil(o)), divmod(_length, 60)))

                persec = math.floor((_length / done) * (seconds - done))
                lm, ls = list(
                    map(lambda o: str(math.ceil(o)), divmod(persec, 60)))
                await message.edit(
                    content=
                    f"{self.bot.get_emote('loading')}  | {done}/{seconds} ({math.ceil((_length / done)*100)/100}/s) (**{math.ceil((done/seconds)*1000)/10}%**) - {tm}:{ts.rjust(2, '0')} / {lm}:{ls.rjust(2, '0')}"
                )
                _lastcheck = _time

        _time = time.time()
        _length = _time - start
        tm, ts = list(map(lambda o: str(math.ceil(o)), divmod(_length, 60)))
        await message.edit(
            content=
            f"{self.bot.get_emote('check')}  | Assigned role to {seconds} members in {tm}:{ts.rjust(2, '0')}"
        )
Ejemplo n.º 14
0
    async def moderation_softban(self,
                                 ctx,
                                 member: typing.Union[discord.Member] = None,
                                 *,
                                 reason=None):
        if not member:
            message = rockutils._(
                "No {target}, which is required, was specified",
                ctx).format(target="target member")
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)

        if ctx.guildinfo['m']['fr'] and not reason:
            message = rockutils._(
                "No {target}, which is required, was specified",
                ctx).format(target="reason")
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)

        if (not ctx.author == ctx.guild.owner) and (hasattr(
                member, "top_role") and hasattr(ctx.author, "top_role") and (
                    (member.top_role > ctx.author.top_role) or
                    (member.top_role > ctx.guild.me.top_role)
                    or member == ctx.author)):
            message = rockutils._("This user cannot be targeted", ctx)
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)

        try:
            await ctx.guild.ban(
                member,
                reason=
                f"Softbanned by {ctx.author} for: {reason if reason else 'No reason specified'}"
            )
            await ctx.guild.unban(
                member,
                reason=
                f"Softbanned by {ctx.author} for: {reason if reason else 'No reason specified'}"
            )
            await rockutils.logcsv([
                member.id,
                str(member), ctx.author.id,
                str(ctx.author), "softban", reason or "",
                math.ceil(time.time()), 0, True
            ], f"{ctx.guild.id}.csv", "punishments")
            message = rockutils._("{target} has been successfully {value}",
                                  ctx).format(target=str(member),
                                              value="softbanned")
            return await ctx.send(f"{self.bot.get_emote('check')}  | " +
                                  message)
        except Exception as e:
            message = rockutils._(
                "A problem has occured during this operation: {error}",
                ctx).format(error=str(e))
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)
Ejemplo n.º 15
0
    async def automod_threshold(self,
                                ctx,
                                key=None,
                                number: typing.Optional[int] = None):
        if key is not None:
            key = key.lower()

        if key == "mentions":
            _key = "m"
            if number is not None:
                if number < 1:
                    number = 1
                if number > 10:
                    number = 10
        elif key == "caps":
            _key = "c"
            if number is not None:
                if number <= 1:
                    number = 1
                if number > 100:
                    number = 100
        else:
            message = rockutils._(
                "Invalid argument for `{argument_name}`. Expected `{expects}` but received `{received}`",
                ctx).format(argument_name="threshold type",
                            expects="mentions, caps",
                            received=key)
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)

        if number is None:
            message = rockutils._(
                "Invalid argument for `{argument_name}`. Expected `{expects}` but received `{received}`",
                ctx).format(argument_name="threshold",
                            expects="number",
                            received=number)
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)

        success = await self.bot.update_info(ctx, [f"am.t.{_key}", number])
        if success:
            message = rockutils._(
                "{key} has been successfully set to {value}", ctx).format(
                    key=("Mentions" if key == "mentions" else "Capitals") +
                    " threshold",
                    value=f"{number}" if key == "mentions" else f"{number}%")
            return await ctx.send(f"{self.bot.get_emote('check')}  | " +
                                  message)
        else:
            message = rockutils._(
                "There was a problem when saving changes. Please try again",
                ctx)
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)
Ejemplo n.º 16
0
 async def borderwall_enable(self, ctx):
     success = await self.bot.update_info(ctx, ["bw.e", True])
     if success:
         message = rockutils._(
             "{key} has been successfully {value}",
             ctx).format(
                 key="Borderwall",
                 value="**enabled**")
         return await ctx.send(f"{self.bot.get_emote('check')}  | " + message)
     else:
         message = rockutils._(
             "There was a problem when saving changes. Please try again", ctx)
         return await ctx.send(f"{self.bot.get_emote('cross')}  | " + message)
Ejemplo n.º 17
0
 async def rules_disable(self, ctx):
     success = await self.bot.update_info(ctx, ["r.e", False])
     if success:
         message = rockutils._(
             "{key} has been successfully {value}",
             ctx).format(
                 key="Rules on join",
                 value="**disabled**")
         return await ctx.send(f"{self.bot.get_emote('check')}  | " + message)
     else:
         message = rockutils._(
             "There was a problem when saving changes. Please try again", ctx)
         return await ctx.send(f"{self.bot.get_emote('cross')}  | " + message)
Ejemplo n.º 18
0
 async def autorole_list(self, ctx):
     message = ""
     for role_id in ctx.guildinfo['ar']['r']:
         role = ctx.guild.get_role(int(role_id))
         if role:
             sub_message = f"{role.mention} `{role_id}`\n"
         else:
             sub_message = f"#unknown-role `{role_id}`\n"
         if len(message) + len(sub_message) > 2048:
             await self.bot.send_data(
                 ctx,
                 message,
                 ctx.userinfo,
                 force_guild=True,
                 title=f"Autorole roles ({len(ctx.guildinfo['ar']['r'])})")
             message = ""
         message += sub_message
     if len(ctx.guildinfo['ar']['r']) == 0:
         message = rockutils._(
             "This list is empty. Run `{command}` to add to this",
             ctx).format(command=f"{ctx.prefix}autorole add")
     await self.bot.send_data(
         ctx,
         message,
         ctx.userinfo,
         force_guild=True,
         title=f"Autorole roles ({len(ctx.guildinfo['ar']['r'])})")
Ejemplo n.º 19
0
 async def guild_blacklist_list(self, ctx):
     message = ""
     for channel_id in ctx.guildinfo['ch']['b']['c']:
         channel = ctx.guild.get_channel(int(channel_id))
         if channel:
             sub_message = f"{channel.mention} `{channel_id}`\n"
         else:
             sub_message = f"#deleted-channel `{channel_id}`\n"
         if len(message) + len(sub_message) > 2048:
             await self.bot.send_data(
                 ctx,
                 message,
                 ctx.userinfo,
                 force_guild=True,
                 title=
                 f"Blacklisted channels ({len(ctx.guildinfo['ch']['b']['c'])})"
             )
             message = ""
         message += sub_message
     if len(ctx.guildinfo['ch']['b']['c']) == 0:
         message = rockutils._(
             "This list is empty. Run `{command}` to add to this",
             ctx).format(command=f"{ctx.prefix}guild blacklist add")
     await self.bot.send_data(
         ctx,
         message,
         ctx.userinfo,
         force_guild=True,
         title=f"Blacklisted channels ({len(ctx.guildinfo['ch']['b']['c'])})"
     )
Ejemplo n.º 20
0
    async def borderwall_setwaittime(self, ctx, limit: typing.Optional[int] = 0):
        if limit < 0:
            limit = 0

        success = await self.bot.update_info(ctx, ["bw.w", limit])
        if success:
            message = rockutils._(
                "{key} has been successfully set to {value}",
                ctx).format(
                    key="Wait time",
                    value="unlimited" if limit == 0 else limit)
            return await ctx.send(f"{self.bot.get_emote('check')}  | " + message)
        else:
            message = rockutils._(
                "There was a problem when saving changes. Please try again", ctx)
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " + message)
Ejemplo n.º 21
0
    async def admin_info(self, ctx, _id: typing.Optional[int] = None):
        canint, _id = rockutils.canint(_id)

        if not canint:
            message = rockutils._(
                "Invalid argument for `{argument_name}`. Expected `{expects}` but received `{received}`",
                ctx).format(
                    argument_name="guild id",
                    expects="number",
                    received=_id)
            return await ctx.send(f"{self.bot.get_emote('alert')}  | " + message)

        _m = await ctx.send(f"{self.bot.get_emote('loading')}")
        response = await self.bot.broadcast("guildsfind", "*", args=[0, _id])
        message = ""
        guild = None
        for cluster_id, cluster_data in response['d'].items():
            if cluster_data['success']:
                guild = cluster_data['results']

        if guild:
            longest = max(len(k) for k in guild.keys())
            for key, value in guild.items():
                message += f"{' '*(longest-len(key))}{key}: {value}\n"
        else:
            message = "Failed to retrieve information for this guild"
        await _m.edit(content=f"```{message}```")
Ejemplo n.º 22
0
 async def moderation(self, ctx):
     message = rockutils._(
         "People said using `+moderation` then the command was confusing. So we listened!\n\n You no longer need to prepend +moderation to moderation commands. All the commands still exist but you no longer need moderation. This means `+moderation ban` will now just be accessed through `+ban`",
         ctx)
     embed = discord.Embed(title="We listen!",
                           colour=3553599,
                           description=message)
     await ctx.send(embed=embed)
Ejemplo n.º 23
0
 async def welcomer_dms(self, ctx):
     dashlink = f"{self.bot.config['bot']['site']}/dashboard/changeguild/{ctx.guild.id}"
     message = rockutils._(
         "Configuring welcomer settings have now been moved to the dashboard [here]({dashboardlink}) to allow for more ease of use",
         ctx).format(dashboardlink=dashlink)
     message += "\n\n"
     message += rockutils._(
         "To configure your Welcomer config, click the link above, log in and click on the Welcomer group on the sidebar. If you need any help, you can find the support server on the site.",
         ctx)
     embed = discord.Embed(title="We have moved",
                           colour=3553599,
                           url=dashlink,
                           description=message)
     embed.set_image(
         url=f"{self.bot.config['bot']['site']}/static/promo/moved-final.png"
     )
     await ctx.send(embed=embed)
Ejemplo n.º 24
0
    async def freeroles_removerole(
            self,
            ctx,
            role: typing.Optional[typing.Union[discord.Role, int]] = None):
        if not ctx.guildinfo['fr']['e']:
            message = rockutils._(
                "This guild has disabled {key}. If you are staff, you can enable this by using `{command}`",
                ctx).format(key="freeroles",
                            command=f"{ctx.prefix}freeroles enable")

        if not role:
            message = rockutils._(
                "No {format} was mentioned. Either mention it, provide the id or name. If you are using the name, make sure you cover it in quotes like: `\"{format} name\"`",
                ctx).format(format="role")
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)

        if isinstance(role, int):
            _role = ctx.guild.get_role(role)
            if _role:
                role = role

        if isinstance(role, int):
            _id = str(role)
            _target = _id
        else:
            _id = str(role.id)
            _target = role.name

        roles = ctx.guildinfo['fr']['r']
        if _id in roles:
            roles.remove(_id)

        success = await self.bot.update_info(ctx, ["fr.r", roles])
        if success:
            message = rockutils._("{key} has been successfully {value}",
                                  ctx).format(key=_target, value="removed")
            return await ctx.send(f"{self.bot.get_emote('check')}  | " +
                                  message)
        else:
            message = rockutils._(
                "There was a problem when saving changes. Please try again",
                ctx)
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)
Ejemplo n.º 25
0
    async def guild_reloaddata(self, ctx):
        success = await self.bot.update_info(ctx, [
            ["d.m.u", 0],
            ["d.d.u", 0],
            ["d.c.u", 0],
            ["d.r.u", 0],
        ])

        if not success:
            message = rockutils._(
                "There was a problem when saving changes. Please try again",
                ctx)
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)

        await self.bot.get_guild_info(ctx.guild.id)
        message = rockutils._("Reloaded guild data", ctx)
        return await ctx.send(f"{self.bot.get_emote('check')}  | " + message)
Ejemplo n.º 26
0
 async def leaver_enable(self, ctx):
     channel = discord.utils.get(ctx.guild.channels,
                                 id=int(ctx.guildinfo['l']['c'] or 0))
     if not channel:
         message = rockutils._("The {key} set no longer exist.",
                               ctx).format(key="leaver channel")
     success = await self.bot.update_info(ctx, ["l.e", True])
     if success:
         message = rockutils._("{key} has been successfully {value}",
                               ctx).format(key="Leaver",
                                           value="**enabled**")
         return await ctx.send(f"{self.bot.get_emote('check')}  | " +
                               message)
     else:
         message = rockutils._(
             "There was a problem when saving changes. Please try again",
             ctx)
         return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                               message)
Ejemplo n.º 27
0
    async def tempchannel_remove(self,
                                 ctx,
                                 member: typing.Union[discord.Member,
                                                      discord.User] = None):
        category = discord.utils.get(ctx.guild.channels,
                                     id=int(ctx.guildinfo['tc']['c'] or 0))
        if not category:
            message = rockutils._("The {key} set no longer exists",
                                  ctx).format(key="tempchannel category")
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)

        _target = ctx.author
        if member:
            requires_elevation = await customchecks.requires_elevation(
                return_predicate=True, return_message=False)(ctx)
            if requires_elevation:
                _target = member

        has_channel = self.has_tempchannel(category, _target)
        if not has_channel:
            message = rockutils._("No tempchannel is assigned to {target}",
                                  ctx).format(target=_target)
            return await ctx.send(f"{self.bot.get_emote('check')}  | " +
                                  message)

        channel = discord.utils.find(lambda o, category=category: str(
            _target.id) in o.name and o.category.id == category.id,
                                     ctx.guild.channels)

        try:
            await channel.delete(
                reason=f"Tempchannel remove requested by {ctx.author}")
            message = rockutils._("Your temporary channel has been removed",
                                  ctx)
            return await ctx.send(f"{self.bot.get_emote('check')}  | " +
                                  message)
        except Exception as e:
            message = rockutils._(
                "A problem has occured during this operation: {error}",
                ctx).format(error=str(e))
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)
Ejemplo n.º 28
0
    async def freeroles_give(self,
                             ctx,
                             role: typing.Optional[typing.Union[discord.Role,
                                                                int]] = None):
        if not ctx.guildinfo['fr']['e']:
            message = rockutils._(
                "This guild has disabled {key}. If you are staff, you can enable this by using `{command}`",
                ctx).format(key="freeroles",
                            command=f"{ctx.prefix}freeroles enable")
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)

        if not role:
            message = rockutils._(
                "No {format} was mentioned. Either mention it, provide the id or name. If you are using the name, make sure you cover it in quotes like: `\"{format} name\"`",
                ctx).format(format="role")
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)

        if isinstance(role, int):
            _role = ctx.guild.get_role(role)
            if _role:
                role = role

        if isinstance(role, int):
            _id = str(role)
            _target = _id
        else:
            _id = str(role.id)
            _target = role.name

        roles = ctx.guildinfo['fr']['r']
        if _id in roles:
            await ctx.author.add_roles(role, reason="FreeRole request")
            message = rockutils._("You have been given your role", ctx)
            return await ctx.send(f"{self.bot.get_emote('check')}  | " +
                                  message)
        else:
            message = rockutils._("{key} is not a valid freerole role",
                                  ctx).format(key=_target)
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)
Ejemplo n.º 29
0
    async def autorole_remove(self,
                              ctx,
                              user: typing.Optional[typing.Union[discord.User,
                                                                 int]] = None):
        if not user:
            message = rockutils._(
                "No {format} was mentioned. Either mention it, provide the id or name. If you are using the name, make sure you cover it in quotes like: `\"{format} name\"`",
                ctx).format(format="user")
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)

        if isinstance(user, int):
            _user = self.bot.get_user(user)
            if not _user:
                try:
                    _user = await self.bot.fetch_user(user)
                except discord.NotFound:
                    _user = None
        else:
            _user = user

        if not _user:
            message = rockutils._(
                "No {target}, which is required, was specified",
                ctx).format(target="valid user")
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)

        staff = ctx.guildinfo['st']['u']
        staff = list(filter(lambda o: o[0] != str(_user.id), staff))
        success = await self.bot.update_info(ctx, ["st.u", staff])
        if success:
            message = rockutils._("{key} has been successfully {value}",
                                  ctx).format(key=_user, value="removed")
            return await ctx.send(f"{self.bot.get_emote('check')}  | " +
                                  message)
        else:
            message = rockutils._(
                "There was a problem when saving changes. Please try again",
                ctx)
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " +
                                  message)
Ejemplo n.º 30
0
    async def borderwall_setchannel(self, ctx, channel: typing.Optional[discord.TextChannel] = None):
        if not channel:
            message = rockutils._(
                "No {format} was mentioned. Either mention it, provide the id or name. If you are using the name, make sure you cover it in quotes like: `\"channel name\"`",
                ctx).format(
                    format="text channel")
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " + message)

        success = await self.bot.update_info(ctx, ["bw.c", str(channel.id)])
        if success:
            message = rockutils._(
                "{key} has been successfully set to {value}",
                ctx).format(
                    key="Borderwall channel",
                    value=channel.mention)
            return await ctx.send(f"{self.bot.get_emote('check')}  | " + message)
        else:
            message = rockutils._(
                "There was a problem when saving changes. Please try again", ctx)
            return await ctx.send(f"{self.bot.get_emote('cross')}  | " + message)