#task error

1 messages · Page 1 of 1 (latest)

devout copper
#

task error

nimble rune
#

save your file & restart your bot, the traceback you have doesn't line up with your code

devout copper
#

ok I am back

#
try:
  import discord
except Exception:
  exit('ERROR FOUND - site packaging error\nTo fix it, go to shell\nThen type kill 1\nThis can fix the problem')
import aiohttp
import asyncpg
from discord.ext import tasks, commands
import requests
import os

os.system('pip install -U git+https://github.com/Rapptz/discord.py')

client = commands.Bot(command_prefix='moopy!',intents=discord.Intents.all())
status = ['牛弟弟' , '牛鄰居' , '牛龜']
client.remove_command("help")
open('status.txt', 'w').writelines('1')

@client.event
async def on_command_error(ctx, error):
  loop.cancel()
  loop.start()

@client.event
async def on_error(event, *args, **kwargs):
  loop.cancel()
  loop.start()
  
@client.event
async def on_ready():
  if not loop.is_running():
    loop.start() 

@tasks.loop(seconds=10)
async def loop():
    now = int(open('status.txt', 'r').read())
    now += 1
    if now == len(status):
      now = 0
    open('status.txt', 'w').writelines(str(now))
    await client.change_presence(activity=discord.Game(name=status[now]))
    print('哞~狀態輪完一次了~')
    print(f'PING: {round(client.latency*1000)}ms')
    requests.get('https://cowcow.dasjdoijasdasda.repl.co')
    requests.get('https://PHONE.dasjdoijasdasda.repl.co')
    requests.get('https://oooo.scratchthings.repl.co')
    requests.get('https://CowCowSlashpy.scratchthings.repl.co')
    requests.get('https://button-1.dasjdoijasdasda.repl.co')  



try:
  client.run(os.environ['token'])
except:
  print('error')
  os.system("busybox reboot")
#

error:

nimble rune
#

Don't use requests

#

It's blocking

orchid sun
#

consider using aiohttp instead of requests

nimble rune
#

you even have it imported

#

come on man

orchid sun
#
 File "main.py", line 45, in loop
    requests.get('https://oooo.scratchthings.repl.co')

may be the reason why the loop is failing.