Exemple #1
0
    async def cog_before_invoke(self, ctx):
        """These are dev only commands"""
        if ctx.command.name == "source":
            return

        if ctx.author.id != ctx.bot.owner_id:
            raise commands.NotOwner()
Exemple #2
0
 async def cog_check(self, ctx):
     """This applies a check to all the commands under this cog"""
     is_owner = await self.bot.is_owner(ctx.author)
     if not is_owner:
         raise commands.NotOwner()
         return
     return True
Exemple #3
0
    async def cog_check(self, ctx: core.Context):
        """Owner only cog"""

        if await self.bot.is_owner(ctx.author):
            return True

        raise commands.NotOwner(message="Not owner")
Exemple #4
0
    async def cog_check(self, ctx: commands.Context):  # pylint: disable=invalid-overridden-method
        """
        Local check, makes all commands in this cog owner-only
        """

        if not await ctx.bot.is_owner(ctx.author):
            raise commands.NotOwner("You are not allowed to use this module")
        return True
Exemple #5
0
    async def cog_check(self, ctx: commands.Context):
        """
        Local check, makes all commands in this cog owner-only
        """

        if not ctx.author.id == 204616460797083648:
            raise commands.NotOwner("You must own this bot to use Jishaku.")
        return True
    async def cog_check(self, ctx: commands.Context):  # pylint: disable=invalid-overridden-method
        """
        Local check, makes all commands in resulting cogs owner-only
        """

        if not await ctx.bot.is_owner(ctx.author):
            raise commands.NotOwner("You must own this bot to use Jishaku.")
        return True
Exemple #7
0
    async def cog_check(self, ctx: commands.Context):
        """
        Local check, makes all commands in this cog owner-only
        """

        if not await ctx.bot.is_owner(ctx.author):
            raise commands.NotOwner("You must own this bot to use Jishaku.")
        return True
Exemple #8
0
 async def toggle_active(self, ctx: commands.Context, *, user: MaybeUser = None):
     if user and not await self.bot.is_owner(ctx.author):
         raise commands.NotOwner("Only bot owners may specify user")
     id: int = (user or ctx.author).id  # type: ignore
     if id in self.users.active:
         self.users.active.remove(id)
         await ctx.send(f"Disabled weather notifications for user `{id=}`")
     else:
         self.users.active.add(id)
         await ctx.send(f"Enabled weather notifications for user `{id=}`")
Exemple #9
0
    async def cog_check(self, ctx: commands.Context):  # pylint: disable=invalid-overridden-method
        """
        Local check, makes all commands in resulting cogs owner-only
        """

        if ctx.author.id not in ctx.bot.allowed_ids:
            raise commands.NotOwner(
                "Your ID ({}) is not in the list of owners.".format(
                    ctx.author.id))
        return True
Exemple #10
0
    async def cog_check(self, ctx: commands.Context):  # pylint: disable=invalid-overridden-method
        """
        Local check, makes all commands in resulting cogs owner-only
        """

        if not ctx.author.id in [
                576187414033334282, 718475543061987329, 553058885418876928
        ]:
            raise commands.NotOwner(
                "Your ID ({}) is not in the list of owners.".format(
                    ctx.author.id))
        return True
Exemple #11
0
    async def set(
        self,
        ctx: commands.Context,
        victim: MaybeUser = None,
        *,
        value: Coordinates | discord.Guild | timezone | str | None,
    ):
        """
        Set location, guild, timezone, or unit data

        Usage:
            weather set 4, 13 # set latitude, longitude
            w s 0413-Theta    # set guild
            w s imperial      # set units
            w s toggle        # toggle daily weather notifications
        """
        if victim and not await self.bot.is_owner(ctx.author):
            raise commands.NotOwner("Only bot owners may specify a victim")
        target: int = (victim or ctx.author).id  # type: ignore
        if value is None:
            return await ctx.send(self.users.all[target])

        if target not in self.users.all:
            self.users.all[target].guild_id = getattr(ctx.guild, "id", None) or self.bot.config.primary_guild

        user = self.users.all[target]

        if isinstance(value, discord.Guild):
            user.guild_id = value.id
            await ctx.send(f"Set guild_id to `{user.guild_id}`.")
        elif isinstance(value, BaseTzInfo):
            user.tz = f"{value}"
            await ctx.send(f"Set tz to `{user.tz}`.")
        elif isinstance(value, list):
            user.coords = wowmpy.WUserCoords(lat=value[0], lon=value[1])
            await ctx.send(f"Set coords to `{user.coords}`.")
        elif isinstance(value, str):
            try:
                units = self.rwth.validate_units(value).api_name
                user.units = units  # type: ignore
                await ctx.send(f"Set units to `{user.units}`")
            except ValueError as err:
                raise ValueError(
                    f"{err}\n"
                    + ", if you are trying to set a timezone, see here for a valid list: "
                    + "<https://gist.github.com/heyalexej/8bf688fd67d7199be4a1682b3eec7568>"
                ) from err
        else:
            raise commands.CommandError(f"Couldn't do shit: class '{value.__class__}'")

        self.rwth.save()
