Jump to content

[PHP][Discord] Show Player Count directly in Discord 1.0.0

   (3 reviews)

1 Screenshot

About This File

In this file I will get you started on how you can use Discord to show your current player count.

 

First step is to create an application at:

https://discord.com/developers/applications

Once created click Bot on the left hand side.

Click "Add Bot" and then "Yes, do it!"

Change your Icon to something more pretty

Click "COPY" underneath "Click to reveal token"

Open the file in the ZIP.

Install PHP composer if not already installed.

Run composer require team-reflex/discord-php

Edit the example_rage.php file and change the "Discord Token here" to the token you copied earlier

Change line 17 IP:PORT to your Server IP and Port

When ready run the file with php -q example_rage.php

This script must always be running for it to appear on the Discord member section. Therefore I would recommend running Linux Screen and running the php -q command then detaching the screen to run it in the background.

The script uses the Discord Heartbeat to keep it active within the list. It will also only poll the server after running the heartbeat 5 times which is every 42 seconds.

 

To set it up with your Discord server you must do the following:

Take the link you were at to setup your bot - it should look like: https://discord.com/developers/applications/IDHERE/bot

Where it says IDHERE - take it and insert it here: https://discord.com/api/oauth2/authorize?client_id=IDHERE&scope=bot&permissions=1

Once this page loads - select your discord server that you are an admin of. 

This will authorize your bot to submit to your server.

 

To make your bot appear at the top of the list, simply create a new permission role called Server

Give it permission to send messages

Set it a nice colour

Drag it to the top of your list

Go to the User that is now in your Member list showing player details and give the role of the server you just created

 

Have fun!

 

Edited by Wdoyle
Removed my ID


What's New in Version 1.0.0   See changelog

Released

  • Made the script detect if you have edited variables or if you attempt to run it on Localhost (Already been asked)
  • It also casts the Server details and checks if they are available, this is to detect if the server is missing from the Masterlist
  • Token and IP:Port details moved to the variables at the top
  • Like 1

User Feedback

Recommended Comments

Hey,

i dont know what i did wrong, but im getting always the same error.
Trying to access array offset on value of type null in C:/Php/example_rage.php on line 54

Link to comment
Share on other sites

hello, thanks for your great work.

i would like to know how i can run this file. i have everything changed and i also installed the php composer, but i cant figure out how i can run the file at the end.

would be great if i knew it after trying so many times, thank you :)

 

i am stuck when it comes to running the file and it would be great if you could help me out, thank you

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...