Search code examples
pythonpython-3.xdiscorddiscord.pypython-webbrowser

Discord.py and Webbrowser | How do I make the web browser open for only the author of the message?


@client.command()
async def open(ctx, pagelink):
    page = (pagelink)
    webbrowser.open(page, new=2)
    if pagelink == 'yt':
        page = ('https://www.youtube.com/')
        webbrowser.open(page, new=2)
        await ctx.send(f"{page} opened, please check your web browser :>")
    elif pagelink == 'reddit':
        page = ("https://www.reddit.com/")
        webbrowser.open(page, new=2)
    elif pagelink == "whatsapp":
        page = ("https://web.whatsapp.com/")
        webbrowser.open(page, new=2)
    elif pagelink == "pornhub":
        page = ("pornhub.com")
        webbrowser.open(page, new=2)

Right now, this command only works for MY browser, how do I get it to work for everyone? Like open up the browser of the one using the command only? For example, my friend uses the command but it doesn't open anything for him, it only opens for me. Why??


Solution

  • Long story short you cannot, the best thing you can do is send an embed With the URL.

    @client.command()
    async def open(ctx, pagelink):
        page = pagelink
        if pagelink == 'yt':
            page = ('https://www.youtube.com/')
        elif pagelink == 'reddit':
            page = ("https://www.reddit.com/")
        elif pagelink == "whatsapp":
            page = ("https://web.whatsapp.com/")
            
        embed=discord.Embed(title="Your link", url=page)
        await ctx.send(embed=embed)