#class | interection
1 messages · Page 1 of 1 (latest)
TypeError: init() missing 1 required positional argument: 'inter'
Yeah you should pass the interaction object when you make an instance
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
yeah
In your case Thing is Product
ok
class ProductView(disnake.ui.View):
def init(self):
super().init()
self.add_item(Product(inter))
here
Honestly I'm giving hints about basic python at this point. Consider reading more about classes
Well, here inter is not defined
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
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'
could you please show Product.__init__?
options remains an empty list
Instead of calling self.add_option, call options.append
TypeError: append_option() got an unexpected keyword argument 'label'
You should be able to fix this yourself
options is a list of disnake.SelectOption instances
Therefore you should append disnake.SelectOption instances
disnake.SelectOption(label="Назад", emoji=":arrow_left:")
]
self.append_option(label=product_name, description=price + " руб. | В наличии " + availability, emoji=":package:")```
there is nothing in the default options, then in the future the option is added
Use options.append(...)
self.options.append(label=product_name, description=price + " руб. | В наличии " + availability, emoji=":package:")```
so?
AttributeError: '_MissingSentinel' object has no attribute 'options'
bruh
Not self.options
Just options
It's literally your variable's name
TypeError: list.append() takes no keyword arguments
because you should append disnake.SelectOption instances...
and what to do?
If it's not clear yet, here's a hint: ```py
options.append(disnake.SelectOption(label=..., description=..., ...))