#All functions are awaited but im still getting RuntimeWarning

1 messages · Page 1 of 1 (latest)

cunning barn
#

im getting this error at random moment in bot's lifetime, but it seems it only happens once

C:\Users\SeaSon\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ui\view.py:548: RuntimeWarning: coroutine 'select_role_view2.refresh' was never awaited view.refresh( RuntimeWarning: Enable tracemalloc to get the object allocation traceback

is this something from my code or from disnake?

here is my code

class select_role_view2(disnake.ui.View):
    def __init__(self, inter):
        super().__init__(timeout=None)
        for role in config.tag_list.keys():
            if role not in queue_ulti.user_get_tag(inter.author):
                self.add_item(role_button2(role, disnake.ButtonStyle.grey))
            else:
                self.add_item(role_button2(role, disnake.ButtonStyle.blurple))

    async def refresh(self, inter):
        for child in [c for c in self.children if isinstance(c, disnake.ui.Button) == True]:
                if inter.data.custom_id == child.custom_id:
                    if child.role not in queue_ulti.user_get_tag(inter.author):
                        await inter.author.add_roles(config.roles_instances[child.role])
                        child.style = disnake.ButtonStyle.blurple
                    else:
                        await inter.author.remove_roles(config.roles_instances[child.role])
                        child.style = disnake.ButtonStyle.grey
        await inter.response.edit_message(content="pick role",view=self)

class role_button2(disnake.ui.Button):
    def __init__(self, role, color):
        self.role = role
        super().__init__(
            custom_id=f"role_{role}",
            label=role,
            style=color
            )

    async def callback(self, inter: disnake.MessageInteraction):
        await self.view.refresh(inter)```
hasty lake
#

refresh is an internal method

#

you're overwriting it

#

the solution is to rename your method

#

we could/should probably underscore that attribute

rose cragBOT
#

disnake/ui/view.py line 394

def refresh(self, components: List[ActionRowComponent[MessageComponent]]):
cunning barn