#class | interection

1 messages · Page 1 of 1 (latest)

slender delta
#

You can pass the interaction object to __init__

haughty cove
slender delta
#

This is how classes work: ```py
class Thing:
def init(self, a, b, c):
...

x = 123
y = "abc"
z = [1, 2, 3]
thing = Thing(x, y, z)

#

If you add parameters to __init__, you have to pass them during instantiation

haughty cove
#

thing = Thing(inter)

#

so?

slender delta
haughty cove
#

ok

#

class ProductView(disnake.ui.View):
def init(self):
super().init()

    self.add_item(Product(inter))
#

here

slender delta
#

Honestly I'm giving hints about basic python at this point. Consider reading more about classes

slender delta
#

So, once again, you have to add it to ProductView's init

#

And pass it during instantiation

#

I'm assuming that inter is coming from a slash command

slender delta
haughty cove
# slender delta In that slash command, instantiate your view like so ^
     await inter.response.edit_message(embed=shop, view=ProductView(inter))
 line 126, in __init__
     self.add_item(Product(inter))
 line 75, in __init__
     self.add_option(label=product_name, description=price + " руб. | В наличии " + availability, emoji=":package:")```

AttributeError: '_MissingSentinel' object has no attribute 'options'
slender delta
slender delta
#

Instead of calling self.add_option, call options.append

haughty cove
slender delta
#

You should be able to fix this yourself

#

options is a list of disnake.SelectOption instances

#

Therefore you should append disnake.SelectOption instances

haughty cove
#
            disnake.SelectOption(label="Назад", emoji=":arrow_left:")
        ]

        self.append_option(label=product_name, description=price + " руб. | В наличии " + availability, emoji=":package:")```
haughty cove
slender delta
haughty cove
#
self.options.append(label=product_name, description=price + " руб. | В наличии " + availability, emoji=":package:")```
#

so?

#

AttributeError: '_MissingSentinel' object has no attribute 'options'

slender delta
#

bruh

slender delta
#

Just options

#

It's literally your variable's name

haughty cove
slender delta
haughty cove
#

and what to do?

slender delta