Skip to content

A Discord bot designed to support NTNUI groups by managing and tracking users' membership statuses efficiently.

License

Notifications You must be signed in to change notification settings

NTNUI/ntnui-membership-bot

Repository files navigation

🤖 NTNUI membership bot

A Discord bot designed to support NTNUI groups by managing and tracking users' membership statuses efficiently.

🔧 What is this made of?

This project leverages the NTNUI API to keep track of memberships, ensuring roles in Discord reflect current statuses. The bot is built with:

  • discord.js for Discord interaction.
  • Node.js as the runtime environment.
  • MongoDB NoSQL database program for efficient cloud storage.

🚀 Quick Start and prerequisites

If you have Docker installed, it is recommended to run this bot as an image.

Make sure you have the required access permissions for the API and database.

It is also recommended to familiarize yourself with Discord and the creation of bots, as this solution currently requires separate bot instances in order to separate groups from each other.

  1. Clone the repository

    git clone https://github.com/NTNUI/ntnui-membership-bot.git
    cd ntnui-membership-bot/
  2. Build the Docker image

    docker build -t ntnui-membership-bot .
  3. Create a .env with the following values

      token=your-bot-token
      clientId=your-bot-client-id
      guildId=your-server-id
      MEMBER_ROLE=your-server-role-name
      GROUP_NAME=ntnui-group-slug
      API=your-api-access-key
      API_LINK=your-api-link
      DB_PASSWORD=your-db-password
      DB_USERNAME=your-db-username
      DB_CONNECTION=your-db-connection
  4. Finally, run the bot using either method

    docker run -d --env-file .env ntnui-membership-bot

    You may enter the environment variables directly into the run command as well.

    docker run -d -e DB_USERNAME=value DB_PASSWORD=your-db-password ntnui-membership-bot

Optionally, you can clone the project yourself — it is recommended to have git and Node installed.

  1. Clone the repository

    git clone https://github.com/NTNUI/ntnui-membership-bot.git
    cd ntnui-membership-bot/
  2. Install dependencies

    npm install
  3. Follow step 3 from the other method, creating a .env file

  4. Run the bot 🎉

    npm start

🗣️ Bot commands

Commands Explanation Required role
/register <phone_number> Register the current Discord account to the NTNUI account with <phone_number> Server member
/accountinfo View the current Discord account's membership info. Server member
/uptime View the NTNUI membership bot's current uptime. Server member
/unregister <phone_number> Unregister a Discord account from their NTNUI account with <phone_number> 'Styret' (Board member)
/grant OR revoke <target> Grants or revokes membership role to <target> 'Styret' (Board member)
/refresh Refresh the remote database with up-to-date membership statuses. 'Styret' (Board member)
/status <target> Look up a registered <target> Discord account's database entry. 'Styret' (Board member)
/edit <target> <phone_number> Edits a <target> Discord account's NTNUI connection with a new <phone_number> 'Styret' (Board member)

Bot in action

🕴️ Privacy — what data is being stored

Privacy is top priority.

This solution stores Discord user IDs and NTNUI IDs as key-value pairs in a remote database.

To keep track of membership validity, a true/false variable is stored for each user.

To support the future reminder feature, a membership's expiry date is also stored.

Contact us for any concerns or data removal requests at [email protected]

👯 Groups that use this bot

🛣️ Roadmap

  • Have a bare bones, functioning bot.
  • Successful integration of the NTNUI API.
  • Implement an automatic invitation feature for users not part of NTNUI.
  • Migrate from local to cloud storage.
  • Implement a reminder for users 1 week ahead of group membership expiry.
  • Full multi-language support.
  • Provide detailed logs for administrators.

🙌 Contributing

Contributions are awesome! Please follow the steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature-name)
  3. Commit your changes (git commit -m "Add new feature")
  4. Push to your branch (git push origin feature-name)
  5. Open a pull request.

📝 License

This project is licensed under the GPL-3.0 license. See LICENSE for details.

About

A Discord bot designed to support NTNUI groups by managing and tracking users' membership statuses efficiently.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published