Discord Message Code Generator
Design the message visually, export it as working code. Writing a Components V2 layout by hand means nesting builder calls you cannot see until the bot sends them. DWEEB works the other way round: build the message in the visual editor against a live Discord-accurate preview, then open the Code tab and copy it as discord.js, discord.py, cURL, JavaScript fetch or Python requests. The export carries the imports, the flag, the send call and every attachment reference, so it runs as pasted.
Nothing is posted until you review the message and confirm it.
What the export looks like
The same message — an accent-striped container with a heading, a divider and a link button — as each bot library receives it. The Components V2 reference shows the JSON form of this exact card.
discord.js
// Components V2 message — discord.js v14.19 or newer.
// Designed in DWEEB (https://dweeb.faizo.net). Edit the text, then send.
const {
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
ContainerBuilder,
MessageFlags,
SeparatorBuilder,
SeparatorSpacingSize,
TextDisplayBuilder,
} = require("discord.js");
const container = new ContainerBuilder()
.setAccentColor(0x5865f2)
.addTextDisplayComponents(
new TextDisplayBuilder().setContent(
[
"# Server update",
"Everything you need in one place.",
].join("\n"),
),
)
.addSeparatorComponents(
new SeparatorBuilder().setDivider(true).setSpacing(SeparatorSpacingSize.Small),
)
.addActionRowComponents(
new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel("Read the guide")
.setURL("https://example.com/update"),
),
);
// Send it from any async context: a command handler, an event, a script.
await channel.send({
components: [container],
flags: MessageFlags.IsComponentsV2,
});discord.py
# Components V2 message — discord.py 2.6 or newer.
# Designed in DWEEB (https://dweeb.faizo.net). Edit the text, then send.
import discord
from discord import ui
def build_view() -> ui.LayoutView:
view = ui.LayoutView(timeout=None)
view.add_item(
ui.Container(
ui.TextDisplay(
"# Server update\n"
"Everything you need in one place.",
),
ui.Separator(visible=True, spacing=discord.SeparatorSpacing.small),
ui.ActionRow(
ui.Button(
style=discord.ButtonStyle.link,
label="Read the guide",
url="https://example.com/update",
),
),
accent_colour=0x5865f2,
),
)
return view
# Send it from any coroutine: a command, an event listener, a task.
await channel.send(view=build_view())
Read the full walkthroughs: Components V2 in discord.js, Components V2 in discord.py, and the webhook senders in Python, JavaScript and cURL.
How it works
- Build the message. Start from a blank canvas, a template or a message restored from Discord, and shape it in the visual editor with the live preview beside you.
- Pick where it will run. Open More → Export as code. Choose a bot library — discord.js or discord.py — or a plain webhook request in cURL, JavaScript or Python.
- Copy it into your project. Copy or download the file. The code rebuilds exactly the message you previewed; edit the text in place whenever the announcement changes.
What you can set up
- discord.js: builder classes for every Components V2 component, sent with channel.send() and the IsComponentsV2 flag
- discord.py: a LayoutView with ui.Container, ui.Section, ui.TextDisplay and friends, sent with channel.send(view=…)
- cURL, JavaScript fetch and Python requests: a webhook POST that already carries with_components=true and the V2 flag
- Uploaded images and files become attachment:// references plus the matching upload code in every target
- Silent send, allowed mentions and forum thread settings carried through where the target supports them
- A note on the design's webhook-only settings when a bot library cannot express them
When to use it
- Prototyping a bot's announcement, help or status message before writing it in code
- Handing a designer's approved layout to the developer who has to ship it
- Posting from a script, a CI pipeline or a cron job without running a bot
- Learning what the Components V2 builders look like from a working example
Try Discord Message Code Generator
Open the Components V2 showcase with the Code tab already showing, pick your library or language, and copy the result.
Open the builder and export code →Frequently asked questions
Which libraries and languages are supported?
Two bot libraries — discord.js 14.19 or newer and discord.py 2.6 or newer, the versions that added Components V2 — and three ways to call a webhook URL directly: cURL, JavaScript with fetch, and Python with the requests library. All five produce the same message.
Is the generated code correct?
Every generator is checked by running its output against the published library and comparing the result with the message it came from: discord.js builders' toJSON(), discord.py's view.to_components(), and the request body the webhook variants actually send. The code samples on this site are produced by the same generator.
Does it handle buttons and select menus?
Yes. Link buttons work anywhere. Buttons and menus with a custom ID are exported too, but they only do something once your bot handles the interaction; the export says so in a comment, and a plain webhook cannot carry them at all.
What about images I uploaded in the editor?
An uploaded file becomes an attachment:// reference, and the export includes the matching upload — an AttachmentBuilder, a discord.File, or a multipart files[0] part — under the same filename. Put the file next to the script and it resolves.
Can I go the other way, from code to the editor?
Paste the JSON payload your code sends into the JSON tab and it opens in the editor. A legacy embed payload is converted to Components V2 on the way in, with a report of anything that could not be mapped.
Is DWEEB free?
Yes. DWEEB's visual builder is free and needs no account. Optional connected services and plans only add server-backed capacity; they do not lock the feature.
Related features
Other things DWEEB can add to the same server — or browse the full feature catalogue.
Part of DWEEB
Discord Message Code Generator is one part of DWEEB, a free visual Discord message builder for webhook messages and embed-style Components V2 layouts. Design the message itself, start from a ready-made template, or read the guides.