How would I utilize the new InteractionContext type?

I have this code currently:
return components {
if (references.any() && referencedNotes.isNotEmpty()) {
ephemeralStringSelectMenu {
placeholder = "Referenced notes"

references.take(25).forEach { result ->
val noteName = result.groupValues[1]

val referencedNote =
referencedNotes.filter { it.aliases.contains(noteName) }.random()

option(noteName, referencedNote._id.toString(16))
}

action {
edit {
viewNoteResponse(referencedNotes.first { it._id.toString(16) == selected.first() }, text)
}
}
}
}
}
return components {
if (references.any() && referencedNotes.isNotEmpty()) {
ephemeralStringSelectMenu {
placeholder = "Referenced notes"

references.take(25).forEach { result ->
val noteName = result.groupValues[1]

val referencedNote =
referencedNotes.filter { it.aliases.contains(noteName) }.random()

option(noteName, referencedNote._id.toString(16))
}

action {
edit {
viewNoteResponse(referencedNotes.first { it._id.toString(16) == selected.first() }, text)
}
}
}
}
}
viewNoteResponse is an extension in both PublicInteractionContext and EphemeralInteractionContext. I assume I would change the receiver to an InteractionContext and then remove the duplicate, but it gives me a type mismatch error when trying to use it where it was being used previously. what should I do to use this new type?
Solution:
it should probably be InteractionContext<*, *, *, *> right
Jump to solution
10 Replies
gdude
gdude12mo ago
what's the full error?
nanobears
nanobears12mo ago
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
private final suspend fun InteractionContext<InteractionResponseBehavior, MessageInteractionResponse, FollowupMessage, FollowupMessage>.viewNoteResponse(note: Note, text: Boolean): Unit defined in cafe.ferret.kosekata.extensions.ViewingExtension
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
private final suspend fun InteractionContext<InteractionResponseBehavior, MessageInteractionResponse, FollowupMessage, FollowupMessage>.viewNoteResponse(note: Note, text: Boolean): Unit defined in cafe.ferret.kosekata.extensions.ViewingExtension
gdude
gdude12mo ago
hmm, what receiver are you using on your function?
Solution
gdude
gdude12mo ago
it should probably be InteractionContext<*, *, *, *> right
nanobears
nanobears12mo ago
oh that just works thanks for the guidance 🙏
gdude
gdude12mo ago
no worries, I'll set up a typealias for you
nanobears
nanobears12mo ago
:O
gdude
gdude12mo ago
pushed GenericInteractionContext - should be published in about 15 mins
nanobears
nanobears12mo ago
thank you!
gdude
gdude12mo ago
yw o7
Want results from more Discord servers?
Add your server