Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poll permissions, events, and other related changes #1226

Merged
merged 42 commits into from
Sep 27, 2024

Conversation

valzargaming
Copy link
Member

@valzargaming
Copy link
Member Author

I'm running out of time to be able to work on this, if someone can please finish this up.

@valzargaming valzargaming force-pushed the valzargaming-polls branch 2 times, most recently from 797ad74 to cdd772b Compare May 10, 2024 18:25
@Log1x Log1x marked this pull request as ready for review July 18, 2024 21:27
@Log1x
Copy link
Collaborator

Log1x commented Jul 18, 2024

This should be about ready once discord-php/DiscordPHP-Http#28 is merged.

The only thing I was unsure of is the namespace for the poll create request part. I feel like it should still be named Poll so I put it in its own Request namespace similar to interactions.

Example usage:

use Discord\Builders\MessageBuilder;
use Discord\Parts\Channel\Poll\Poll;

$message = MessageBuilder::new();

$poll = new Poll($this->discord());

$poll = $poll
    ->setQuestion('What is your favorite color?')
    ->setAnswers(['Red', 'Green', 'Blue'])
    ->setDuration(1)
    ->setAllowMultiselect(true);

$message->setPoll($poll);

$channel->sendMessage($message);

Screenshot

$discord->on(Event::MESSAGE_POLL_VOTE_ADD, function (PollAnswer $answer, Discord $discord) {
    //
});

$discord->on(Event::MESSAGE_POLL_VOTE_REMOVE, function (PollAnswer $answer, Discord $discord) {
    //
});

Copy link
Member

@SQKo SQKo left a comment

Choose a reason for hiding this comment

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

Many things need to be adjusted, and in my opinion there should be repository for poll, the way it works will be similar to Reaction repositories

src/Discord/Parts/Channel/Poll.php Outdated Show resolved Hide resolved
src/Discord/Parts/Channel/Poll.php Outdated Show resolved Hide resolved
src/Discord/Parts/Channel/Poll/PollResults.php Outdated Show resolved Hide resolved
src/Discord/Parts/Thread/Thread.php Outdated Show resolved Hide resolved
src/Discord/WebSockets/Events/MessagePollVoteAdd.php Outdated Show resolved Hide resolved
src/Discord/WebSockets/Events/MessagePollVoteRemove.php Outdated Show resolved Hide resolved
src/Discord/Parts/Channel/Poll.php Outdated Show resolved Hide resolved
@Log1x Log1x marked this pull request as draft July 21, 2024 17:13
protected $fillable = [
'id',
'count',
'me_voted',
Copy link
Collaborator

Choose a reason for hiding this comment

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

im not sure how to handle me_voted in this context.

Copy link
Member Author

Choose a reason for hiding this comment

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

The documentation for this is just "Whether the current user voted for this answer" so I think it's something the API endpoint fills in based on who requested the data. It's probably used for something in the normal user client. Because bots can't vote anyway this should always be false and can be ignored.

@valzargaming valzargaming marked this pull request as ready for review August 13, 2024 05:42
@valzargaming valzargaming requested review from Log1x and SQKo August 13, 2024 05:42
@valzargaming
Copy link
Member Author

Codacy is just complaining about a variable named $id being too short and can be safely ignored

@valzargaming valzargaming merged commit e584be6 into master Sep 27, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants