Fixed bot hanging on channel None
This commit is contained in:
parent
9a51a85a3a
commit
e4914cc275
8
bot.py
8
bot.py
@ -3,6 +3,7 @@ import discord
|
||||
from discord.ext import commands, tasks
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
import datetime
|
||||
|
||||
# Read token from file
|
||||
f = open("token.txt", "r")
|
||||
@ -20,6 +21,8 @@ la_servers = {}
|
||||
client = discord.Client()
|
||||
|
||||
def get_servers_status():
|
||||
print("Getting servers", end = " ")
|
||||
print(str(datetime.datetime.now()))
|
||||
r = requests.get("https://www.playlostark.com/en-us/support/server-status")
|
||||
soup = BeautifulSoup(r.content, features = "html.parser")
|
||||
|
||||
@ -120,6 +123,11 @@ async def check_status():
|
||||
for sub in globalList["subs"]:
|
||||
if sub["Server"] == curr["Server"]:
|
||||
channel = client.get_channel(sub["Channel"])
|
||||
print("Channel", end = " ")
|
||||
print(sub["Channel"])
|
||||
print("Server", end = " ")
|
||||
print(sub["Server"])
|
||||
if channel is not None:
|
||||
await channel.send(curr["Server"] + " changed status to " + curr["Status"])
|
||||
globalList["la_servers"] = curr_status
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user