#Help passing arguments into button callbacks

1 messages · Page 1 of 1 (latest)

rustic harbor
#

how do I pass arguments into button callbacks?
like I would expect you'd do it normally
but I keep getting errors

#

I probably should

#

have used pastebin

#

but I just get

#
Ignoring exception in view <View timeout=None children=8> for item <Button style=<ButtonStyle.primary: 1> url=None disabled=False label='U1' emoji=None row=0>:
Traceback (most recent call last):
  File "/Users/oriontomasi/opt/anaconda3/lib/python3.9/site-packages/disnake/ui/view.py", line 385, in _scheduled_task
    await item.callback(interaction)
TypeError: 'coroutine' object is not callable
#

I'm probably doing something really idiotic

#

please someone help

native lodge
#

Yeah that's not going to work

#

You don't add () when assigning a callback

#

Otherwise the script tries to call the callback first and assign whatever it returns as its callback

rustic harbor
native lodge
#

You don't

rustic harbor
#

oh

#

do I redefine the callbacks inside of the slash command?

native lodge
#

I think you can use custom_id to assign the buttons the upscale value

rustic harbor
#

the codeid is unique every time

#

how would I do that?

native lodge
#

Make a view subclass instead.

#

How long is the code id?

rustic harbor
#

lemme check

#

'497d586c-6d31-434c-9de5-054d0631f484'

#

uuuh

#

like that long

#

thats how long it is

native lodge
#

Then u should be fine

#

custom_id can hold 100 chars

rustic harbor
#

how do I make a view subclass, could you point me to the documentation?

native lodge
#

Either of the examples in the view folder should suffice

rustic harbor
#

k

native lodge
#

Basically make a view. Give it a instance variable that is the code point. Add your 8 buttons using decorators. Reference the self.codepoint during the callback and apply the changes