← 返回
未分类 Key 中文

LM Studio Discord Bot

Connect a local LM Studio model directly to Discord as a lightweight chat bot. Use when you want to expose a local LLM (running via LM Studio on CPU) to Disc...
将本地 LM Studio模型直接接入 Discord,作为轻量聊天机器人。适用于将本地 LLM(LM Studio 在 CPU 上运行)暴露给 Discord。
dq-stack dq-stack 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 需要
★ 0
Stars
📥 408
下载
💾 0
安装
1
版本
#bot#discord#latest#lm-studio#openclaw#qwen

概述

LM Studio Discord Bot

A minimal Discord bot that routes messages directly to LM Studio — no OpenClaw gateway in the path.

When to Use

  • LM Studio model is fast in direct chat but slow through OpenClaw
  • CPU-only setup where OpenClaw's tool system adds too much latency
  • You want a simple Discord bot without the full OpenClaw feature set

How It Works

Discord → bot.js → LM Studio API → bot.js → Discord

The bot uses Discord.js to receive messages and axios to call LM Studio's /v1/chat/completions endpoint directly. No tools, no workspace files, no system prompt overhead.

Setup

1. Create the bot project

mkdir lm-studio-discord-bot
cd lm-studio-discord-bot
npm init -y
npm install discord.js axios

2. Create bot.js

See scripts/bot-template.js for the ready-to-use template.

3. Configure

Edit these constants in bot.js:

const DISCORD_TOKEN = 'YOUR_DISCORD_BOT_TOKEN';
const LM_STUDIO_URL = 'http://127.0.0.1:1234/v1/chat/completions';
const MODEL = 'qwen2-0.5b-instruct';  // Must match loaded model in LM Studio
const GUILD_ID = 'YOUR_DISCORD_SERVER_ID';

To get your bot token: https://discord.com/developers/applications

To get the Guild ID: Enable Developer Mode in Discord → Right-click your server → Copy ID

4. Add bot to your server

https://discord.com/oauth2/authorize?client_id=BOT_CLIENT_ID&permissions=1024&scope=bot

Replace BOT_CLIENT_ID with your bot's Application ID from the Discord Developer Portal.

5. Run

node bot.js

The bot will log in and respond to messages in any channel of the configured guild.

Configuration Tips

ParameterDefaultNotes
---------------------------
max_tokens512Lower = faster, less verbose
timeout60000msIncrease if slow on CPU
streamfalseSet true for streaming replies

Known Limitations

  • No tool access (file read/write, web search, etc.)
  • No conversation memory — each message is stateless
  • No slash commands
  • Single model per bot instance

Extending

To add conversation history, modify the messages array in the axios call to include prior exchanges. Note: this increases token usage and context window pressure.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-03 10:11 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-agent

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,446 📥 329,148
ai-agent

Agent Browser

rez0
用于 AI 代理的浏览器自动化 CLI。当用户需要与网站交互(包括浏览页面、填写表单、点击按钮、截图等)时使用。
★ 869 📥 348,389
ai-agent

self-improving agent

pskoett
记录自身发现以实现自我改进的技能
★ 4,170 📥 941,777