-
Notifications
You must be signed in to change notification settings - Fork 0
/
servers.py
32 lines (23 loc) · 662 Bytes
/
servers.py
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
30
31
32
"""
Functions to check all the servers the bot is running in.
"""
import os
import discord
from dotenv import load_dotenv
load_dotenv()
intents = discord.Intents.default()
intents.guilds = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
# Prints out all the servers the bot is in.
print(f"Logged in as: {client.user.name} (ID: {client.user.id})")
print("Guilds:")
for guild in client.guilds:
print(f"- {guild.name} (ID: {guild.id})")
await client.close()
token = os.getenv("DISCORD_BOT_TOKEN")
if token:
client.run(token)
else:
print("Token not found. Please check your .env file.")