Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To send a screenshot of a URL with discord.js, generate the image with a browser or screenshot service, then upload its bytes as a Discord attachment. For an embed, reference that uploaded file with attachment://filename.png. If capture may take more than a moment, defer the interaction, create the screenshot, and edit the original reply.

How the workflow fits together

discord.js does not render web pages. Your capture tool produces a file path, buffer, or stream; discord.js sends that result in the interaction response. Keeping those responsibilities separate makes it possible to replace Playwright, Puppeteer, an API, or another image tool without changing the Discord delivery code.

  1. Validate and normalize the requested URL.
  2. Capture the page as PNG, JPEG, WebP, or another format accepted by your workflow.
  3. Give the upload a filename, such as screenshot.png.
  4. Put the attachment in the interaction response’s files array.
  5. For an embed image, use the exact filename in an attachment:// URL.

Discord’s API reference documents a default maximum of 20 MiB per uploaded file; Nitro status or server boosts can raise the applicable limit. For interactions, read interaction.attachment_size_limit at runtime instead of assuming every installation has the same ceiling. See the Discord API reference.

Capture the URL before calling Discord

The capture stage depends on your chosen tool. A browser library normally needs a browser binary, navigation timeout, viewport, and a wait condition suitable for the target site. An HTTP screenshot API returns image bytes directly and avoids browser installation. Whichever option you choose, pass its result to the Discord upload step rather than trying to make discord.js perform the capture.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Logitech Brio 101 Full HD 1080p Webcam for Streaming and Meetings - Black
  • Compatible with Nintendo Switch 2’s new GameChat mode
  • Auto-Light Balance: RightLight boosts brightness by up to 50%, reducing shadows so you look your best—compared to previous-generation Logitech webcams (1)
  • Privacy with a Slide: The integrated webcam cover makes it easy to get total, reliable privacy when you're not on a video call
  • Built-In Mic: The built-in microphone lets others hear you clearly during video calls
  • Easy Plug-And-Play: The Brio 101 works with most video calling platforms, including Microsoft Teams, Zoom and Google Meet—no hassle; it just works

Browser output as a buffer

The following illustrative function shows the boundary. Replace its body with the browser or image library used by your project; the returned value must be a Node.js Buffer.

async function captureUrl(url) {
  // Use your selected browser or screenshot tool here.
  // Return a Buffer containing PNG/JPEG/WebP bytes.
  return screenshotBuffer;
}

Do not claim a particular browser default, full-page mode, or wait strategy without checking the documentation for the version installed in your project. The official Playwright screenshots page is at playwright.dev/docs/screenshots; verify browser installation and navigation settings there.

Use a file path or stream when that is what your tool returns

AttachmentBuilder accepts a buffer-resolvable value or a stream. If the capture is written to disk, pass the path (or read it into a buffer) and choose a stable filename for the attachment. A stream is useful when you do not want to retain the entire image in application memory, but make sure it remains readable until Discord has consumed it.

Send the screenshot in an interaction reply

The basic pattern uses AttachmentBuilder and the interaction’s files option. This example assumes screenshotBuffer contains the result of your capture function.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const { AttachmentBuilder, EmbedBuilder } = require('discord.js');

async function sendScreenshot(interaction, screenshotBuffer) {
  const file = new AttachmentBuilder(screenshotBuffer, {
    name: 'screenshot.png'
  });

  const embed = new EmbedBuilder()
    .setTitle('Page screenshot')
    .setImage('attachment://screenshot.png');

  await interaction.reply({
    embeds: ,
    files: [file]
  });
}

The filename in setImage() must match the uploaded name character-for-character, including extension and capitalization. Discord’s embed guidance demonstrates this attachment:// scheme in the discord.js embeds guide.

Rank #2
Sale
Logitech C270 720p Webcam Plug-and-Play Wide Screen Video Calling - Black
  • Compatible with Nintendo Switch 2’s new GameChat mode
  • Crisp HD 720p/30 fps video calls with diagonal 55° field of view and auto light correction. Compatible with popular platforms including Skype and Zoom.
  • The built-in noise-reducing mic makes sure your voice comes across clearly up to 1.5 meters away, even if you’re in busy surroundings.
  • C270’s RightLight 2 feature adjusts to lighting conditions, producing brighter, contrasted images to help you look good in all your conference calls.
  • The adjustable universal clip lets you attach the camera securely to your screen or laptop, or fold the clip and set the webcam on a shelf. You’re always ready for your next video call.

