'My Replt Discord Bot Code is giving me a Weird Error
Yesterday, the bot was working fine. I didn't change anything since I last ran the code, but I'm getting a very odd error. And I don't have the skillset to decipher what the error means. If it helps, when I logged onto Replt today, it said that the code was running. I found that weird because it shouldn't have been running while my PC was off, but it could have been a visual bug.
import os
import discord
import random
import time
#import keep_alive
from tarot import *
#950548917911695433
player = discord.Client()
Prefixee = ["hey soupy, ", "is!"]
#Secrets
token = os.environ['token']
#--
#Run
#keep_alive.keep_alive()
#--
@player.event
async def on_ready():
print("We have logged in as {0.user}".format(player))
@player.event
async def on_message(msge):
# if msge.channel.name == "log":
# await msge.delete()
cont = msge.content
guild = msge.guild
channels = guild.channels
Prefix = "is!"
for i in range(len(Prefixee)):
if cont.startswith(Prefixee[i]):
Prefix = Prefixee[i]
if msge.author != player.user:
if cont.startswith(Prefix+"sayd:"):
msg = cont[len(Prefix+"sayd:"):(len(cont)+1)].split(":|: ")
if msge.author.id == 326078895436726282:
for i in range(len(channels)):
if channels[i].name == msg[1]:
await channels[i].send(msg[0])
await msge.delete()
if cont.startswith(Prefix+"say "):
msg = cont[len(Prefix+"say "):(len(cont)+1)]
await msge.channel.send("**" + msge.author.name + "** says: \"" + msg + "\"")
elif (cont.startswith(Prefix+"roles") or cont.startswith(Prefix+"what are the roles")):
roles = guild.roles
rolestring = ""
for i in range(1,len(roles)):
rolestring = rolestring + "__" + roles[i].name + "__" + " **|** "
await msge.channel.send(rolestring)
elif cont.startswith(Prefix+"who are you"):
whoami = "Hi, " + msge.author.name + """! I'm Soupy! I work for Inauthentic Soup.
https://imgur.com/JDwQQGN"""
elif cont.startswith(Prefix+"tarot"):
Deck = []
for i in range(len(tarot)):
Deck.append(tarot[i])
random.seed()
randomCard = random.randrange(0,len(tarot))
await msge.channel.send("Waring: Online cards are not as effective as real cards.")
time.sleep(2)
await msge.channel.send("Shuffling. . . ")
time.sleep(1)
await msge.channel.send("You drew " + tarot[randomCard])
elif cont.startswith("Thank you, Soupy"):
await msge.channel.send("Happy to help! :D")
elif cont.startswith("Terminate"):
await msge.channel.send("Happy to help! :D")
player.run(token)
This is my python code. ^^
And my error/output is below.
Traceback (most recent call last):
File "main.py", line 76, in <module>
player.run(token)
File "/home/runner/ISDungeons/venv/lib/python3.8/site-packages/discord/client.py", line 723, in run
return future.result()
File "/home/runner/ISDungeons/venv/lib/python3.8/site-packages/discord/client.py", line 702, in runner
await self.start(*args, **kwargs)
File "/home/runner/ISDungeons/venv/lib/python3.8/site-packages/discord/client.py", line 665, in start
await self.login(*args, bot=bot)
File "/home/runner/ISDungeons/venv/lib/python3.8/site-packages/discord/client.py", line 511, in login
await self.http.static_login(token.strip(), bot=bot)
File "/home/runner/ISDungeons/venv/lib/python3.8/site-packages/discord/http.py", line 300, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "/home/runner/ISDungeons/venv/lib/python3.8/site-packages/discord/http.py", line 216, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 429 Too Many Requests (error code: 0)
Solution 1:[1]
Replit uses a shared IP, which means the others users who host their bots on replit use the same IP. Many requests from the same IP will result in it getting ratelimited by Discord API. The conclusion is very simple - don't host bots on replit.
Use a VPS instead. There are some options that give you free start credits. For example: https://try.digitalocean.com/freetrialoffer
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Exenifix |
