#Passing variables on or something?
1 messages · Page 1 of 1 (latest)
Yes
No...
You pass the variable to the class, and receive such variable on the class init
And then you make it a class attribute
Then you need to learn OOP.
Pycord is based on OOP
You will keep getting stuck
"For such a simple thing"
you need that for every discord bot
just learn OOP frfr
it'd prob be smth like```py
classname:
def init(self, variablename):
self.varname = variablename
def button_callback(args):
await ctx.send(self.varname)``` no clue what exactly you are doing tho
Thats correct
Except classname should be Classname(discord.ui.View):
Because youre subclassing a view
fair
And you have to add super().__init__() inside your init
Here's the confirm example.
That's a simple example ^
do i HAVE to? i mean for alot of stuff it works without, depending on whats done
You have to
super init inits the View class which gives you attributes, methods and other stuff for the view to work
hmhm
only really used attributes in view classes once
Usually just have like 2-3 buttons inside it and not even an init def lol
Can you pass variables to a modal in similar way?
(answer is yes, got it working) ty for useful info from this thread
.close
Done with your help thread?
Please close your own help thread by using </close:1009144375709814897> with @tight vector.
Backup bot: </solved:1109625445990793246> (or
.solved) with @torn hound.