Reputation: 31
Hi I have looked on several other forums and cannot diagnose my issue based on their code. This is for a discord bot, and whenever I get this error it forces the code to exit. It does not happen every time I run and I cannot figure out why or how to prevent it. This is my code below:
@client.event
async def on_message(message):
if message.content.startswith('!view'):
old = message.content
url = old.replace("!view", "").strip()
print ("Viewer started")
headers1 = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
}
for i in range(100):
try:
r = requests.get(url,headers=headers1,verify=False,timeout=5)
if r.status_code == 99:
print("Viewed successfully")
loop = asyncio.get_event_loop()
loop.close()
except Exception as e:
print(e)
Thank you so much in advance, I am really puzzled!
Upvotes: 1
Views: 686
Reputation: 11
Most cases the problem is becouse you didn't created a bot in the aplication https://discord.com/developers
Upvotes: 1