Skip to content

Commit 11846ed

Browse files
Create 2ndBot.py
1 parent 4843918 commit 11846ed

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

SCPSL-Discord-Bot/2ndBot.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#Only run this bot if you have multiple servers.
2+
#You can duplicate this file if you have more than 2 servers.
3+
4+
import asyncio
5+
import discord
6+
from discord.ext import commands
7+
import json
8+
9+
EnableStatus = True
10+
11+
bot = commands.Bot(command_prefix="!", intents=discord.Intents.none())
12+
13+
waitTime= 15
14+
15+
@bot.event
16+
async def on_ready():
17+
print("The bot is running.")
18+
while True:
19+
f = open('data.json')
20+
data = json.load(f)
21+
22+
if data["Success"] == True:
23+
24+
#Change the 0 if you want to display another server
25+
#0 = 1st server, 1 = 2nd server, 2 = 3rd server and so on.
26+
playercount= data["Servers"][1]["Players"]
27+
28+
if EnableStatus == True:
29+
sep = '/'
30+
totalPlayers = int(playercount.split(sep, 1)[0])
31+
totalSlots = int(playercount.split(sep, 1)[1])
32+
if totalPlayers == 0:
33+
stat = discord.Status.idle
34+
elif totalPlayers == totalSlots:
35+
stat= discord.Status.dnd
36+
else:
37+
stat= discord.Status.online
38+
39+
await bot.change_presence(status=stat,activity=discord.Game(name=playercount))
40+
print(playercount)
41+
42+
waitTime = data["Cooldown"] + 2
43+
else:
44+
print("Error 503: Rate limit exceeded")
45+
await asyncio.sleep(waitTime)
46+
47+
48+
bot.run("Token")

0 commit comments

Comments
 (0)