Summary
await ctx.defer() Throws a unknown interaction error after certain time of no usage of the bot.
Reproduction Steps
The possible reproduction steps:
- Have a main.py file that loads cogs
- Have a cog with a simple slash command
- Use await ctx.defer()
- Launch the bot and wait
- After 30 ish seconds of waiting do next step
- Launch said simple slash command and see the console
- After launching the command the the command again and it will work
- If you do a command after 10s or less of running another command it will work all fine
- If you wait another 30s and run the command again it will throw a error.
Minimal Reproducible Code
Main.py:
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix='!', intents=intents)
bot.load_extension("cogs.example")
@bot.slash_command(guild_ids=["823188238260633600"])
async def stop(ctx):
await ctx.defer()
if ctx.author.guild_permissions.administrator:
print("Terminating the bot...")
try:
await ctx.respond("https://media4.giphy.com/media/CC5MVO9Jx4RqMQRfvT/giphy.gif")
except:
pass
sys.exit("Terminated.")
else:
await ctx.respond("https://media.tenor.com/Iv6oKRuAhVEAAAAC/hal9000-im-sorry-dave.gif")
if __name__ == "__main__":
bot.run(token)
cogs/example.py:
import discord
from discord.ext import commands
class Greetings(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.slash_command(guild_ids=["823188238260633600"])
async def hello(self, ctx):
self.bot.api.logger("inf", "hello from the cog!")
await ctx.send(f'Hello {ctx.author}')
@commands.slash_command(guild_ids=["823188238260633600"])
async def uptime(self, ctx):
#Extends the 3s limit to reply so we dont get a unknown interation error.
await ctx.defer()
await ctx.followup.send(f"This is a example and i cannot be bothered to do a uptime command :)")
def setup(bot):
bot.add_cog(Greetings(bot))
Expected Results
Have the ctx.defer() send a thinking state to discord to extend the response
Then have the bot reply
Actual Results
After certain time of inactivity from the bot when i run a command it gives a Unknown Interaction error when it tries do to ctx.defer()
But if you use a command in 10s or less after running a command it will work just fine as expected. This is basically some hibernation thing wich is strange.
Screenshot from the log: Here
Discord screenshot
Intents
intents = discord.Intents.default() intents.members = True
System Information
From my test it doesnt depend on python version/hardware yes i tried running it on a VPS same resoult.
Checklist
Additional Context
No response
Summary
await ctx.defer() Throws a unknown interaction error after certain time of no usage of the bot.
Reproduction Steps
The possible reproduction steps:
Minimal Reproducible Code
Expected Results
Have the ctx.defer() send a thinking state to discord to extend the response
Then have the bot reply
Actual Results
After certain time of inactivity from the bot when i run a command it gives a Unknown Interaction error when it tries do to ctx.defer()
But if you use a command in 10s or less after running a command it will work just fine as expected. This is basically some hibernation thing wich is strange.
Screenshot from the log: Here
Discord screenshot
Intents
intents = discord.Intents.default() intents.members = True
System Information
From my test it doesnt depend on python version/hardware yes i tried running it on a VPS same resoult.
Checklist
Additional Context
No response