Discord chat embed reference for the iframe and script

Updated

Wizcord puts a live Discord channel on your page in one of two ways: a floating chat button (one <script> tag) or an inline chat (one <iframe>). Both load the same chat from https://wizcord.io. You can get either from the Embed your chat card on your dashboard, which writes the code for the channel you pick. This page lists every option you can set, for when you write or change the code yourself. For the set-up from the start, see how to embed a live Discord channel on your website.

You need the channel's ID: in Discord, turn on Developer Mode (User Settings, then Advanced), right-click the channel and choose Copy Channel ID. The channel's server must be connected in your Wizcord dashboard, with the Wizcord bot in it.

Floating chat button

<script src="https://wizcord.io/iframe/embed.js" data-channel-id="YOUR_CHANNEL_ID" async></script>

Put it anywhere in the page, in the <head> or the <body>. It adds a button in a bottom corner, and the button opens the chat in a panel. The script loads with your page; the chat itself loads from Wizcord only when the panel is first opened, by a visitor or by your page's own script, or straight away if you set data-open="true".

Attribute Values Default Notes
data-channel-id The channel ID, 17 to 20 digits required Anything else: no button, and a warning in the browser console
data-position bottom-left bottom right Any other value gives bottom right
data-theme light dark
data-accent Six hex digits, no # button 5865F2 Colours the button and is passed to the chat. Without it the chat keeps its standard colours
data-label Plain text, up to 40 characters Chat A longer label is not shortened: the button says Chat instead. The same happens with control characters
data-show-pinned true off The pinned messages bar
data-load-older true off The "Load older messages" button
data-threads true off Public threads and forum posts
data-open true off Opens the panel when the page loads, without moving keyboard focus

Values are case-sensitive: true, not True (hex digits in data-accent may be either case). A value that is not in the list is ignored and the default is used.

How it behaves:

  • The panel is 380 × 560 pixels, smaller if the window is. Under 480 pixels wide it fills the screen and respects the phone's safe areas.
  • The floating chat never shows the channel list.
  • The panel's close button, another click on the button, or Escape while the button or the close button has focus closes it. Opening moves keyboard focus to the panel's close button; closing it with its own controls moves focus back to the button.
  • The button lives in a Shadow DOM, so your page's CSS does not change it and its CSS does not leak into your page.
  • Adding the script twice still gives one button. Whichever copy runs first wins, and with async that is not always the first one on the page, so keep only one copy.

JavaScript API

The script adds one object, window.WizcordChat:

Method What it does
WizcordChat.open() Opens the panel
WizcordChat.close() Closes it
WizcordChat.toggle() Opens it if closed, closes it if open
<button type="button" onclick="window.WizcordChat && WizcordChat.open()">Chat with us</button>

The object exists only once the script has run with a valid channel ID, which is why the example checks for it first. A call made after the script has run but before the button is on the page is remembered and applied when it appears. There are no events, no unread count and no method to remove the button: it stays until the page is reloaded.

Inline chat (iframe)

The dashboard's default code fits the page: as wide as the page up to 800 pixels, 600 pixels high but never taller than 80% of the screen.

<iframe src="https://wizcord.io/iframe?channelId=YOUR_CHANNEL_ID&menu=false" width="100%" height="600" style="display:block;max-width:800px;max-height:80vh;border:0" frameborder="0" title="Discord chat"></iframe>

Its Fixed size choice gives an exact size instead, without the style:

<iframe src="https://wizcord.io/iframe?channelId=YOUR_CHANNEL_ID&menu=false" width="800" height="600" frameborder="0" title="Discord chat"></iframe>

A fixed size can be anything from 200 to 4000 pixels, or width="100%" with Full width. A fixed width wider than a phone makes visitors scroll sideways.

URL parameters

Add them to the src address, after channelId, each starting with &.

Parameter Values Default What it does
channelId The channel ID required The channel shown
menu false list shown menu=false hides the channel list. With the list, visitors can switch to the other channels your embeds may show. The dashboard adds menu=false unless you turn the channel list on
show_pinned true off A bar with the channel's pinned messages, when it has any
theme light dark Light colours. Any other value: dark
accent Six hex digits, no # standard colours The main button, links and the message box outline while typing. Text on the button turns black or white for contrast
load_older true off A "Load older messages" button. Each click loads the next older page; when there is nothing older it says "Beginning of the available history"
threads true off Public threads and forum posts, archived ones included. Private threads are never shown. Visitors can reply in them but cannot start a forum post

menu=false and show_pinned=true accept any case. theme, load_older and threads need the exact lower-case value. An invalid value is ignored.

Example:

https://wizcord.io/iframe?channelId=YOUR_CHANNEL_ID&menu=false&theme=light&accent=5865F2&load_older=true

How it behaves:

  • The chat fills whatever size you give the iframe.
  • When the chat itself is 768 pixels wide or narrower, the channel list starts collapsed.
  • The chat opens with up to 200 of the latest messages.
  • If the channel is not served (a wrong ID, a server not connected in your dashboard, the bot not in the server, an age-restricted channel, or a channel not chosen for your embeds), visitors see "This chat is not available right now."
  • Embeds show a small "Provided by Wizcord" link under the chat.

Content-Security-Policy and framing

  • If your site sends a Content-Security-Policy header, allow https://wizcord.io in frame-src (or child-src / default-src) for both kinds of embed, and in script-src for the button.
  • The button's styles are applied in a way that works under a strict style-src. In browsers without constructable stylesheets it adds a <style> element carrying your script tag's nonce, if it has one.
  • You do not need to register your site's address with Wizcord.
  • Do not add a sandbox attribute. Signing in with Discord opens a pop-up window, and the sign-in is kept in the chat's own browser storage. A sandbox without allow-scripts, allow-same-origin, allow-popups and allow-popups-to-escape-sandbox breaks these.
  • Your dashboard shows We saw your embed on your site, using the address the browser passes to the chat. For an inline chat, a Referrer-Policy: no-referrer header or referrerpolicy="no-referrer" on the iframe hides it: the chat still works, but the dashboard cannot see it. The floating button always passes your site's address. Browsers usually pass only the site's address, not the page, and the chat must stay open for a few seconds.

What the chat loads

Besides wizcord.io, the chat loads images and avatars from Discord's servers (cdn.discordapp.com), sends a request to Google Fonts (fonts.googleapis.com), and contacts Tenor for GIFs: when a visitor opens the GIF picker, and to show Tenor links posted in the channel. Images in link previews, and GIF links posted in the channel (for example from Giphy), load from the sites they come from.

Plans

Every option on this page works for every connected server today. Wizcord is free while it is in beta, and paid plans are coming.

What is not available

There is no npm package, no events your page can listen to, no unread count on the button and no custom CSS, and visitors cannot upload files. For React and Next.js, see Discord chat in React and Next.js, which shows how to use the iframe and the script there without a package.

Create an account to get your channel's code from the dashboard, or read the full documentation.

Wizcord is free while it is in beta.

Create an accountRead the documentation