GithubHelp home page GithubHelp logo

leslija / fivem-serverstatsbot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from itsxscrubz/fivem-serverstatsbot

0.0 0.0 0.0 59 KB

A discord bot that posts FiveM server status and player count to a designated channel.

License: MIT License

Shell 6.52% JavaScript 5.15% TypeScript 88.33%

fivem-serverstatsbot's Introduction

fivem-serverstatsbot

A discord bot that posts FiveM server status and player count to a designated channel.

exampleImage


Current Features

The bot will post a message in a predetermined channel (if none exists) or edit the message and update it with the current server status and player count.

I HIGHLY recommend using pm2 if you are self hosting the bot.


- IMPORTANT -

I am editing the previous message by grabbing the last message posted. I am NOT checking to see what this last message was. So the channel this posts in NEEDS to be dedicated to this bot/stats embed ONLY with NO OTHER POSTS inside it. I'm lazy and didn't wanna do any logic to get around this. xD


Notes

As of v1.0 it ONLY handles displaying server online status and player count ON A SINGLE SERVER at a time.

I'm not 100% sure if I'm going to take this any further, since this was just a way for me to familiarize myself with the discord.js lib.

I also have NO plans on actively supporting this outside of fixing bugs.

Please note, when the server is offline, the Join Server button will be disabled.


Environment variables

  • DISCORD_TOKEN => This is the bot token you are provided in the section below.
  • UPDATE_CHANNEL_ID => The channel the bot will post updates to.
  • FIVEM_SERVER_NAME => Bot will have Watching MyServerName as a status and will also be displayed on the embed message.
  • BOT_SERVER_ID => This is the CFX server invite code.
  • BOT_SITE_LINK => This will open a browser url to your site when either clicking the Visit Website button OR clicking the header text that displays your server name inside the embed.
  • BOT_EMBED_ICON => This is the image that will be displayed inside the embed message.
  • BOT_CHECKSTATUS_INTERVAL => This is the time in seconds between checking/updating the server status/player count.

Installation

General

  • Rename .env.example to .env.
  • Follow all the steps below to set up the bot.
  • After ALL the env variables are set, then you can build and start the bot.

Discord

  • Go here to the discord developers panel.
  • Click the New Application button on the top right and give it a name.
  • You can fill out the name, description, and tags as you see fit.
  • Then click Bot on the left hand panel.
  • Click the Add Bot button.
  • Give your bot a name, and avatar icon.
  • Click the Copy button under the token section and set it via the DISCORD_TOKEN env variable.
  • On the left hand panel, click OAuth2 then URL Generator.
  • Select bot under scopes, then select the following required permissions: Read Messages/View Channels, Embed Links. You may set other permissions that will be needed if you plan to add to the code yourself.
  • Copy the generated url below the permissions, and paste it in the browser to invite the bot to your server.
  • You will need to create a channel to post the server stats to. Create the channel, right click it, and click Copy ID, and that id will be used as the BOT_SITE_LINK env variable. If you don't see Copy ID, then go to Discord User Settings => Advanced => Developer Mode and turn it on.
  • Finally, set all the other env variables, and you're good to go!

fivem-serverstatsbot's People

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.