Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Discord SO Notifier. A Discord bot that fetches the latest Stack Overflow questions tagged with the configured tag, posts them as rich embeds to your Discord channel, and keeps the submitted question IDs in a JSON file

License

NotificationsYou must be signed in to change notification settings

webdriverio/discord-bot

Repository files navigation

A Node.js bot that bridges Stack Overflow and Discord for the WebdriverIO community.

Features

  • Monitors Stack Overflow for new questions tagged with a configurable tag (default:webdriver-io).
  • Posts new questions as rich embeds to a specified Discord channel via webhook.
  • Prevents duplicate notifications by persisting sent question IDs.
  • Configurable via environment variables.
  • Easy to extend for other tags or notification channels.

Getting Started

Prerequisites

  • Node.js v22+ (for native fetch and ESM support)
  • npm
  • Access to a Discord server where you can create a webhook

Installation

  1. Clone the repository:

    git clone<repo-url>cd wdio-discord-bot
  2. Install dependencies:

    npm install
  3. Configure environment variables:

    Create a.env file in the project root with the following content:

    DISCORD_WEBHOOK_ID=your_discord_webhook_idDISCORD_WEBHOOK_TOKEN=your_discord_webhook_tokenTAG_TO_MONITOR=webdriver-io# Optional: STACKEXCHANGE_KEY=your_stackexchange_api_key
    • DISCORD_WEBHOOK_ID andDISCORD_WEBHOOK_TOKEN are from your Discord channel webhook.
    • TAG_TO_MONITOR is the Stack Overflow tag to monitor.
    • STACKEXCHANGE_KEY is optional but recommended for higher API rate limits.
  4. Run the bot:

    • For development (with TypeScript):
      npm run dev
    • For production:
      npm start

How It Works

  • On each run, the bot:
    1. Loads the list of previously notified question IDs fromdata/sentIds.json.
    2. Fetches the latest questions from Stack Overflow tagged with your configured tag.
    3. Filters out questions already sent.
    4. Formats and posts new questions to Discord as embeds.
    5. UpdatessentIds.json and auto-commits/pushes the file (if using git).

Development Advice

  • TypeScript: The project is written in TypeScript. Usenpm run dev for live development.
  • Persistence: Sent question IDs are stored indata/sentIds.json. To reset notifications, delete or clear this file.
  • Auto-commit: Each time new questions are sent, the bot auto-commits and pushes the updatedsentIds.json. Ensure your environment has git configured and permissions set.
  • Extending: To monitor a different tag, changeTAG_TO_MONITOR in your.env.
  • Formatting: The embed includes a snippet of the question body, with code blocks formatted for Discord.
  • Error Handling: If the bot fails to send a message or update sent IDs, errors are logged to the console.
  • API Limits: For higher Stack Exchange API limits, setSTACKEXCHANGE_KEY in your.env.

Project Structure

src/  config/         # Environment variable validation  services/       # Stack Overflow, Discord, and persistence logic  utils/          # HTML formatting for Discord  index.ts        # Entry pointdata/  sentIds.json    # Tracks sent question IDs

Troubleshooting

  • No new questions: If there are no new questions, the bot will log "No new questions."
  • Webhook errors: Double-check your Discord webhook credentials.
  • Git errors: Ensure your environment has git installed and configured for auto-commits.

License

MIT

Feel free to further customize this README for your community or deployment environment!

About

Discord SO Notifier. A Discord bot that fetches the latest Stack Overflow questions tagged with the configured tag, posts them as rich embeds to your Discord channel, and keeps the submitted question IDs in a JSON file

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp