#Key error

1 messages Β· Page 1 of 1 (latest)

mental adder
#

I am trying to run a command that is in an extension. Here comes the issue: when i run the command it throws me this error:

Task exception was never retrieved
future: <Task finished name='Task-72' coro=<Client._dispatch_interaction() done, defined at C:\Users\jakob\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\interactions\client\client.py:1609> exception=KeyError('challenge')>
Traceback (most recent call last):
  File "C:\Users\jakob\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\interactions\client\client.py", line 1628, in _dispatch_interaction
    if ctx.command:
  File "C:\Users\jakob\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\interactions\models\internal\context.py", line 308, in command
    return self.client._interaction_lookup[self._command_name]
KeyError: 'challenge'```
dusky ferryBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

mental adder
#

btw this happens for every command in the code

gentle gale
#

Resolved in 5.1.0

weak sequoia
#

can you fully restart the bot and see if it still occurs?

mental adder
mental adder
weak sequoia
#

ok so to have done that you would have restarted

#

gunna need to see your extension please

mental adder
#

yep

#

main.py on startup:

@listen()
async def on_startup():
    print("Ready")
    print(f"This bot is owned by {bot.owner}")
    # Load all modules, from a JSON file, for convenience
    with open("modules.json", "r") as file:
        data = json.load(file)

        for extension in data["extensions"]:
            bot.load_extension(extension)
    await bot.change_presence(
        activity=Activity(
            name="Larss_J and _AR struggle with this bots development",
            type=ActivityType.WATCHING,
        ),
        status=Status.IDLE,
    )```
weak sequoia
#

ah

#

never load extensions in startup

mental adder
weak sequoia
#

load them straight after initialising the client, but before login - sync will behave itself that way - if that fixes it, ill have a tinker with the extension loader which is where the bug would be

mental adder
#

nope

#
# Ran when the bot is ready
@listen()
async def on_startup():
    print("Ready")
    print(f"This bot is owned by {bot.owner}")
    await bot.change_presence(
        activity=Activity(
            name="Larss_J and _AR struggle with this bots development",
            type=ActivityType.WATCHING,
        ),
        status=Status.IDLE,
    )


# Load all modules, from a JSON file, for convenience
with open("modules.json", "r") as file:
    data = json.load(file)

    for extension in data["extensions"]:
        bot.load_extension(extension)```
#

still doesnt work

weak sequoia
# mental adder

this code wouldnt work? there are a load of missing imports. did you remove them before sending?

#

oh you use wildcards - nvm

#

bare with while i test

mental adder
weak sequoia
#

its considered bad practice

#

i cant replicate using pypi latest. can i see this CustomExtension class?

mental adder
#
from naff import *

class CustomExtension (Extension):
    # Init function – runs when the extension is loaded
    def __init__(self, bot):
        print(f"Extension {self.name} loaded")```
#

uhh

#

i did not know this existed

weak sequoia
#

i imagine thatd break it laugh

mental adder
#

My bad keepincool

#

lemme test

weak sequoia
#

smh, i span up a new venv for you

mental adder
#

now it doesnt work and throws no error

weak sequoia
#

whats the error

mental adder
weak sequoia
#

read the error bud

mental adder
#

took like 5 seconds to throw

weak sequoia
#

requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='aws.random.cat', port=443): Max retries exceeded with url: /meow (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x00000243BAF739D0>, 'Connection to aws.random.cat timed out. (connect timeout=None)'))

#

#general literally talked about this earlier πŸ˜…

#

#general message

mental adder
#

aww

#

sorry i didnt know

weak sequoia
#

all wokrin otherwise?

mental adder
#

the ctx.send in my code has await

weak sequoia
#

tracemalloc is a built into python

import tracemalloc

tracemalloc.start()
gentle gale
mental adder
#

But i dont have to do that on my other bots

weak sequoia
#

i dont know what to tell you. i cant see all your other bots. if youre using the debug ext in them its enabled automatically

#

the error suggests youre calling bot.start from inside an event loop. which wont work, you want await bot.astart which is the asynchronous version

mental adder
#

ill try and fix this

weak sequoia
#

from utils.keep_alive import start whats this?

mental adder
weak sequoia
#

idk enough about your codebase to find the error, but its not a lib error

mental adder
#

i can push the code to github and then you can see the full code

weak sequoia
#

ill be honest, i dont have time to review your entire codebase πŸ˜…

#

tracemalloc should help you track down wherever the issue is

mental adder
#

ok thanks

#

thanks for the help

weak sequoia
#

np, gl

mental adder