Mirasaki / dayz-leaderboard-bot

A DayZ bot to display your leaderboard in Discord using the CFTools API
MIT License
21 stars 7 forks source link
dayz dayz-bot discord discord-bot discord-js leaderboard nodejs

DayZ Leaderboard Bot

GitHub license GitHub issues GitHub forks GitHub stars

A DayZ bot written in Javascript to display your leaderboard using the CFTools Cloud API.

Archived

This project has been archived and has since been replaced with cftools-discord-bot, a bot that that fully utilizes the CFTools Data API and offers way more than just a leaderboard

Demo

Come try the bot yourself in our official support server! Demo

Technologies Used

Prerequisites

Installation

  1. Download the latest release here
  2. Extract/unzip the downloaded compressed file into a new folder
  3. Open a command prompt in the project root folder/directory
    • On Windows you can type cmd.exe in the File Explorer path
    • Root folder structure:
      • commands/
      • local_modules/
      • .env.example
      • index.js
      • etc...
  4. Run the command npm install
  5. Copy-paste the .env.example file in the same directory and re-name the created file to .env
  6. Open the .env file and fill in your values
    • CLIENT_ID: Can be grabbed by creating a new application in your Discord Developer Portal
    • DISCORD_BOT_TOKEN: After creating your bot on the link above, navigate to Bot in the left-side menu to reveal your bot-token
    • CFTOOLS_API_APPLICATION_ID: Application ID from your CFTools Developer Apps - Authorization has to be granted by navigating to the Grant URL that's displayed in your app overview
    • CFTOOLS_API_SECRET: Same as above, click Reveal Secret
  7. Open the config/servers.example.json file and rename it to servers.json. Fill in your values.
    • CFTOOLS_SERVER_API_ID: Click Manage Server in your CF Cloud Panel > Settings > API Key > Server ID
  8. Add the bot to your server by using the following link: (Replace CLIENT-ID with your CLIENT_ID from before) https://discord.com/api/oauth2/authorize?client_id=CLIENT-ID&permissions=0&scope=bot%20applications.commands
  9. Run the command node . in the project root folder/directory or npm run start if you have PM2 installed to keep the process alive.

Server configuration

Server configuration is managed through the /config/servers.json file, here is a quick reference of what the values mean.

This is NOT valid JSON, as you should NOT use this file, use the example instead

[
  {
    // The name to display when selecting servers with /leaderboard and /stats
    "name": "Name to display - server WITH automatic leaderboard",
    // Click `Manage Server` in your CFTools dashboard (https://app.cftools.cloud/dashboard) > `Settings` > `API Key` > `Server ID`
    "CFTOOLS_SERVER_API_ID": "Your secret server API id",
    // Should the automatic leaderboard be enabled
    "AUTO_LB_ENABLED": true,
    // ID of the channel to post the automatic leaderboard to
    "AUTO_LB_CHANNEL_ID": "806479539110674472",
    // How often should the leaderboard be updated
    "AUTO_LB_INTERVAL_IN_MINUTES": 60,
    // Should old leaderboard data/messages be deleted
    "AUTO_LB_REMOVE_OLD_MESSAGES": true,
    // The amount of players to show on the leaderboard
    "AUTO_LB_PLAYER_LIMIT": 25
  }
]

FAQ

How do I create the Discord bot account?

Check out this video by The Coding Train

Is any specific set-up required to use this?

Yes. Your DayZ server has to be connected to the CFTools Cloud API and needs the GameLabs integration mod.

License

MIT