#Javadiscord api constructor error
53 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @fringe cairn! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
yes, you are calling a constructor which does not exist, there is no no-arg constructor for BotJokeService
i have already created constructor for my
playerrepository
but here it still gives error
even if i try here new BotJokerService (PlayerRepository playerRepostiory)
post screenshot of that
up
you don't declare the type of the argument when calling a constructor
only the name of the variable you're passing to it
how to declear i dont get it
constructor call works like method call (kind of)
you call it only with the names of the arguments
not the types
look
this is my botjoke service
everything works fine here
everything is defined
now i want that my jda
yes, the problem is with the invokation of the constructor, not the constructor itself
here, you don't call the argument "PlayerRepository playerRepository", the type is already known, you don't need to specify it
you need a variable of type PlayerRepository
so that you can call the constructor like new BotJokeService(playerRepository) such that playerRepository is a variable contains a PlayerRepository
same as method call
you cannot call the constructor with no arguments, because there is no no-argument constructor
because the playerRepository variable doesn't refer to a PlayerRepository, it is uninitialized
how to initialize
its kind of paradox my brain is exploding , on my botjokeservice side everything goes fine its constructor everything to make my service class work i have to put it in jda context whenever i try to do that new BotjokeService(); everything goes crazy i dont know how to initilize my repository i just dont get it
cant i here say that i want my super classes constructor ?