Git Product home page Git Product logo

jndgoncalves / sleeptight-discord-bot Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 1.77 MB

The SleepTight Discord bot is designed to monitor user in voice channels fell asleep. If a user is detected to have fallen asleep, the bot sends a text message, plays a specific sound, and then removes the user from the voice channel.

License: MIT License

JavaScript 2.40% Dockerfile 8.08% TypeScript 89.52%
discord discord-bot discord-js

sleeptight-discord-bot's Introduction

SleepTight Discord Bot

The SleepTight Discord bot is designed to monitor user in voice channels fell asleep. If a user is detected to have fallen asleep, the bot sends a text message, plays a specific sound, and then removes the user from the voice channel. This bot enhances server interactions by providing a fun and interactive audio experience for users.

Table of Contents

How It Works

The bot determines if a user has fallen asleep using a combination of wearable technology and mobile applications:

  • Xiaomi Mi Band 6: This is the primary wearable device used for sleep detection. While the bot has been tested with the Mi Band 6, it may also be compatible with other models.
  • Notify for Mi Band: This Android application detects when the Mi Band recognizes that the user has fallen asleep. Upon detection, it sends an intent signal.
  • Tasker: Another Android application that receives the intent from "Notify for Mi Band". Once Tasker receives the intent, it triggers an action - specifically, making an HTTP request to the local server where the bot is running.
  • Bot Action: Upon receiving the HTTP request from Tasker, the bot performs the following actions:
    1. Sends a goodbye message to a specified text channel within a designated guild.
    2. Removes the user from the voice channel.
    3. Plays a "goodnight" sound.

Development & Configuration

  • TypeScript: The bot is written in TypeScript, offering strong typing and OOP features.
  • ESLint: The code is linted using ESLint to ensure code quality and consistency.
  • VS Code: For developers using Visual Studio Code, there are specific configurations provided for a seamless development experience.

Setup & Installation

  1. Clone the Repository

    git clone https://github.com/jndgoncalves/SleepTight-discord-bot
  2. Navigate to the Directory

    cd discord-bot
  3. Install Dependencies

    npm install
  4. Setup Environment Variables Rename .env.example to .env and fill in the required variables, such as your Discord token and any other necessary configurations.

  5. Run the Bot

    docker-compose up
  6. Wearable Device Ensure you have the Xiaomi Mi Band (or a compatible device) set up and paired with your Android device.

  7. Notify for Mi Band Install the Notify for Mi Band application on your Android device. Download and install the "Notify for Mi Band" application from here (https://mibandnotify.com/). Ensure the app has the necessary permissions to access your Mi Band's data. Important: Go to your phone's settings and make sure that "Notify for Mi Band" is allowed to run in the background and autostart on device boot.

  8. Tasker Download and install the Tasker application from here (https://tasker.joaoapps.com/). Create an event, set action to "com.mc.miband.tasker.fellAsleep" (intent). Then create task, set action to "HTTP Request" and fill in the following details: Method GET and URL http://[IP of the server where the bot is running]:3000/fellAsleep.

    Important: Similarly, ensure Tasker is allowed to run in the background and autostart on device boot through your phone's settings.

Events Handled

  • ready: Initializes the bot and logs a message to the console.

Dependencies

  • Discord.js: Interact with the Discord API.
  • @discordjs/voice: Handle voice connections in Discord.js.
  • dotenv: Load environment variables from .env.
  • ts-node: TypeScript execution for Node.js.
  • ffmpeg: Handle multimedia data for audio playback in voice channels.

DevDependencies

  • @typescript-eslint/eslint-plugin and @typescript-eslint/parser: ESLint support for TypeScript.
  • eslint: Lint ECMAScript/JavaScript code.
  • nodemon: Monitor source changes and restart the server.
  • typescript: Static types for JavaScript development.

Debugging with VS Code

  1. Update docker-compose.yml: Modify for debugging.

  2. Build and Start the Container:

    docker-compose up
  3. Debug using VS Code: Attach VS Code to the running Node.js process inside the container.

Contribution & Feedback

Contributions are welcome! Fork the repository and submit a pull request for enhancements or fixes. For feedback or issues, use the GitHub issues section.

License

This project is licensed under the MIT License.

Contact

For inquiries or collaboration opportunities, reach out via GitHub issues or your preferred contact method.

sleeptight-discord-bot's People

Contributors

jndgoncalves avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.