Attach an image without an embed

If an embed is unnecessary, omit embeds and send only the file:

await interaction.reply({
  content: 'Here is the screenshot.',
  files: [new AttachmentBuilder(screenshotBuffer, { name: 'page.webp' })]
});

Use an extension that describes the actual bytes. Discord’s API reference lists JPG, JPEG, PNG, WebP, and GIF as supported image formats for images used inside embeds.

Defer a slash-command reply while capture runs

A page can take longer than Discord’s initial interaction-response window. Defer immediately, perform the capture, then edit the original response. The discord.js interaction methods are documented in the MessageComponentInteraction API reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const { AttachmentBuilder, EmbedBuilder } = require('discord.js');

async function handleScreenshot(interaction, url) {
  await interaction.deferReply();

  try {
    const screenshotBuffer = await captureUrl(url);
    const file = new AttachmentBuilder(screenshotBuffer, {
      name: 'screenshot.png'
    });
    const embed = new EmbedBuilder()
      .setTitle('Page screenshot')
      .setDescription(url)
      .setImage('attachment://screenshot.png');

    await interaction.editReply({
      embeds: ,
      files: [file]
    });
  } catch (error) {
    console.error(error);
    await interaction.editReply({
      content: 'I could not capture that URL. Check the address and try again.'
    });
  }
}

Use followUp() when you intentionally want an additional message after the initial response; use editReply() to replace the deferred placeholder. Always catch capture and upload errors so the user receives a final response.

Complete command shape with validation and limits

URL validation prevents malformed input and lets you reject schemes that your capture service should never request. A conservative command accepts HTTPS and HTTP, rejects credentials, and limits the requested URL length.

Rank #3
Sale
NexiGo N60 1080P Webcam with Microphone, Software Control & Privacy Cover, USB HD Computer Web Camera, Plug and Play, for Zoom/Skype/Teams, Conferencing and Video Calling
  • 【Full HD 1080P Webcam】Powered by a 1080p FHD two-MP CMOS, the NexiGo N60 Webcam produces exceptionally sharp and clear videos at resolutions up to 1920 x 1080 with 30fps. The 3.6mm glass lens provides a crisp image at fixed distances and is optimized between 19.6 inches to 13 feet, making it ideal for almost any indoor use.
  • 【Wide Compatibility】Works with USB 2.0/3.0, no additional drivers required. Ready to use in approximately one minute or less on any compatible device. Compatible with Mac OS X 10.7 and higher / Windows 7, 8, 10 & 11 / Android 4.0 or higher / Linux 2.6.24 / Chrome OS 29.0.1547 / Ubuntu Version 10.04 or above. Not compatible with XBOX/PS4/PS5.
  • 【Built-in Noise-Cancelling Microphone】The built-in noise-canceling microphone reduces ambient noise to enhance the sound quality of your video. Great for Zoom / Facetime / Video Calling / OBS / Twitch / Facebook / YouTube / Conferencing / Gaming / Streaming / Recording / Online School.
  • 【USB Webcam with Privacy Protection Cover】The privacy cover blocks the lens when the webcam is not in use. It's perfect to help provide security and peace of mind to anyone, from individuals to large companies. 【Note:】Please contact our support for firmware update if you have noticed any audio delays.
  • 【Wide Compatibility】Works with USB 2.0/3.0, no additional drivers required. Ready to use in approximately one minute or less on any compatible device. Compatible with Mac OS X 10.7 and higher / Windows 7, 10 & 11, Pro / Android 4.0 or higher / Linux 2.6.24 / Chrome OS 29.0.1547 / Ubuntu Version 10.04 or above. Not compatible with XBOX/PS4/PS5.
const { SlashCommandBuilder } = require('discord.js');

const data = new SlashCommandBuilder()
  .setName('screenshot')
  .setDescription('Capture a web page')
  .addStringOption(option =>
    option.setName('url')
      .setDescription('The page to capture')
      .setRequired(true));

function parseHttpUrl(value) {
  const parsed = new URL(value);
  if (!['http:', 'https:'].includes(parsed.protocol)) {
    throw new Error('Only HTTP and HTTPS URLs are allowed');
  }
  if (parsed.username || parsed.password) {
    throw new Error('Credentials in URLs are not allowed');
  }
  return parsed.href;
}

