forked from jacobmstein/PlayerCountBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
29 lines (18 loc) · 641 Bytes
/
Copy pathbot.py
File metadata and controls
29 lines (18 loc) · 641 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import asyncio
import discord
import valve.source.a2s
import config
client = discord.Client()
async def update_player_count():
while not client.is_closed:
await client.wait_until_ready()
try:
with valve.source.a2s.ServerQuerier(config.SERVER_ADDRESS) as server:
await client.change_presence(
game=discord.Game(
name=f"{server.info()['player_count']} players online!"))
except valve.source.NoResponseError:
pass
await asyncio.sleep(3)
client.loop.create_task(update_player_count())
client.run(config.BOT_TOKEN)