Skip to content

pasomadev/soma-app

Repository files navigation

Soma Discord AI

AI Developer assistant for Discord communities.

License: MIT TypeScript Cloudflare Workers

What it does

Soma is a Discord bot that answers questions and helps with coding tasks in group chats and private DMs. It remembers conversations for 24 hours and can search the web when needed.

You can talk to it three ways:

  • Use /soma <question> in any channel
  • Right-click a message and select "Ask Soma"
  • Right-click and select "Ask Soma with Context" for detailed help

Quick Start

Want to try Soma without hosting it yourself? Add our hosted version to your Discord server or Apps:

Add Soma to Discord →

You can use Soma in:

  • Server channels
  • Group chats
  • Private DMs

Or host your own instance below.

How to use Soma

Debug code in chat

You: /soma why is this throwing a null reference error?
[paste your code]

Soma: You're calling .map() on userData before checking if it exists.
Add a null check first: if (!userData) return null;

Pair programming

You: [right-click on a code snippet] → Ask Soma with Context
Context: "how can we make this faster?"

Soma: This loops through the array twice. You can combine the filter
and map into a single pass with reduce, cutting the time in half.

Fact check messages

Friend: "React hooks came out in 2016"
You: [right-click message] → Ask Soma

Soma: React Hooks were released in February 2019 with React 16.8,
not 2016.

Settle arguments

You: /soma what's the actual difference between a burrito and a wrap?

Soma: A burrito uses a flour tortilla and is fully closed on both ends.
A wrap can use any flatbread and is usually open on one or both ends.
But honestly, the line gets blurry at Chipotle.

Self-hosting Setup

You'll need:

  • Node.js v18 or higher
  • Bun or npm
  • A Cloudflare account
  • A Discord application

Install

git clone https://github.com/pasomadev/soma-app.git
cd soma-app
bun install

Configure

Copy .dev.vars.example to .dev.vars and add your keys:

DISCORD_APPLICATION_ID=your_discord_app_id
DISCORD_PUBLIC_KEY=your_discord_public_key
DISCORD_TOKEN=your_discord_bot_token
GEMINI_API_KEY=your_google_gemini_api_key

Run

bun run reg    # register commands
bun run dev    # start local server
bun run deploy # push to cloudflare

How it works

Discord sends requests to Cloudflare Workers, which talks to Google Gemini and stores chat history in Cloudflare KV.

Project structure

src/
├── index.ts      # main bot logic
├── llm.ts        # gemini integration
├── utils.ts      # chat history helpers
├── types.ts      # type definitions
├── contants.ts   # system prompts
└── register.ts   # command registration

Built with

  • Cloudflare Workers for hosting
  • Hono and discord-hono for the framework
  • Google Gemini Flash 2.5
  • Vercel AI SDK
  • TypeScript and Bun

Contributing

Fork the repo, make your changes, and open a pull request. Run bun test before committing.

Roadmap

  • Support for multiple AI models
  • Custom prompts per server
  • Voice message support
  • Image analysis
  • Deepwiki MCP

Common problems

Commands don't show up: Discord takes up to an hour to sync global commands. Try in a different server.

Bot doesn't respond: Check your environment variables and make sure the bot has the right Discord permissions.

Slow responses: First requests take longer. After that it's fast.

License

MIT - see LICENSE file.

Links

About

AI Assistant for Developer Communities on Discord

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published