How to use the cogs.utils.helper.edit function in Cogs

To help you get started, we’ve selected a few Cogs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lehnification / Discord-SelfBot / cogs / misc.py View on Github external
async def eimage(self, ctx, *, msg: str):
        """Embed an image."""
        link = self.link.findall(msg)
        if link:
            mimetype, encoding = mimetypes.guess_type(link[0])
            if mimetype and mimetype.startswith('image'):
                try:
                    await edit(ctx, embed=discord.Embed(colour=embedColor(self)).set_image(url=link[0]))
                except:
                    await edit(ctx, content="\N{HEAVY EXCLAMATION MARK SYMBOL} Something went wrong", ttl=5)
            else:
                await edit(ctx, content="\N{HEAVY EXCLAMATION MARK SYMBOL} No image link", ttl=5)
        else:
            await edit(ctx, content="\N{HEAVY EXCLAMATION MARK SYMBOL} No link given", ttl=5)
github lehnification / Discord-SelfBot / cogs / mod.py View on Github external
async def _colour(self, ctx, role: str, colour: str):
        """Set the Color of a Role."""
        role = getRole(ctx, role)
        colour = getColor(colour)
        if not role:
            return await edit(ctx, content="\N{HEAVY EXCLAMATION MARK SYMBOL} Role not found", ttl=5)
        elif not colour:
            return await edit(ctx, content="\N{HEAVY EXCLAMATION MARK SYMBOL} Colour not found", ttl=5)
        else:
            value = discord.Colour(int((colour.hex_l.strip('#')), 16))
            try:
                await role.edit(colour=value)
            except discord.HTTPException:
                await edit(ctx, content="\N{HEAVY EXCLAMATION MARK SYMBOL} Missing permissions to edit this role", ttl=5)
            else:
                e = discord.Embed(color=value)
                e.set_author(name="Changed Role Color of: " + str(role))
                await edit(ctx, embed=e)
github lehnification / Discord-SelfBot / selfbot.py View on Github external
async def on_command_error(ctx, error):
    if isinstance(error, commands.NoPrivateMessage):
        await edit(ctx, content='\N{HEAVY EXCLAMATION MARK SYMBOL} Only usable on Servers', ttl=5)
    elif isinstance(error, commands.CheckFailure):
        await edit(ctx, content='\N{HEAVY EXCLAMATION MARK SYMBOL} No Permissions to use this command', ttl=5)
    elif isinstance(error, commands.CommandInvokeError):
        log.error('In {0.command.qualified_name}:\n{1}'.format(ctx, ''.join(traceback.format_list(traceback.extract_tb(error.original.__traceback__)))))
        log.error('{0.__class__.__name__}: {0}'.format(error.original))
github lehnification / Discord-SelfBot / cogs / mal.py View on Github external
content = await self.loop.run_in_executor(None, self.get_google_entries, query, 'anime')
            await content
        except RuntimeError as e:
            await edit(ctx, content=str(e), ttl=3)
        else:
            if content is None:
                await edit(ctx, content='No results found... sorry.', ttl=3)
            else:
                em = await self.loop.run_in_executor(None, self.parse_content, self.malid, 'anime')
                gc.collect()
                if em is Exception:
                    await edit(ctx, content='\N{HEAVY EXCLAMATION MARK SYMBOL} Invalid credentials; rejected by MAL.', ttl=3)
                else:
                    try:
                        if permEmbed(ctx.message):
                            await edit(ctx, embed=em)
                        else:
                            await edit(ctx, content='https://myanimelist.net/anime/{}' + content)
                    except:
                        await edit(ctx, content='\N{HEAVY EXCLAMATION MARK SYMBOL} Whoops a Wumpus made and error while getting your Embed', ttl=3)
github lehnification / Discord-SelfBot / cogs / tools.py View on Github external
async def jumbo(self, ctx):
        """Display your favorite emotes in large."""
        emote = getEmote(ctx, getWithoutInvoke(ctx))
        if emote:
            em = discord.Embed(colour=embedColor(self))
            em.set_image(url=emote.url)
            await edit(ctx, embed=em)
        else:
            await edit(ctx, content='\N{HEAVY EXCLAMATION MARK SYMBOL} Only Emotes...', ttl=3)
