Exemple #1
0
 async def purge(self,
                 ctx,
                 amount: int = -1,
                 *,
                 opt: flags.FlagParser(user=[UserWithFallback],
                                       match=str,
                                       nomatch=str,
                                       include_embeds=bool,
                                       startswith=str,
                                       endswith=str,
                                       attachments=bool,
                                       bot=bool,
                                       invite=bool,
                                       text=bool,
                                       channel=TextChannel,
                                       reason=str) = flags.EmptyFlags):
     if amount > 500 or amount < 0:
         return await ctx.send(
             'Invalid amount. Minumum is 1, Maximum is 500')
     try:
         await ctx.message.delete()
     except Exception:
         pass
     if isinstance(opt, dict):
         await self.flag_purge(ctx, amount, opt)
     else:
         await self.basic_purge(ctx, amount)
Exemple #2
0
    async def bulk_delete(
        self,
        ctx,
        *,
        args: flags.FlagParser(amount=int,
                               bot_only=bool,
                               member=discord.Member) = flags.EmptyFlags):
        """Bulk-delete a certain amout of messages in the current channel.

        The amount of messages specified might not be the amount deleted.
        Limit is set to 500 per command, the bot can't delete messages older than 14 days."""
        if args["bot_only"] and args["member"]:
            raise commands.BadArgument(
                "Either specify a member or bot only, not both.")

        amount = args["amount"] or 10
        if amount > 500:
            return await ctx.send("Maximum of 500 messages per command.")

        check = None
        if args["bot_only"] is not None:
            check = lambda m: m.author.bot
        elif args["member"] is not None:
            check = lambda m: m.author.id == args["member"].id

        try:
            await ctx.message.delete()
        except discord.HTTPException:
            pass

        purge = await ctx.channel.purge(limit=amount, check=check, bulk=True)

        await ctx.send(f"Successfully deleted {len(purge)} message(s).",
                       delete_after=5)
Exemple #3
0
    async def deep_fry(
        self,
        ctx,
        args: flags.FlagParser(member=discord.Member,
                               amount=float) = flags.EmptyFlags):
        """Deepfry yours or someone else's profile picture."""
        await ctx.trigger_typing()
        avatar = await get_avatar(args["member"] or ctx.author)

        deepfried = await enhance(avatar, "color", args["amount"] or 10)
        await ctx.send(file=discord.File(deepfried, filename="fried.jpeg"))
Exemple #4
0
    async def specs(self,
                    ctx,
                    user: Member = None,
                    flags: flags.FlagParser(remove=bool) = flags.EmptyFlags):
        user = user if user else ctx.author
        uspecs = await self.bot.db.fetch('SELECT * FROM specs WHERE uid=$1;',
                                         user.id)
        if not uspecs:
            return await ctx.error(
                f'Specs not found for that user. Tell them to fill in this form\n<https://inv.wtf/sk1spec>'
            )
        else:
            if isinstance(flags, dict) and flags.get(
                    'remove',
                    False) and ctx.author.guild_permissions.manage_messages:
                con = await self.bot.db.acquire()
                async with con.transaction():
                    query = 'DELETE FROM specs WHERE uid=$1;'
                    await self.bot.db.execute(query, user.id)
                await self.bot.db.release(con)
                await user.remove_roles(
                    self.guild.get_role(595626786549792793),
                    reason=f'Specs removed by {ctx.author}')
                return await ctx.success(
                    f'Successfully removed specs for {user}')
            uspecs = uspecs[0]

            def escape(text: str):
                text = discord.utils.escape_markdown(text)
                text = re.sub(r'<a?:[a-zA-Z0-9\_]+:([0-9]+)>', '', text, 0,
                              re.MULTILINE)
                return text

            embed = discord.Embed(
                color=user.color,
                timestamp=datetime.datetime.now(
                    datetime.timezone.utc)).set_author(
                        name=str(user),
                        icon_url=user.avatar_url_as(static_format='png',
                                                    size=2048),
                        url=f'https://inv.wtf/sk1spec').add_field(
                            name='» CPU',
                            value=escape(uspecs['cpu'][:1024]),
                            inline=False).add_field(
                                name='» GPU',
                                value=escape(uspecs['gpu'][:1024]),
                                inline=False).add_field(
                                    name='» RAM',
                                    value=escape(uspecs['ram'][:1024]),
                                    inline=False).add_field(
                                        name='» Operating System',
                                        value=escape(uspecs['os'][:1024]),
                                        inline=False)
            return await ctx.send(embed=embed)
Exemple #5
0
    async def bright(self,
                     ctx,
                     *,
                     args: flags.FlagParser(member=discord.Member,
                                            amount=float) = flags.EmptyFlags):
        """Brighten yours or someone else's profile picture."""
        await ctx.trigger_typing()
        avatar = await get_avatar(args["member"] or ctx.author)

        bright = await enhance(avatar,
                               "brightness",
                               args["amount"] or 2,
                               fmt="PNG",
                               quality=None)
        await ctx.send(file=discord.File(bright, filename="bright.png"))
Exemple #6
0
	async def addswear(self, ctx, word: str, f: flags.FlagParser(remove=bool) = flags.EmptyFlags):
		if ctx.author.id != 509078480655351820:
			return await ctx.send('no')
		remove = False
		if isinstance(f, dict):
			remove = f['remove']
		if not remove:
			self.config['words'].append(word)
			json.dump(self.config, open('conor.json', 'w'), indent=4)
			self.swear = self.config['words']
			return await ctx.send(f'Added {word} to the naughty list')
		elif word in self.swear:
			self.config['words'].remove(word)
			json.dump(self.config, open('conor.json', 'w'), indent=4)
			self.swear = self.config['words']
			return await ctx.send(f'Removed {word} from the naughty list')