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
gdude14mo ago
what's the full error?
nanobears
nanobearsOP14mo 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
gdude14mo ago
hmm, what receiver are you using on your function?
Solution
gdude
gdude14mo ago
it should probably be InteractionContext<*, *, *, *> right
nanobears
nanobearsOP14mo ago
oh that just works thanks for the guidance 🙏
gdude
gdude14mo ago
no worries, I'll set up a typealias for you
nanobears
nanobearsOP14mo ago
:O
gdude
gdude14mo ago
pushed GenericInteractionContext - should be published in about 15 mins
nanobears
nanobearsOP13mo ago
thank you!
gdude
gdude13mo ago
yw o7
Want results from more Discord servers?
Add your server