I've been hosting a discord bot on an online IDE but it happens to disconnect from the API after a while. The code on the IDE continues to run, but on discord, it is unable to respond to commands and essentially the entire bot is completely offline, while a running code is being executed. Even more suprising is a background task that I have assigned to run every minute continues to do it's job ( which is to edit a embed in a server with new information ). I've been going through the documentation and about the gateway kinda stuff but I'm utterly confused. It states that disconnections are regular but never teaches me how to actually connect again rather some snippets of JSON data. Documentation here : https://discord.com/developers/docs/topics/gateway#gateway-intents
I'm a bit new to this stuff but the documentation clearly doesn't talk anything about the way to connect to the gateway, and what to do during a op7 reconnect. How would I be able to incorperate this reconnection thing with my discord bot also?
Related
I want to create a status page for my discord bot to let other users see if my bot is currently running or if it is offline. I use UpTimeRobot for that. But I saw that the only options to check if my bot is running are HTTP(s), Keyword, Ping, and Port. So my question is now, how can uptimerobot check, if my bot is online with one of the 4 methods? Which would be the easiest way and what do I need to do to let this work?
I tried many different things at searching, but couldn't find a solution.
It comes down to how you are hosting the Discord Bot.
Easiest way is probably to have a web server running somewhere, and have your Bot send a request every X minutes to let it know that it's still alive.
Out of the four options: HTTP(s), Keyword, Ping and Port - HTTP is probably the simplest, but you might not even need UpTimeRobot (depending on how nice looking you want the status page). But it would require you to run the Web Server and the Discord Bot on the same system. See this answer for more details.
You can use replit for your bot.Upload the files,rename your bot's main program to main.py,and then add this to a new blank file(name the file keep_alive):
from flask import Flask
from threading import Thread
app = Flask("")
#app.route("/")
def home():
return "Hello. I am really alive!"
def run():
app.run(host="0.0.0.0",port=8080)
def keep_alive():
t = Thread(target=run)
t.start()
Add the lines
import keep_alive
keep_alive.keep_alive()
right before the client.run() call.
Click the run button at the top.You should see a panel open at the top right of the screen saying "Hello. I am really alive!". Copy the address in the address bar above.Then set the UptimeRobot monitor to point to that website.
NOTE:This method is completely free.You don't need the paid version of the replit account.While it says the bot will stop after you close the browser tab, it actually closes after 1 hour of network inactivity. As long as UptimeRobot's ping interval is less than 1 hour,you are fine.
I'm trying to setup a Microsoft Bot Framework bot using Python, a Direct Line Channel for Speech to Text and some Luis resources for NLP.
I've managed to get the bot working with Teams (and WebChat) but I can't figure how to correctly use the Direct Line Speech Channel. The bot is a variation of the Multi-turn prompt bot that I iterated upon (mostly by altering the dialog part, I didn't touch the rest of the bot).
I've tried following this tutorial, which led me to configure my Channel Registration and App service correctly. Following that, I've done some test using the clients provided here and got the following error on each and everyone of them:
Connection was closed by the remote host. Error code: 1002. Error details: The server returned status code '503' when status code '101' was expected. SessionId: fc7a098e75e44379b18330e8385104a9
This led me to believe that my bot was misbehaving and refusing Direct Line Speech messages.
Rereading the earlier tutorial led me to this one which is where I am stuck. It asks to do a bunch of modifications on C# code so that the bot interpret and uses websockets correctly. However, my bot is written using the Python version of the SDK, and I can't find an equivalent tutorial for how to setup Direct Line Speech in a Python bot.
Could you advise me as to how I should go about it ? I'd prefer not to have to rewrite the whole thing in C#.
September 2020 edit: I've resorted to rewriting the whole thing in C#, it works now.
I'm asking this question because I've noticed that a lot of (if not all) discord bots go offline every few hours, then come back 2 seconds later. After making my own bot, it does the exact same thing (and it's only in 4 servers). Every few hours, it goes offline for 2 seconds then comes back. Does anyone have an explanation as to why this happens?
Debugging
When the problem occurs, it also triggers on_ready(), which seems to me to mean that it isn't discord, but the client.
Other Information
I am using discord.py-rewrite library, but I've seen this happen with the discord.js library as well
This happens in active servers
Unless most bot developers make the same mistake, this is not a problem with my code.
This is not a pressing issue for me. I am just mostly curious why and am not necessarily looking for a solution, though I would appreciate it if you had one.
It could be possible that the Raspberry Pi loses connection to the discord client if it's connected wirelessly to the internet. Mine does the same for other servers unless it's connected through ethernet.
I’ve been working on a telegram bot and I just managed to design it to handle commands and issue responses to users.
I was able to achieve this successfully and started testing each and every command repeatedly to ensure they work, mind you these are like 6 or 7 commands. Basically user sends the /command and my bot sends feedback and that for like the very first few tries, like it really worked then suddenly it all stopped working.
The welcome message for new group users from the bot the feature still works but the commands aren’t.
I didn’t register all commands with BotFather but they worked anyway regardless so I’m not sure that’s the problem.
I am trying to code a simple bot for 7.6 tibia private server. My problem is that I don't know how to get a packet responsible for some action and if I'll have one I don't know how to send it to server.
Can you give me some tips?