GithubHelp home page GithubHelp logo

jaakkytt / 7days-to-die-time-bot Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 16 KB

A Discord bot that reports the daytime and the current player count of a 7 Days to Die game server

Home Page: https://hub.docker.com/r/jaakkytt/7days-to-die-time-bot

Dockerfile 1.17% TypeScript 98.83%
7daystodie discord docker

7days-to-die-time-bot's Introduction

7 Days to Die daytime bot

A Discord bot that reports the daytime and the current player count of a 7 Days to Die game server as the bot activity state. The bot switches its afk status to Idle when there are no players on the server, and Online when there are players.

Example statuses:

๐Ÿ•Š๏ธDay 118/119, 12:00 ๐Ÿง1
๐Ÿ’€Day 119, 12:00 ๐Ÿง2
๐Ÿ’€Day 120, 03:00 ๐Ÿง4
๐Ÿ•Š๏ธDay 120/126, 04:01 ๐Ÿง1
๐Ÿ•Š๏ธPaused at Day 122/126, 04:11

Currently, there are some assumptions on the game server configurations:

  • TelnetEnabled is set to true
  • TelnetPort and TelnetPassword values have been specified
  • BloodMoonFrequency has a default value of 7

Installation

Discord bot

  • Create a new bot application in the Discord Developer Portal
  • In Settings > Bot: use the Reset Token button to generate a new token, copy that for later
  • In Settings > Bot > Privileged Gateway Intents: enable PRESENCE INTENT and MESSAGE CONTENT INTENT
  • In Settings > OAuth2 > Url Generator: check the scope bot and bot permissions Read Messages/View Channels, Send Messages, and Use Embedded Activities
  • Use the generated URL to invite the bot in your Discord channel.

Node application

If your game server is running on the https://github.com/Didstopia/7dtd-server container image, you can simply run the bot in a Docker container next to your game instance. Adjust the variables and volume mappings accordingly. Or set up a container created from the jaakkytt/7days-to-die-time-bot:latest image, and additionally specify the TELNET_HOST and TELNET_PORT variables.

services:
  game:
    container_name: 7d2d
    image: didstopia/7dtd-server:latest
    restart: unless-stopped
    ports:
      - "26900:26900/tcp"
      - "26900:26900/udp"
      - "26901:26901/udp"
      - "26902:26902/udp"
    volumes:
      - ./game:/steamcmd/7dtd
      - ./data:/app/.local/share/7DaysToDie
    environment:
      - SEVEN_DAYS_TO_DIE_UPDATE_CHECKING=0
      - SEVEN_DAYS_TO_DIE_BRANCH=public
      - SEVEN_DAYS_TO_DIE_TELNET_PORT=8081
      - SEVEN_DAYS_TO_DIE_TELNET_PASSWORD=
  bot:
    container_name: time-bot
    image: jaakkytt/7days-to-die-time-bot:latest
    restart: unless-stopped
    depends_on:
      - game
    environment:
      - DISCORD_TOKEN=
      - DISCORD_LOGIN_TIMEOUT=60000
      - DISCORD_UPDATE_INTERVAL=20000
      - TELNET_HOST=game
      - TELNET_PORT=8081
      - TELNET_PASSWORD=

If you wish to run the Node.js application outside the container:

  • clone this repo,
  • run npm install,
  • run npm run build,
  • create an .env file from .env.example and fill in the variables in that file,
  • and run node dist/app.js

7days-to-die-time-bot's People

Contributors

jaakkytt avatar

Watchers

 avatar

7days-to-die-time-bot's Issues

Add usage guide and example of result

Include discord bot and container setup.

Include example status messages:

๐Ÿ•Š๏ธDay 118/119, 12:00 ๐Ÿง1
๐Ÿ’€Day 119, 12:00 ๐Ÿง2
๐Ÿ’€Day 120, 03:00 ๐Ÿง2
๐Ÿ•Š๏ธDay 120/126, 04:01 ๐Ÿง1

Reduce the amount of permissions the bot requires

The bot probably does not need the MESSAGE CONTENT INTENT nor the Read Messages/View Channels and Send Messages permissions - currently they are there just because I did not clean up the DiscordClient after initial development and debugging.

  • Identify the minimum set of permissions the bot needs to run
  • Clean up DiscordClient and installation guide

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.