-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #337 from MazeXP/feature/polls
Implement polls
- Loading branch information
Showing
74 changed files
with
2,063 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
Backend/Remora.Discord.API.Abstractions/API/Gateway/Events/Polls/IMessagePollVoteAdd.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// IMessagePollVoteAdd.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using JetBrains.Annotations; | ||
using Remora.Rest.Core; | ||
|
||
namespace Remora.Discord.API.Abstractions.Gateway.Events; | ||
|
||
/// <summary> | ||
/// Represents the addition of a vote to a poll. | ||
/// </summary> | ||
/// <remarks>If the poll allows multiple selections, then one event will be sent per answer.</remarks> | ||
[PublicAPI] | ||
public interface IMessagePollVoteAdd : IGatewayEvent | ||
{ | ||
/// <summary> | ||
/// Gets the ID of the user. | ||
/// </summary> | ||
Snowflake UserID { get; } | ||
|
||
/// <summary> | ||
/// Gets the ID of the channel. | ||
/// </summary> | ||
Snowflake ChannelID { get; } | ||
|
||
/// <summary> | ||
/// Gets the ID of the message. | ||
/// </summary> | ||
Snowflake MessageID { get; } | ||
|
||
/// <summary> | ||
/// Gets the ID of the guild. | ||
/// </summary> | ||
Optional<Snowflake> GuildID { get; } | ||
|
||
/// <summary> | ||
/// Gets the ID of the answer. | ||
/// </summary> | ||
int AnswerID { get; } | ||
} |
59 changes: 59 additions & 0 deletions
59
Backend/Remora.Discord.API.Abstractions/API/Gateway/Events/Polls/IMessagePollVoteRemove.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// IMessagePollVoteRemove.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using JetBrains.Annotations; | ||
using Remora.Rest.Core; | ||
|
||
namespace Remora.Discord.API.Abstractions.Gateway.Events; | ||
|
||
/// <summary> | ||
/// Represents the removal of a vote to a poll. | ||
/// </summary> | ||
/// <remarks>If the poll allows multiple selections, then one event will be sent per answer.</remarks> | ||
[PublicAPI] | ||
public interface IMessagePollVoteRemove : IGatewayEvent | ||
{ | ||
/// <summary> | ||
/// Gets the ID of the user. | ||
/// </summary> | ||
Snowflake UserID { get; } | ||
|
||
/// <summary> | ||
/// Gets the ID of the channel. | ||
/// </summary> | ||
Snowflake ChannelID { get; } | ||
|
||
/// <summary> | ||
/// Gets the ID of the message. | ||
/// </summary> | ||
Snowflake MessageID { get; } | ||
|
||
/// <summary> | ||
/// Gets the ID of the guild. | ||
/// </summary> | ||
Optional<Snowflake> GuildID { get; } | ||
|
||
/// <summary> | ||
/// Gets the ID of the answer. | ||
/// </summary> | ||
int AnswerID { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
Backend/Remora.Discord.API.Abstractions/API/Objects/Polls/IPoll.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// | ||
// IPoll.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using JetBrains.Annotations; | ||
using Remora.Rest.Core; | ||
|
||
namespace Remora.Discord.API.Abstractions.Objects; | ||
|
||
/// <summary> | ||
/// Represents a poll. | ||
/// </summary> | ||
[PublicAPI] | ||
public interface IPoll | ||
{ | ||
/// <summary> | ||
/// Gets the question of the poll. | ||
/// </summary> | ||
IPollMedia Question { get; } | ||
|
||
/// <summary> | ||
/// Gets a list of each available answer in the poll. | ||
/// </summary> | ||
IReadOnlyList<IPollAnswer> Answers { get; } | ||
|
||
/// <summary> | ||
/// Gets the time when the poll ends. | ||
/// </summary> | ||
DateTimeOffset? Expiry { get; } | ||
|
||
/// <summary> | ||
/// Gets a value indicating whether a user can select multiple answers. | ||
/// </summary> | ||
bool IsMultiselectAllowed { get; } | ||
|
||
/// <summary> | ||
/// Gets the layout type of the poll. | ||
/// </summary> | ||
PollLayoutType LayoutType { get; } | ||
|
||
/// <summary> | ||
/// Gets the results of the poll. | ||
/// </summary> | ||
Optional<IPollResults> Results { get; } | ||
} |
43 changes: 43 additions & 0 deletions
43
Backend/Remora.Discord.API.Abstractions/API/Objects/Polls/IPollAnswer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// IPollAnswer.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using JetBrains.Annotations; | ||
using Remora.Rest.Core; | ||
|
||
namespace Remora.Discord.API.Abstractions.Objects; | ||
|
||
/// <summary> | ||
/// Represents a poll answer. | ||
/// </summary> | ||
[PublicAPI] | ||
public interface IPollAnswer | ||
{ | ||
/// <summary> | ||
/// Gets the ID of the answer. | ||
/// </summary> | ||
Optional<int> AnswerID { get; } | ||
|
||
/// <summary> | ||
/// Gets the data of the answer. | ||
/// </summary> | ||
IPollMedia PollMedia { get; } | ||
} |
47 changes: 47 additions & 0 deletions
47
Backend/Remora.Discord.API.Abstractions/API/Objects/Polls/IPollAnswerCount.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// IPollAnswerCount.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using JetBrains.Annotations; | ||
|
||
namespace Remora.Discord.API.Abstractions.Objects; | ||
|
||
/// <summary> | ||
/// Represents a count for a poll answer. | ||
/// </summary> | ||
[PublicAPI] | ||
public interface IPollAnswerCount | ||
{ | ||
/// <summary> | ||
/// Gets the ID of the answer. | ||
/// </summary> | ||
int ID { get; } | ||
|
||
/// <summary> | ||
/// Gets the number of votes for this answer. | ||
/// </summary> | ||
int Count { get; } | ||
|
||
/// <summary> | ||
/// Gets a value indicating Whether the current user has voted for this answer. | ||
/// </summary> | ||
bool HasCurrentUserVoted { get; } | ||
} |
Oops, something went wrong.