#Javadiscord api constructor error

53 messages · Page 1 of 1 (latest)

fringe cairn
#

hello guys i am using jda and working on my project, i have created botjokerservice which gives random jokes on request now i am trying to save this random quotes on my h2 runtime database but its not working

gentle hingeBOT
#

This post has been reserved for your question.

Hey @fringe cairn! Please use /close or the Close Post button 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.

fringe cairn
#

my service code

#

error

#

its some kind of constructor error i guess

tacit beacon
#

yes, you are calling a constructor which does not exist, there is no no-arg constructor for BotJokeService

fringe cairn
#

i have already created constructor for my

#

playerrepository

#

but here it still gives error

#

even if i try here new BotJokerService (PlayerRepository playerRepostiory)

tacit beacon
fringe cairn
#

here

fringe cairn
#

up

tacit beacon
#

you don't declare the type of the argument when calling a constructor

#

only the name of the variable you're passing to it

fringe cairn
#

how to declear i dont get it

tacit beacon
#

constructor call works like method call (kind of)

#

you call it only with the names of the arguments

#

not the types

fringe cairn
#

look

#

this is my botjoke service

#

everything works fine here

#

everything is defined

#

now i want that my jda

tacit beacon
#

yes, the problem is with the invokation of the constructor, not the constructor itself

fringe cairn
#

listen to botjokesservice app

#

here

#

what to do here i dont get that

tacit beacon
#

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

fringe cairn
#

i changed that

#

it gives exception

tacit beacon
#

because the playerRepository variable doesn't refer to a PlayerRepository, it is uninitialized

fringe cairn
#

how to initialize

tacit beacon
#

set it to something

#

most likely, a new instance of PlayerRepository

fringe cairn
#

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 ?