-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4843918
commit 11846ed
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#Only run this bot if you have multiple servers. | ||
#You can duplicate this file if you have more than 2 servers. | ||
|
||
import asyncio | ||
import discord | ||
from discord.ext import commands | ||
import json | ||
|
||
EnableStatus = True | ||
|
||
bot = commands.Bot(command_prefix="!", intents=discord.Intents.none()) | ||
|
||
waitTime= 15 | ||
|
||
@bot.event | ||
async def on_ready(): | ||
print("The bot is running.") | ||
while True: | ||
f = open('data.json') | ||
data = json.load(f) | ||
|
||
if data["Success"] == True: | ||
|
||
#Change the 0 if you want to display another server | ||
#0 = 1st server, 1 = 2nd server, 2 = 3rd server and so on. | ||
playercount= data["Servers"][1]["Players"] | ||
|
||
if EnableStatus == True: | ||
sep = '/' | ||
totalPlayers = int(playercount.split(sep, 1)[0]) | ||
totalSlots = int(playercount.split(sep, 1)[1]) | ||
if totalPlayers == 0: | ||
stat = discord.Status.idle | ||
elif totalPlayers == totalSlots: | ||
stat= discord.Status.dnd | ||
else: | ||
stat= discord.Status.online | ||
|
||
await bot.change_presence(status=stat,activity=discord.Game(name=playercount)) | ||
print(playercount) | ||
|
||
waitTime = data["Cooldown"] + 2 | ||
else: | ||
print("Error 503: Rate limit exceeded") | ||
await asyncio.sleep(waitTime) | ||
|
||
|
||
bot.run("Token") |