Also consider SSRF protections when your bot runs in a cloud network: block localhost, private address ranges, link-local metadata endpoints, and internal hostnames unless your product explicitly needs them. Apply request and page-load timeouts in the capture layer, not only in Discord code.

Attachment, hosted image, path, buffer, or stream?

Choice Best fit Trade-off
Upload attachment One-off, per-request screenshots Self-contained response; subject to the applicable file-size limit
External image URL A stable image already hosted publicly Requires externally reachable hosting and its availability; not a fresh upload
Buffer Capture already exists in memory Simple; large images consume process memory
File path Capture tool writes a temporary file Manage cleanup and permissions
Stream Streaming or large-output pipelines Keep the stream open until the upload completes

For custom screenshots generated for each command, uploading the result is usually the least complicated option. The discord.js guide notes that repeatedly sending the same image can be faster when it is hosted and referenced by URL, but that approach introduces hosting and cache considerations.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Image size, format, and CDN considerations

  • Check interaction.attachment_size_limit before uploading and resize or recompress when the result is too large.
  • PNG preserves sharp text and transparency but can be large; JPEG is smaller for photographic pages; WebP can reduce size when your downstream clients support it.
  • Use a descriptive, stable filename and keep the embed reference identical to it.
  • Discord attachment CDN URLs may be signed and expire. Do not treat a signed URL as a permanent public asset. Discord clients refresh signed attachment links shown in the client, and the API can accept a CDN URL without parameters and refresh it, as described in the API reference.

Troubleshooting discord.js screenshot replies

The embed is blank, but the attachment appears

Check that .setImage() uses attachment://, not a filesystem path or ordinary filename, and that the filename exactly matches the attachment’s name option. Confirm the extension reflects the actual image format.

The interaction fails before the screenshot finishes

Call deferReply() before starting capture, then call editReply() with the completed file. Do not attempt a second initial reply() after deferring.

Discord rejects the upload as too large

Read the runtime attachment_size_limit, then reduce viewport dimensions, capture only the needed element, or recompress the image. The documented 20 MiB value is a default, not a universal maximum.

Rank #4
Sale
EMEET C960 1080P Webcam with Microphone, 2 Mics, 90° FOV, Computer Camera
  • 1080P Webcam with Cover for Video Calls - EMEET computer webcam provides design and Optimization for professional video streaming. Realistic 1920 x 1080p video, 5-layer anti-glare lens, providing smooth video. C960 computer camera delivers 1920x1080 video with fixed focus (11.8–118.1 inches), so as to provide a clearer image. C960 USB webcam has a cover and can be removed automatically to meet your needs for privacy. For optimal image performance, use the webcam in a well-lit environment.
  • Built-in 2 Omnidirectional Mics - EMEET webcam with microphone for desktop features 2 built-in omnidirectional microphones, picking up your voice to create clear audio for communication. When installing the webcam, select EMEET C960 as the default microphone input device in your computer and video applications and select C960 as the default device in Zoom/Teams and ensure microphone permissions are enabled for proper use. Please note that C960 does not include built-in speakers.
  • Automatic Light Adjustment - Automatic exposure adjustment is applied in EMEET HD webcam 1080p so that the streaming webcam can deliver stable image performance. EMEET C960 camera for computer also features color adjustment and exposure optimization to help you look your best. For optimal video quality, it is recommended to use the webcam in normal or well-lit environments and select suitable video settings in your application. Proper lighting helps achieve a clearer and more balanced image.
  • Plug-and-Play & Upgraded USB Connectivity - New C960 webcam features both USB Type-A & A-to-C adapter connections for wider compatibility. For stable performance, connect the webcam directly to the computer's main USB port and ensure the device is recognized correctly. If a hub or docking station is used, please ensure it provides sufficient power and stable data transmission, as limited ports may affect performance. 90° wide-angle lens captures more participants without frequent adjustments.
  • High Compatibility & Multi Application - C960 webcam for laptop is compatible with Windows 10/11, macOS 10.14+, and Android TV 7.0+. Not supported: Windows Hello, TVs, tablets, or game consoles. It works with Zoom, Teams, Facetime, Google Meet, YouTube and more. Please select C960 webcam as the default camera and microphone device in your application and ensure camera/microphone permissions are enabled, especially on macOS. (Tips: Incompatible with Windows Hello)

The file is uploaded with the wrong name or type

Set the AttachmentBuilder name explicitly and ensure your capture tool produced the format implied by the extension. A PNG buffer named .jpg can confuse clients and embed rendering.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The capture times out or returns a blank page

