Exemple #1
0
    async def imgur(self, ctx, given_url: ImageUrl(ImageFormat.all) = None):
        _(
            """`[given_url]` - The URL to shorten; if not given, this command will look for image attachments

            Get a short URL from a long one or an image attachment.

            If both a URL and an attachment is given, the attachment is preferred. GIFs are not supported, only JPG and PNG.
            In case this command fails, you can [manually upload your image to Imgur](https://imgur.com/upload)."""
        )
        if not given_url and not ctx.message.attachments:
            return await ctx.send(_("Please supply a URL or an image attachment"))
        if ctx.message.attachments:
            if len(ctx.message.attachments) > 1:
                return await ctx.send(_("Please only use one image at a time."))
            given_url = await ImageUrl(ImageFormat.all).convert(
                ctx, ctx.message.attachments[0].url
            )

        link = await self.get_imgur_url(given_url)
        await ctx.send(_("Here's your short image URL: <{link}>").format(link=link))
Exemple #2
0
    async def image(self, ctx, *, url: ImageUrl(ImageFormat.all) = ""):
        _("""`[url]` - An image url for the pet's image, must be 60 characters or shorter

            Updates the image that shows in `{prefix}pet`.

            Having trouble finding a short image link? Follow [this tutorial](https://wiki.idlerpg.xyz/index.php?title=Tutorial:_Short_Image_URLs) or just attach the image you want to use (png, jpg, webp and gif are supported)!

            Only rangers can use this command.""")
        if (urllength := len(url)) == 0:
            if not ctx.message.attachments:
                current_icon = ctx.pet_data["image"]
                return await ctx.send(
                    _("Your current pet image is: {url}").format(
                        url=current_icon))
            file_url = await ImageUrl(ImageFormat.all
                                      ).convert(ctx,
                                                ctx.message.attachments[0].url)
            await ctx.send(
                _("No image URL found in your message, using image attachment..."
                  ))
            icon_url = await self.bot.cogs["Miscellaneous"].get_imgur_url(
                file_url)