Discord bot - connection problems - socket hangups, timeouts, disconnections

Hi, few years ago I have started to code a bot for discord here on glitch. It was a small private bot. But things have changed a bit and it is bigger now and I started to receive some connection errors while the bot communicates with discord (mainly). Usually it is a socket hangup, timeout or disconnection. Right now I see this:
Error: socket hang up
while I try to fetch messages from some channel (actually there is just one message in the channel. The thing is, that my bot fetch a message and afterwards it edit the message in specified channel. Since It works in almost 300 guilds, it do this thing 300x times every 5 minutes. Sometimes it takes 45 seconds, sometimes 3 minutes, sometimes more then 5 minutes (and this produces memory problems as well). Bot also lags in these times to act on commands. It usually ends with the bot restart.

So the question is, is my bot too big to fit to glitch? What is the cause, that sometimes it works, and sometimes not? Can I do something, to avoid this? (Well I have already made optimisations to the code to only fetch message and edit it, it used to have much more “smart” logic before).
project name is: RotBot

Thank for info.