Skip to content

Implement polls#933

Open
DRSchlaubi wants to merge 31 commits intomainfrom
feature/polls
Open

Implement polls#933
DRSchlaubi wants to merge 31 commits intomainfrom
feature/polls

Conversation

@DRSchlaubi
Copy link
Copy Markdown
Member

No description provided.

@Moortu
Copy link
Copy Markdown

Moortu commented Aug 18, 2024

Would love to see this feature merged after a review, conflicts resolved and fixes

@lukellmann
Copy link
Copy Markdown
Member

Would love to see this feature merged after a review, conflicts resolved and fixes

i can take a look, but i'll be on vacation for a week first

@Moortu
Copy link
Copy Markdown

Moortu commented Aug 19, 2024

Would love to see this feature merged after a review, conflicts resolved and fixes

i can take a look, but i'll be on vacation for a week first

Small world, I'm on vacation rn for a week

Have a good week.
And I look forward to this feature.

I can upgrade my bot in a significant way with it.

@DRSchlaubi
Copy link
Copy Markdown
Member Author

Now ready

DRSchlaubi and others added 5 commits August 25, 2024 13:24
They seem to be here by accident, I already removed them for good in
#944.
All other kord enums use camel case naming.
Copy link
Copy Markdown
Member

@lukellmann lukellmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also missing Permission.SendPolls, Intent.GuildMessagePolls, Intent.DirectMessagePolls

Comment thread common/src/commonMain/kotlin/entity/Interactions.kt Outdated
/**
* Behavior of a Poll message.
*/
public interface PollBehavior : MessageBehavior {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think it's a good idea to have Poll/PollBehavior extend Message/MessageBehavior - a poll is part of a message, not a message itself; it doesn't have a message type; ...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am quite sure poll message can't contain anything but the poll

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that might be true for now, but who knows about the future. conceptually a poll is part of a message.

Comment thread core/src/commonMain/kotlin/behavior/channel/PollParentChannelBehavior.kt Outdated
Comment thread core/src/commonMain/kotlin/behavior/channel/PollParentChannelBehavior.kt Outdated
Comment thread common/src/commonMain/kotlin/entity/DiscordMessage.kt Outdated
Comment thread rest/src/commonMain/kotlin/builder/message/PollBuilder.kt Outdated
Comment on lines +84 to +113
public fun answer(title: String, emojiUnicode: String? = null, id: Int = answers.size) {
require(answers.size < 10) { "Cannot add more than 10 answers" }
answers.add(
DiscordPoll.Answer(
answerId = id,
pollMedia = DiscordPoll.Media(
Optional(title),
Optional(emojiUnicode?.let { DiscordPartialEmoji(name = it) }).coerceToMissing()
)
)
)
}

/**
* Adds an answer with [title] and [emoji].
*
* @param id the answer id
*/
public fun answer(title: String, emoji: Snowflake? = null, id: Int = answers.size) {
require(answers.size < 10) { "Cannot add more than 10 answers" }
answers.add(
DiscordPoll.Answer(
answerId = id,
pollMedia = DiscordPoll.Media(
Optional(title),
Optional(emoji?.let { DiscordPartialEmoji(id = it) }).coerceToMissing()
)
)
)
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the id required to be sent? that is is the answer_id field optional on poll creation? this makes me think it might be:

Only sent as part of responses from Discord's API/Gateway.

*
* @param id the answer id
*/
public fun answer(title: String, emojiUnicode: String? = null, id: Int = answers.size) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could emoji be used for the parameter name instead?

Comment thread gateway/src/commonMain/kotlin/Event.kt
Comment thread gateway/src/commonMain/kotlin/Event.kt
@lukellmann
Copy link
Copy Markdown
Member

also relevant: discord/discord-api-docs#7090

@lukellmann
Copy link
Copy Markdown
Member

also discord/discord-api-docs#7050

@Moortu
Copy link
Copy Markdown

Moortu commented Dec 10, 2024

Any progress?

@lukellmann
Copy link
Copy Markdown
Member

Any progress?

@DRSchlaubi?

@DRSchlaubi
Copy link
Copy Markdown
Member Author

Actually we said that you wanted to finish this haha

@lukellmann
Copy link
Copy Markdown
Member

Actually we said that you wanted to finish this haha

Oh, yeah I forgot about that and have been busy otherwise 😅

@Moortu
Copy link
Copy Markdown

Moortu commented Dec 13, 2025

@lukellmann This one must have dropped out your field of view

@Moortu
Copy link
Copy Markdown

Moortu commented Jan 17, 2026

@DRSchlaubi looking at lukellmann's git activity, I don't think he'll come back to this.
I am a kotlin developer, so I would like to take a crack at it, but I've never contributed to anything before and the whole of how kord works is a mystery to me. So I don't even know if I should attempt it.

What do you think?

@DRSchlaubi
Copy link
Copy Markdown
Member Author

Sure you can take a look at it, but I can't promise that I will get to merging/reviewing it

# Conflicts:
#	common/api/common.api
#	common/api/common.klib.api
#	common/src/commonMain/kotlin/entity/DiscordMessage.kt
#	core/api/core.api
#	core/api/core.klib.api
#	core/src/commonMain/kotlin/cache/data/MessageData.kt
#	core/src/commonMain/kotlin/entity/Message.kt
#	gateway/src/commonMain/kotlin/Event.kt
#	rest/api/rest.api
#	rest/api/rest.klib.api
#	rest/src/commonMain/kotlin/json/JsonErrorCode.kt
#	rest/src/commonMain/kotlin/route/Route.kt
#	rest/src/commonMain/kotlin/service/ChannelService.kt
@NoComment1105
Copy link
Copy Markdown
Contributor

@lukellmann I have taken over this PR here and completed a large volume of your review comments. If you could find the time to review again that would be most appreciated 🙏🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants