sectasy
sectasy

Reputation: 27

Discord.gateway warning "Shard ID None heartbeat blocked for more than... (Only my vps & win 11)

At the beginning I will add that I know about the existence of similar topics. However, it is nowhere said that this only happens on certain devices.

A problem like this topic Warning discord.getaway "discord.gateway: Shard ID None heartbeat blocked for more than 10 seconds." Discord.gateway warning "Shard ID None heartbeat blocked for more than 10 seconds." while using pandas

I have the same problem, but I have it on my laptop with windows 11 and on my VPS with ubuntu 20. How on earth works fine on my older desktop computer win10. On VPS and windows 11 it no longer works

My old computer has python 3.9 and I installed the same on win11 and 3.8 on VPS

my code

from discord.ext import commands
from importlib import reload
import discord as s
import discord
import requests
from bs4 import BeautifulSoup
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.options import Options


options = Options()
options.add_argument("--no-sandbox")
options.add_argument("--headless")
options.add_argument("--disable-gpu")

try:
    driver = webdriver.Chrome('/usr/bin/chromedriver', options=options)

except:
    driver = webdriver.Chrome('chromedriver.exe', options=options)

wait = WebDriverWait(driver, 10)

intents = discord.Intents.all()
client = discord.Client(intents=intents)
cmd = commands.Bot(command_prefix='$', intents=intents)

class test:
    def __init__(self):
        pass
klasa = test()

@client.event
async def send_pw(id, mess):
    user = await client.fetch_user(id)
    await user.send(mess)

@client.event
async def send_ch(id, mess):
    user = await client.fetch_channel(id)
    await user.send(mess)

@client.event
async def on_ready():
    client.loop.create_task(open_site())

@client.event
async def open_site():
    driver.get(f"https://widgets.tipply.pl/TIP_ALERT/key")
    while True:
        try:
            await wait.until(EC.presence_of_element_located((By.XPATH, "/html/body/div/div[1]/span[2]/span[2]")))
            nick = driver.execute_script(
                'return document.querySelector("#root > div.sc-bwzfXH.sc-htpNat.cTksdP > span:nth-child(2) > span.sc-bdVaJa.hmPbnt.animated.rubberBand.infinite").outerText')
            kasa = driver.execute_script(
                'return document.querySelector("#root > div.sc-bwzfXH.sc-htpNat.cTksdP > span:nth-child(1) > span.sc-bdVaJa.hmPbnt.animated.heartBeat.infinite").outerText')
            print("Found donate.")
            print(f"{nick} Wpłacił {kasa}")
            await send_ch(1030573044227090504, f"{nick} wpłacił {kasa}")
            f = open('log.txt', 'a', encoding='utf-8')
            f.write(f"{nick} Wpłacił {kasa}")
            f.close()
        except:
            print("Waiting...")


client.run("key")```

Upvotes: 0

Views: 507

Answers (1)

sectasy
sectasy

Reputation: 27

The problem seems to be resolved. After many hours and many different attempts. I solved it quite unconventionally. Manually reinstalled discord site-packages from old computer to new and VPS.

I don't understand why my current package discord.py wasn't working properly. It was correctly downloaded by pip

Upvotes: 1

Related Questions