I made a Discord bot that runs from a hidden Excel sheet. Because why not.
Our take
There is something quietly powerful about a developer who looks at an Excel spreadsheet and sees a server. When someone builds a Discord bot that runs entirely from a hidden worksheet using a native WebSocket module for VBA, it is not just a clever hack. It is a signal. The tools we have long considered simple or outdated are still capable of surprising us when we stop treating them as static containers and start thinking of them as runtime environments. This is the kind of work that deserves more attention, because it challenges the assumption that meaningful automation requires heavyweight platforms or modern frameworks. If you have ever tried to stream real-time data into Excel using traditional methods, you know how quickly those approaches fall apart under pressure. That context matters here, because Wasabi exists in part to solve exactly that problem, and this Discord experiment reveals what happens when you give VBA a proper network layer. I built a native WebSocket & MQTT client for Excel VBA (Zero DLLs, streams live data without freezing) walked through that foundation. What this new project demonstrates is where that foundation can take you when you stop asking whether something is possible and start asking what is interesting.
The elegance of the approach is worth examining closely. Discord's bot API is, at its core, a WebSocket connection and a JSON handshake. There is no SDK requirement, no proprietary runtime, no cloud dependency. You connect, you identify, you send heartbeats, you parse events, and you respond. That simplicity is not a limitation. It is the entire point. The developer behind Wasabi understood that VBA has been starved of native network capabilities for years, and that once you give it even a basic WebSocket implementation, the doors open faster than most people expect. The bot runs from a hidden sheet, responds to commands like !ping and !get A1, and can write cell values or trigger macros on demand. It sits quietly in the background while the spreadsheet remains fully functional on top of it. That is a remarkably clean architecture for something built in a language most developers would not consider for this kind of work.
What makes this worth discussing beyond the technical novelty is the pattern it reveals. The developer is not arguing that Excel should replace your bot framework or that VBA is superior to Python for server-side logic. The argument is subtler and more compelling: the boundaries we draw between tools are often arbitrary, and when you remove them, genuinely creative workflows emerge. Being able to read and write cells via Discord commands, trigger macros remotely, or post alerts when a threshold is crossed turns a spreadsheet into an interactive system that can respond to the outside world without any additional infrastructure. It is the kind of integration that would have seemed absurd a decade ago and now feels inevitable.
The question worth watching is not whether more people will build Discord bots in Excel. It is whether this mindset spreads. When developers stop treating legacy tools as relics and start treating them as platforms with untapped potential, the results tend to be more interesting than anything built with the expected stack. Wasabi is still early, and the ecosystem around it is small, but the willingness to explore these intersections is what separates a tool from a platform. That is the shift worth paying attention to.
I already posted it on r/vba But I'd like to share this knowledge and the interesting things you can create using Wasabi with other communities as well!
So I've been working on a native WebSocket module for VBA called Wasabi, and at some point I asked myself: "can I connect this to Discord's gateway and make a bot?" The answer is yes, and it's glorious and completely unnecessary.
The concept
Discord's bot API is just a WebSocket connection to wss://gateway.discord.gg. Once connected, Discord sends you a JSON payload with an op code telling you to identify yourself. You send back your bot token and intents, and from that point on you receive events (messages, reactions, etc.) as JSON frames. You respond to them by hitting Discord's REST API with plain HTTP calls.
That's it. No SDK needed. Just WebSocket + JSON parsing.
Step 1: Get a bot token
Go to https://discord.com/developers/applications, create an application, add a bot, copy the token. Enable the "Message Content Intent" under the bot settings or it won't receive message content.
Step 2: Import Wasabi
Download Wasabi.bas from https://github.com/uesleibros/wasabi/releases and import it into your VBA project via File > Import File. No references to enable, no DLLs to register.
Step 3: Connect to the gateway and keep it alive
Discord requires you to send a heartbeat payload every N milliseconds (it tells you the interval on connect). Here's a minimal loop that handles that:
#If VBA7 Then Private Declare PtrSafe Function GetTickCount Lib "kernel32" () As Long #Else Private Declare Function GetTickCount Lib "kernel32" () As Long #End If Sub RunDiscordBot() Dim token As String token = "YOUR_BOT_TOKEN_HERE" Dim handle As Long If Not WebSocketConnect("wss://gateway.discord.gg/?v=10&encoding=json", handle) Then MsgBox "Failed to connect to Discord gateway." Exit Sub End If Dim msg As String Dim heartbeatInterval As Long Dim lastHeartbeat As Long Dim identified As Boolean identified = False lastHeartbeat = 0 Do While WebSocketIsConnected(handle) msg = WebSocketReceive(handle) If Len(msg) > 0 Then Dim op As Long op = ExtractOp(msg) ' parse the "op" field from JSON ' Hello payload: Discord sends heartbeat interval If op = 10 Then heartbeatInterval = ExtractHeartbeatInterval(msg) lastHeartbeat = GetTickCount() ' Identify If Not identified Then Dim identifyPayload As String identifyPayload = "{""op"":2,""d"":{""token"":""" & token & """,""intents"":33280,""properties"":{""os"":""windows"",""browser"":""excel"",""device"":""excel""}}}" WebSocketSend identifyPayload, handle identified = True End If ' Dispatch: actual events like MESSAGE_CREATE ElseIf op = 0 Then Call HandleEvent(msg, token) End If End If ' Send heartbeat when due If GetTickCount() - lastHeartbeat >= heartbeatInterval Then WebSocketSend "{""op"":1,""d"":null}", handle lastHeartbeat = GetTickCount() End If DoEvents Loop WebSocketDisconnect handle End Sub Step 4: Handle a message event
When op = 0 and the event type is MESSAGE_CREATE, you get the channel ID and message content from the JSON. Then you can reply via Discord's REST API using XMLHTTP:
Sub HandleEvent(ByVal payload As String, ByVal token As String) If InStr(payload, "MESSAGE_CREATE") = 0 Then Exit Sub Dim channelId As String Dim content As String channelId = ExtractField(payload, "channel_id") content = ExtractField(payload, "content") If content = "!ping" Then Call SendDiscordMessage(channelId, "Pong! (sent from Excel)", token) End If End Sub Sub SendDiscordMessage(ByVal channelId As String, ByVal message As String, ByVal token As String) Dim http As Object Set http = CreateObject("MSXML2.XMLHTTP") Dim url As String url = "https://discord.com/api/v10/channels/" & channelId & "/messages" Dim body As String body = "{""content"":""" & message & """}" http.Open "POST", url, True http.setRequestHeader "Authorization", "Bot " & token http.setRequestHeader "Content-Type", "application/json" http.Send body Do While http.readyState <> 4 DoEvents Loop End Sub Where to go from here
This is just the skeleton. From here you can:
- Read/write cells based on Discord commands ("!get A1" returns the cell value, "!set A1 42" writes to it)
- Trigger macros remotely by sending a command from Discord
- Post alerts to a channel when a cell value crosses a threshold (combine with a Worksheet_Change event)
- Run the bot from a hidden sheet so it sits quietly in the background while you use the spreadsheet normally
The browser and device fields in the identify payload are set to "excel" in the example above. Discord doesn't validate these, but it's a fun touch.
Full module docs and source: https://github.com/uesleibros/wasabi
[link] [comments]
Read on the original site
Open the publisher's page for the full experience