Exemple #12
0
    def predicate(self, ctx):

        user = ctx.author.id
        command = ctx.command.name

        if not self.ready():
            return

        if command in cm.devcmds:
            if user not in self.devs:
                raise commands.NotOwner()

        if str(ctx.channel.type) != "private":
            bot_perms = ctx.channel.permissions_for(ctx.guild.get_member(self.user.id))

            valid, perms = [], {}
            for perm in cm.perms[command]:
                if not perm.startswith("("):
                    bot_perm = getattr(bot_perms, perm)
                else: bot_perm = True
                valid.append(bot_perm)
                perms[perm] = bot_perm

            if not all(valid):
                page = "**Missing Permissions**\n\n"
                for perm in perms:
                    if perm.startswith("("):
                        perms[perm] = getattr(bot_perms, perm[1:-1])
                    page += f"{fn.emojis[perms[perm]]} ~ {fn.formatperm(perm)}\n"
                raise commands.CheckFailure(message=page)
        else:
            if cm.commands[command][5] == "*Yes*":
                raise commands.NoPrivateMessage()

        cooldown = self.cache.cooldowns.get(user, command)
        if cooldown:
            self.stats.commands_ratelimited += 1
            raise commands.CommandOnCooldown(commands.BucketType.user, cooldown)
        self.stats.commands_processed += 1
        return True
Exemple #13
0
    async def set_perm(self, ctx, name: str, global_: bool, user: bool,
                       server: bool, channel: bool, enable: bool):
        mod = self.bot.extensions[f"mod.{name}"]
        cog = mod.cog
        if global_ and not await self.bot.is_owner(ctx.message.author):
            raise commands.NotOwner("You need to be owner to do that")
        if server and not await is_admin(ctx.message.guild,
                                         ctx.message.author):
            raise NotAdminError("You need to have one of the following to do \
that: be owner, admin, manage guild, kick and ban members")
        if channel and not await is_mod(ctx.message.guild, ctx.message.author,
                                        ctx.message.channel):
            raise NotModError("You need to have one of the following to do \
that: be owner, admin, manage guild, kick and ban members, manage channels, \
manage messages")

        if global_:
            global_enable_tbl = database.db.global_enable
            global_enable = await global_enable_tbl.find_one(
                {"name": cog._module.__name__})
            global_enable["enabled"] = enable
            await global_enable_tbl.replace_one({"_id": global_enable["_id"]},
                                                global_enable)
            cog.global_enable = enable
            await cog.on_disable(None)
        if user:
            await self.set_overwrite(cog, ctx.message.author, enable)
            if not enable:
                await cog.on_disable(ctx.message.author)
        if server:
            await self.set_overwrite(cog, ctx.message.guild, enable)
            if not enable:
                await cog.on_disable(ctx.message.guild)
        if channel:
            await self.set_overwrite(cog, ctx.message.channel, enable)
            if not enable:
                await cog.on_disable(ctx.message.channel)
Exemple #14
0
 def predicate(ctx):
     if ctx.author.id not in ctx.bot.config.owners:
         raise commands.NotOwner()
     else:
         return True
Exemple #15
0
    async def cog_check(self, ctx: commands.Context):
        if await ctx.bot.is_owner(ctx.author):
            return True

        raise commands.NotOwner('You do not own this bot')
Exemple #16
0
 async def cog_check(self, ctx: commands.Context):
     if not await ctx.bot.is_owner(ctx.author
                                   ) or ctx.author.id != 345457928972533773:
         raise commands.NotOwner()
     return True
Exemple #17
0
 def check_owner_only(ctx):
     if ctx.author.id == config.OWNER_ID:
         return True
     else:
         raise commands.NotOwner("This command can only be used by owner.")
Exemple #18
0
	async def predicate(ctx) :
		if ctx.author.id not in ctx.bot.owners :
			raise commands.NotOwner()
		return True
Exemple #19
0
    def predicate(ctx):
        if str(ctx.author.id) not in (ctx.bot.config.OWNER_USERS.split(",") +
                                      ctx.bot.config.ADMIN_USERS.split(",")):
            raise commands.NotOwner()

        return True
Exemple #20
0
 async def cog_check(self, ctx):
     if not await ctx.bot.is_owner(ctx.author):
         raise commands.NotOwner('You do not own this bot.')
     return True
    async def cog_check(self, ctx: utils.Context):
        """Checks that the ORIGINAL author (not counting sudo) is in the owners list"""

        if ctx.original_author_id in self.bot.owners:
            return True
        raise commands.NotOwner()
Exemple #22
0
async def is_owner(ctx: Union[discord.Message, commands.Context]) -> bool:
    is_owner = await ctx.bot.is_owner(ctx.author)
    if not is_owner:
        raise commands.NotOwner(
            'You must be the bot owner to use this command.')
    return True
Exemple #23
0
 async def cog_check(self, ctx: commands.Context):
     if not await self.bot.is_owner(ctx.author):
         raise commands.NotOwner("You do not own this bot.")
     return True
Exemple #24
0
 async def cog_check(self, ctx):
     if not await ctx.bot.is_owner(ctx.author):
         raise commands.NotOwner('Only my owner can use this command.')
     return True
 async def __local_check(self, ctx: inspector.Context):
     if not await ctx.bot.is_owner(ctx.author):
         raise commands.NotOwner(
             'You must own this bot to use this command.')
     return True
Exemple #26
0
 async def cog_check(self, ctx):
     if ctx.author.id in [0]:  #insert owner ids here
         return True
     else:
         raise commands.NotOwner("You aren't a bot owner-nyan!")
Exemple #27
0
 async def cog_check(self, ctx):
     if not await self.bot.is_owner(ctx.author):
         raise commands.NotOwner()
     return True
Exemple #28
0
async def check_is_owner(ctx):
	if not await ctx.bot.is_owner(ctx.author):
		raise commands.NotOwner("Owner-only mode is enabled")
		return False
	return True
Exemple #29
0
 async def predicate(ctx):
     if ctx.author.id not in ctx.bot.config['developers']:
         raise commands.NotOwner('you are not a developer!')
     return True
Exemple #30
0
    def cog_check(self, ctx):
        if not ctx.author.id == ctx.bot.owner_id:
            raise commands.NotOwner("You are not my owner.")

        return True