discord_luau/discord_stub

A local Discord stub, hosted on 127.0.0.1, for testing discord-luau bots.

discord-luau

A local Discord gateway, REST and voice server for testing bots without connecting to Discord.

Source: packages/discord_stub

Installation

pesde add discord_luau/discord_stub --dev

Example

local discordLuau = require("./luau_packages/discord_luau")
local discordStub = require("./luau_packages/discord_stub")
local stdPolyfills = require("./luau_packages/std_polyfills")

local stub = discordStub.new({ clock = "virtual", polyfills = stdPolyfills })
local gateway = stub:createWebsocketServer()

stub:createHttpServer()

local bot = discordLuau.bot.new({ token = "stub-token", intents = 0, isUsingStub = stub })

bot:connectAsync():await()
gateway:dispatch("MESSAGE_CREATE", messageData)

stub:stop()

clock = "virtual" runs the stub's time 100 times faster, so timeouts and heartbeats take moments in tests.

Full documentation at discordluau-docs.devcomp.workers.dev.

Contributing

Contributions are welcome via the repository at github.com/DiscordLuau/discord-luau.

License

This package is licensed under the MIT License.

discord_stub is an independent implementation built from Discord's public developer documentation. It is not affiliated with or endorsed by Discord, and it ships no Discord marks or logos. Use it only as a local test double.