Inspect the capture tool’s navigation and readiness settings, verify the URL is reachable from the bot host, and log the underlying error. Handle cookie consent, authentication, JavaScript-rendered content, and bot checks in the capture layer. Do not hide these failures by sending an apparently successful Discord message.

Code copied from a guide does not match your installed version

Check your installed discord.js major version and its current API documentation. The embeds guide section is marked legacy, while the API reference tracks the main documentation; method signatures and builders can change.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo is a screenshot API and MCP server. It accepts a URL and returns PNG, JPEG, WebP, or PDF, so your bot can receive image bytes without installing a browser. Before capture it accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in X-Page-Verdict and X-Billed headers.

Request an image, then pass the response body to AttachmentBuilder:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`ScreenshotNeo HTTP ${res.status}`);
const screenshotBuffer = Buffer.from(await res.arrayBuffer());

const file = new AttachmentBuilder(screenshotBuffer, { name: 'screenshot.webp' });
await interaction.editReply({ files: [file] });

See the ScreenshotNeo documentation for authentication, options, and response handling. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. Options include full-page capture with lazy images, CSS-selector element capture, device presets and custom viewports, dark mode, retina scale, custom CSS and JavaScript, clicks, selector or network-idle waits, request blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, TTL caching, signed links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API, and an OpenAPI specification. Common screenshot-API parameter names also work for easier migration.

Best Value
Sale
Logitech C920x HD Pro PC Webcam Full 1080p/30fps Video - Black
  • Compatible with Nintendo Switch 2’s new GameChat mode
  • HD lighting adjustment and autofocus: The Logitech webcam automatically fine-tunes the lighting, producing bright, razor-sharp images even in low-light settings. This makes it a great webcam for streaming and an ideal web camera for laptop use
  • Advanced capture software: Easily create and share video content with this Logitech camera that is suitable for use as a desktop computer camera or a monitor webcam
  • Stereo audio with dual mics: Capture natural sound during calls and recorded videos with this 1080p webcam, great as a video conference camera or a computer webcam
  • Full HD 1080p video calling and recording at 30 fps. You'll make a strong impression with this PC webcam that features crisp, clearly detailed, and vibrantly colored video

The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; yearly billing provides two months free, and every feature is available on every plan. Create a free ScreenshotNeo account.

Operational checklist

  • Validate only the URL schemes and hosts your bot should access.
  • Defer interactions before slow capture work.
  • Use a supported image format and check the runtime upload limit.
  • Keep the attachment filename and attachment:// reference identical.
  • Catch capture, conversion, and Discord API errors separately in logs.
  • Delete temporary files after a successful or failed upload.
  • Never expose API keys in command responses or client-side code.
  • Confirm behavior against the discord.js version installed by your bot.

Frequently Asked Questions

Can I send a screenshot from a URL without creating an embed?

Yes. Put an AttachmentBuilder containing the image bytes in the interaction response’s files array and omit the embeds array.

Does Discord fetch a website URL when I use it as an embed image?

An embed image URL must be reachable by Discord. An uploaded attachment avoids depending on your own public image hosting for that request.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Should I store screenshots permanently?

Only if your application needs history. Otherwise upload the result, retain any required metadata, and remove temporary local files after the response completes.

What should happen when a user requests a private or internal URL?

Reject it or enforce an explicit allowlist. A screenshot service running in your infrastructure can otherwise become a server-side request-forgery path.

Quick Recap

SaleBestseller No. 1
Logitech Brio 101 Full HD 1080p Webcam for Streaming and Meetings - Black
Logitech Brio 101 Full HD 1080p Webcam for Streaming and Meetings - Black
Compatible with Nintendo Switch 2’s new GameChat mode; Built-In Mic: The built-in microphone lets others hear you clearly during video calls
$24.99
SaleBestseller No. 2
Logitech C270 720p Webcam Plug-and-Play Wide Screen Video Calling - Black
Logitech C270 720p Webcam Plug-and-Play Wide Screen Video Calling - Black
Compatible with Nintendo Switch 2’s new GameChat mode
$16.89
SaleBestseller No. 5
Logitech C920x HD Pro PC Webcam Full 1080p/30fps Video - Black
Logitech C920x HD Pro PC Webcam Full 1080p/30fps Video - Black
Compatible with Nintendo Switch 2’s new GameChat mode; Fully compatible with Windows 11
$54.99

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.