I'm having a problem with delivering a variable value to a function inside a class.
The specific issue occurs in the following code:
@discord.ui.select(
row = 0,
options = self.r
)
Here is the relevant code for the class:
class MyView(discord.ui.View):
def __init__(self, no):
super().__init__()
self.no = no
self.manga = None
self.chapters = None
self.startnum = -25
self.endnum = 0 # add 25
self.twentyfives = 0
self.r = []
r = []
for i in data:
if str(i["MangaName"]).lower() == no:
self.manga =i
break
if self.manga != None:
self.chapters = int(self.manga["ChaptersNumber"])
self.twentyfives = (self.chapters // 25)+1
self.startnum += 25
if self.endnum + 25 > self.chapters:
self.endnum = self.chapters
else:
self.endnum +=25
self.startnum +=25
for title in range(self.startnum,self.endnum):
self.r.append(discord.SelectOption(
label=self.manga["Chaptersinfo"][title]))
r = self.r
@discord.ui.select(
row = 0,
options = self.r
)
async def select_callback(self, select, interaction): # the function called when the user is done selecting options
manga_selected = select.values[0]
await interaction.response.send_message(f"Awesome! I like {select.values[0]} too!")
i tried using different function to store the data then receive it again but it didn't work and i tried to let
async def select_callback
and
@discord.ui.select
inside the class but the async def select_callback didn't work and the options didn't show