JavaScript automation for Discord
Your Discord bot, built your way.
Write commands, automate your server, and connect the services you use—all from one dashboard. No bot hosting required.

How it works
From event to action.
Choose what starts a script, write the behavior, and let Mallard run it for your server.
- 01
Choose a trigger
A Discord command, a stream going live, a webhook, or a new feed item.
- 02
Write or adapt
Use Studio to edit a starter script or template, with autocomplete for Mallard’s API.
- 03
Run on your server
Save your script, then inspect its runs and errors in the dashboard.
Built for server owners who code
Everything you need to build and run custom automations without DevOps or hosting overhead.
More than a script editor
Connect services and build forms alongside your scripts. Here’s what that looks like in the dashboard.
Connect your services
Link streaming channels, follow feeds, receive webhooks, and configure AI from the dashboard.

Forms for your community
Build public forms with a live preview, collect responses, and run scripts when someone submits.

free for every server; limits may change as usage grows
What a script looks like
Plain JavaScript against a small API. Discord actions, an HTTP client, per-guild storage, and native AI and streaming integrations.
Catch attachment spam automatically
// Count messages containing attachments, not ordinary text messages
if (ctx.message.attachments.length === 0) return;
const key = `imgspam.${ctx.message.authorId}`;
const recent = JSON.parse(await getKV(key, { lock: true }) || "[]")
.filter(e => Date.now() - e.timestamp < 10000);
recent.push({ messageId: ctx.message.id, timestamp: Date.now() });
if (recent.length >= 3) {
await deleteKV(key);
const target = await ctx.guild.members.fetch(ctx.message.authorId);
if (target) await target.timeout(1440 * 60000, "Attachment spam");
if (ctx.env.mod_alert_channel_id) {
await discord.channels.createMessage(ctx.env.mod_alert_channel_id, "🖼️ Timed out for attachment spam. Please review.");
}
} else {
await setKV(key, JSON.stringify(recent), 60);
}Summarize recent chat with AI
// OpenRouter AI is configured on the Integrations page, so scripts
// call aiChat() directly without exposing any API keys
const chat = (await getMessages(ctx.channelId, 100)).reverse()
.map(function (m) { return m.authorDisplayName + ": " + m.content; })
.join("\n");
const res = await aiChat("Summarize this chat:\n" + chat, {
model: "google/gemini-3.5-flash-lite"
});
await ctx.interaction.editReply(res.content);Announce when you go live
// Twitch events arrive as triggers just like Discord ones
if (ctx.env.twitch_announce_channel_id) {
await discord.channels.createMessage(ctx.env.twitch_announce_channel_id, {
embeds: [{
title: "🔴 Live now: " + ctx.twitch.title,
description: "Playing " + ctx.twitch.category
+ " at twitch.tv/" + ctx.twitch.broadcasterLogin
}]
});
}Post YouTube uploads automatically
// Fires on upload without RSS polling. ctx.youtube gives you title, url, etc.
if (ctx.youtube.isShort) return; // Skip YouTube Shorts if desired
await discord.channels.createMessage(ctx.env.yt_announce_channel_id || ctx.channelId,
`📺 New video from **${ctx.youtube.channelTitle}**: **${ctx.youtube.title}**\n${ctx.youtube.url}`);
Start with what you need
Install the bot, explore the starter scripts, and customize them as your server grows. Add new commands in JavaScript whenever you're ready. The docs cover every trigger and function.
Mallard is free forever. If you'd like to help with hosting, you can buy me a coffee.
Questions, or want to see what other servers are running? The support server has a scripts hub.