github lehnification / Discord-SelfBot / cogs / log.py View on Github external
async def channel(self, ctx):
        """Add a channel to the logger."""
        channels = self.bot.log_channel
        channel = getChannel(ctx, getWithoutInvoke(ctx)).id
        if channel:
            if channel in self.bot.log_block_channel:
                await edit('\N{HEAVY EXCLAMATION MARK SYMBOL} Already in blacklist used',  ttl=5)
                return
            if channel in channels:
                channels.remove(channel)
                self.bot.log_channel = channels
                await save_log('channel', channels)
                await edit(ctx, content='\N{HEAVY CHECK MARK} Removed Channel with ID ``%s`` from logger' % channel,  ttl=5)
            else:
                channels.append(channel)
                self.bot.log_channel = channels
                await save_log('channel', channels)
                await edit(ctx, content='\N{HEAVY CHECK MARK} Added Channel with ID ``%s`` to logger' % channel,  ttl=5)
        else:
            await edit(ctx, content='\N{HEAVY EXCLAMATION MARK SYMBOL} No Channel found',  ttl=5)
github lehnification / Discord-SelfBot / cogs / tools.py View on Github external
msg = search.split(" | ")
            search = msg[0]
            content = msg[1]
        mess = None
        if search.isdigit():
            async for message in ctx.message.channel.history(limit=500):
                if message.id == int(search):
                    mess = message
        else:
            async for message in ctx.message.channel.history(limit=500):
                if message.id != ctx.message.id and search in message.content:
                    mess = message
        if mess is not None:
            em = discord.Embed(description=mess.clean_content, timestamp=mess.created_at, colour=embedColor(self))
            em.set_author(name=mess.author.display_name, icon_url=mess.author.avatar_url)
            await edit(ctx, content=content, embed=em)
        else:
            await edit(ctx, content='Message not found!', ttl=3)
github lehnification / Discord-SelfBot / cogs / tools.py View on Github external
async def id(self, ctx):
        """Get the ID of a Server, Channel, Emote, User"""
        if ctx.invoked_subcommand is None:
            content = getWithoutInvoke(ctx)
            if getUser(ctx, content):
                await edit(ctx, content="The User ID is ``{}``".format(getUser(ctx, content).id))
            elif getChannel(ctx, content):
                await edit(ctx, content="The Channel ID is ``{}``".format(getChannel(ctx, content).id))
            elif getGuild(ctx, getWithoutInvoke(ctx)):
                await edit(ctx, content="The Guild ID is ``{}``".format(getGuild(ctx, content).id))
            elif getEmote(ctx, content):
                await edit(ctx, content="The Emote ID is ``{}``".format(getEmote(ctx, content).id))
            else:
                await edit(ctx, content="\N{HEAVY EXCLAMATION MARK SYMBOL} No User, Channel, Guild or Emote found", ttl=3)
github lehnification / Discord-SelfBot / cogs / mal.py View on Github external
async def anime(self, ctx, *, query):
        """Search for an Anime."""
        await edit(ctx, content='Searching...')
        try:
            content = await self.loop.run_in_executor(None, self.get_google_entries, query, 'anime')
            await content
        except RuntimeError as e:
            await edit(ctx, content=str(e), ttl=3)
        else:
            if content is None:
                await edit(ctx, content='No results found... sorry.', ttl=3)
            else:
                em = await self.loop.run_in_executor(None, self.parse_content, self.malid, 'anime')
                gc.collect()
                if em is Exception:
                    await edit(ctx, content='\N{HEAVY EXCLAMATION MARK SYMBOL} Invalid credentials; rejected by MAL.', ttl=3)
                else:
                    try:
                        if permEmbed(ctx.message):
github lehnification / Discord-SelfBot / cogs / misc.py View on Github external
async def gif(self, ctx, *text):
        """Get a gif from Giphy."""
        if text:
            if len(text[0]) > 1 and len(text[0]) < 20:
                try:
                    msg = "+".join(text)
                    search = "http://api.giphy.com/v1/gifs/search?q=" + msg + "&api_key=dc6zaTOxFJmzC"
                    async with aiohttp.ClientSession() as cs:
                        async with cs.get(search) as r:
                            result = json.loads(await r.text())
                            if result["data"] != []:
                                await edit(ctx, embed=discord.Embed(color=embedColor(self)).set_image(url=result["data"][0]["images"]["original"]["url"].split("?response")[0]))
                            else:
                                await edit(ctx, content="Your search terms gave no results.", ttl=3)
                except:
                    await edit(ctx, content="Error.", ttl=3)
            else:
                await edit(ctx, content="Invalid search.", ttl=3)
        else:
            await edit(ctx, content="\N{HEAVY EXCLAMATION MARK SYMBOL} Specify Search", ttl=3)