Nextcord AttributeError

32 Views Asked by At

This error has happened ever since I changes the API requests to async using aiohttp and I really dont understand what is happening I have all I know its saying coroutine object has no attribute edit I'm hoping someone might able to figure this out but I am still going to be trying myself, if you can see the issue could you explain it to me thank you.

class SeedPingHLL(commands.Cog):

    
    def __init__(self, legionnaire):

        self.legionnaire = legionnaire
        self.check_to_start_seed_ping.start()


    #Here were passing a loop into the view embed and updating when new players have joined will update enbeded view to new player count until seeding completed
    @tasks.loop(time=Start_seeding_time)
    async def check_to_start_seed_ping(self):
        print("Task started")
        while True:
            ##need a while loop and stops the while loop but is ready for the next time!
            players = await api_request_public()
            event_check = await Seed_API()
            min_player_count = await Seed_API()
            #if event_check[0] == False and self.seed_ping_hll.is_running() == False:
            if event_check[0] == False and self.seed_ping_hll.is_running() == False:
                if players[1] >= 1:
                #if players[1] >= min_player_count[1]:
                    print("started")
                    seed_channel = self.legionnaire.get_channel(Channel_id)
                    seed_ping = seed_channel.send(embed=await Seed_Ping_Embed())
                    
                    self.seed_ping_hll.start(seed_ping)
                    break
            #await asyncio.sleep(1.0)
            
    
    @tasks.loop(minutes=1.0)
    async def seed_ping_hll(self, seed_ping_message):
        
        player_count_end_seeding = await Seed_API()

        players = await api_request_public()
        
        await seed_ping_message.edit(embed =Seed_Ping_Embed())
        await asyncio.sleep(0.3)
        print("player checked")

        if players[1] > player_count_end_seeding[2]:
            seed_ping_message.edit(embed = await Seed_Ping_Embed(server_seeded=True,))
            print("stopping")
            self.seed_ping_hll.cancel()
            players_vip_reward_check()

Terminal error:

sys:1: RuntimeWarning: coroutine 'Messageable.send' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Task exception was never retrieved
future: <Task finished name='Task-25' coro=<Loop._loop() done, defined at C:\Users\shazd\AppData\Local\pypoetry\Cache\virtualenvs\lost-legionnaire-9AFMHyBb-py3.12\Lib\site-packages\nextcord\ext\tasks\__init__.py:128> exception=TypeError('Loop._error() takes 2 positional arguments but 3 were given')>
Traceback (most recent call last):
  File "C:\Users\shazd\AppData\Local\pypoetry\Cache\virtualenvs\lost-legionnaire-9AFMHyBb-py3.12\Lib\site-packages\nextcord\ext\tasks\__init__.py", line 145, in _loop
    await self.coro(*args, **kwargs)
  File "C:\Users\shazd\lost-legionnaire\lost_legionnaire\cogs\SeedPingHLL.py", line 78, in seed_ping_hll
    seed_ping_message.edit(embed = await Seed_Ping_Embed())
    ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'coroutine' object has no attribute 'edit'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\shazd\AppData\Local\pypoetry\Cache\virtualenvs\lost-legionnaire-9AFMHyBb-py3.12\Lib\site-packages\nextcord\ext\tasks\__init__.py", line 173, in _loop
    await self._call_loop_function("error", exc)
  File "C:\Users\shazd\AppData\Local\pypoetry\Cache\virtualenvs\lost-legionnaire-9AFMHyBb-py3.12\Lib\site-packages\nextcord\ext\tasks\__init__.py", line 120, in _call_loop_function
    await coro(self._injected, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Loop._error() takes 2 positional arguments but 3 were given

I have added await to functions that needed it but with the coroutine object has no attribute edit I don't know what the issue could be now as it was at first an await issue now I have no clue.

1

There are 1 best solutions below

0
Shannonlee Gafney On

So changing an API requests back to using requests and then adding in await before sending messaging to the channel here

seed_ping = await seed_channel.send(embed= Seed_Ping_Embed())

and

await seed_ping_message.edit(embed=Seed_Ping_Embed())

This seemed to have worked