import mimetypes


def url_is_image(url):
    """Checks if the url point to an image."""
    mimetype, encoding = mimetypes.guess_type(url)
    if mimetype and mimetype.startswith('image'):
        return True

    ext = url.split('.')[-1].split("?")[0].lower()
    mimetype, encoding = mimetypes.guess_type(ext)
    # discord image url
    if ext in ["webp", "gif"] or (mimetype and mimetype.startswith('image')):
        return True

    return False