#I don't understand what the error is, I don't understand why

1 messages · Page 1 of 1 (latest)

blazing cosmos
#

Error:

future: <Task finished name='disnake-ui-modal-dispatch-chat:mute' coro=<Modal._scheduled_task() 
done, defined at C:\Users\AR\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ui\modal.py:206> exception=KeyError((947586139911491635, 'chat:mute'))>
Traceback (most recent call last):
  File "C:\Users\AR\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ui\modal.py", line 215, in _scheduled_task
    interaction._state._modal_store.remove_modal(
  File "C:\Users\AR\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ui\modal.py", line 237, in remove_modal
    return self._modals.pop((user_id, modal_custom_id))
KeyError: (947586139911491635, 'chat:mute')```
#

Code:

class Chat_Modal_Mute(dis.ui.Modal):
    def __init__(self,user:dis.Member = None):
        self.user = user
        components = [
            TextInput(
                label='Причина',
                style=TextInputStyle.short,
                required=False,
                placeholder='Пример: Злостный нарушитель 1.2',
                custom_id='chat:mute-reason'
            ),
            TextInput(
                label='Время',
                style=TextInputStyle.short,
                max_length=3,
                placeholder='Пример: 10d,10h,10m,10s',
                custom_id='chat:mute-time',
                required=False                
            )
        ]
        super().__init__(title='Мут',custom_id='chat:mute',components=components)
    async def callback(self, interaction: dis.ModalInteraction):
        mute = interaction.guild.get_role(1036166964973944902)
        await interaction.response.defer(with_message=True,ephemeral=True)
        values = interaction.text_values
        reason = values['chat:mute-reason']
        time = values['chat:mute-time']
        if mute in self.user.roles:
            embed0 = Embed(description = f'{interaction.author.mention}, Этот человек уже находится в муте',colour=0xf80c0c)
            embed0.set_author(name=f'Ошибка',icon_url=str(f'https://media.discordapp.net/attachments/1030714278459752508/1037800787734175864/998972502518800423-1.png'),)
            await interaction.edit_original_message(embed = embed0)
        else:
            if await mute_chat(inter = interaction,time=time,reason=reason,member=self.user) == 'error':
                await interaction.edit_original_message('Ошибка')```
zealous comet
#

oh hmm

#

does that error always happen?

#

also, how are you sending the modal?

blazing cosmos
#

No she appears sometimes

#

It appears when submit model sometimes

#

Although I don't know for sure

zealous comet
#

@cinder mural sorry for ping, but it looks like this is a race condition?

zealous comet
#

it would be useful to debug that

cinder mural
#

There are a few things that could be happening here

#

do you have a way of consistently reproducing it?

blazing cosmos
blazing cosmos
cinder mural
#

Is there a specific set of steps to do to get this error, or does it happen randomly?

blazing cosmos
#

Random

#

It all works, but sometimes it appears

cinder mural
#

Hmm, alright

zealous comet
#

maybe ModalStore._modals data is being deleted somehow?

cinder mural
#

it's probably a race condition between two modals, since they're only keyed by author + custom ID

zealous comet
#

but this is the first time I see that error hmm

zealous comet
#

that'd be a... rare case

cinder mural
#

In any case, you should be able to work around that by making the custom IDs more unique, e.g. by adding the interaction ID of the slash command that triggered the modal (chat:mute-1234123412341234)

blazing cosmos
#

The problem is with the Custom ID?

zealous comet
#

you could probably mark this as lib bug