FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
meglado
megladolovelyBeigeSole
Remix of dglazkov/discordBot
Public
Like
lovelyBeigeSole
Home
Code
2
README.md
S
main.tsx
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in miliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
8/21/2024
README.md

A simple Discord Bot scaffolding, a slight rev on the one in the valtown guide.

The discordBot function takes in an object where each key is a Discord command and the value is a function to handle the command. If the function returns a Promise, it will be handled as a deferred interaction with a followup message.

Usage:

Create val
import { discordBot } from "https://esm.town/v/dglazkov/discordBot"; const echo = async (data) => { await new Promise((r) => setTimeout(r, 5000)); return { type: 4, data: { content: data.data.options[0].value, }, }; }; export default discordBot({ ping: () => ({ type: 4, data: { content: `Pong! It is ${new Date()}`, }, }) echo, });
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.