Discord bot disconnecting and going offline intermittently

My bot remains online for approximately 10 to 15 minutes before it disconnects. It occasionally reconnects but frequently crashes shortly after. I’m not certain of the cause. Here’s some of my code below:

import os
import asyncio
import discord
from discord.ext import commands
from decouple import config

client = commands.Bot(command_prefix='!', intents=discord.Intents.all())

@client.event
async def on_ready():
    print('Bot is online')

@client.event
async def on_disconnect():
    print('Bot has been disconnected')

async def load_cogs():
    for file in os.listdir('./extensions'):
        if file.endswith('.py'):
            client.load_extension(f'extensions.{file[:-3]}')

async def start_bot():
    await load_cogs()
    await client.start(config('DISCORD_TOKEN'))

asyncio.run(start_bot())

I looked into the issue over the past few days and found that it might relate to the Discord API, but I’m unsure how to fix it. When I do capture an error message, it reads: discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction.

One potential issue could be that the bot is being terminated due to a network connection problem or a timeout error while waiting for interactions. Make sure your bot’s hosting environment has a stable internet connection. Additionally, double-check that your Discord token is correct and has not expired. As a troubleshooting step, try wrapping interactions with a try-except block to catch and debug unexpected exceptions. Limiting the use of resource-heavy commands in rapid succession might help avoid rate limits imposed by Discord.