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.