feat: message poll

#1150 #1147
This commit is contained in:
Elysia
2024-07-03 21:31:45 +07:00
parent e6e9febe8c
commit 485dab55bf
16 changed files with 545 additions and 87 deletions

View File

@@ -0,0 +1,22 @@
'use strict';
const { Events } = require('../../../util/Constants');
module.exports = (client, { d: data }) => {
/**
* Poll Vote Structure
* @see {@link https://docs.discord.sex/resources/message#poll-results-structure}
* @typedef {Object} MessagePollUserVote
* @property {Snowflake} user_id ID of the user
* @property {Snowflake} channel_id ID of the channel
* @property {Snowflake} message_id ID of the message
* @property {?Snowflake} guild_id ID of the guild
* @property {number} answer_id ID of the answer
*/
/**
* Emitted when a user votes on a poll. If the poll allows multiple selection, one event will be sent per answer.
* @event Client#messagePollVoteAdd
* @param {MessagePollUserVote} data Raw data
*/
client.emit(Events.MESSAGE_POLL_VOTE_ADD, data);
};

View File

@@ -0,0 +1,12 @@
'use strict';
const { Events } = require('../../../util/Constants');
module.exports = (client, { d: data }) => {
/**
* Emitted when a user removes their vote on a poll. If the poll allows for multiple selections, one event will be sent per answer.
* @event Client#messagePollVoteRemove
* @param {MessagePollUserVote} data Raw data
*/
client.emit(Events.MESSAGE_POLL_VOTE_REMOVE, data);
};

View File

@@ -10,7 +10,7 @@ module.exports = (client, { d: data }) => {
* Emitted when a relationship is removed, relevant to the current user.
* @event Client#relationshipRemove
* @param {Snowflake} user The userID that was updated
* @param {RelationshipTypes} type The type of the old relationship
* @param {RelationshipType} type The type of the old relationship
* @param {string | null} nickname The nickname of the user in this relationship (1-32 characters)
*/
client.emit(Events.RELATIONSHIP_REMOVE, data.id, data.type, data.nickname);

View File

@@ -5,7 +5,7 @@ const { Events } = require('../../../util/Constants');
module.exports = (client, { d: data }) => {
/**
* @typedef {Object} RelationshipUpdateObject
* @property {RelationshipTypes} type The type of relationship
* @property {RelationshipType} type The type of relationship
* @property {Date} since When the user requested a relationship
* @property {string | null} nickname The nickname of the user in this relationship (1-32 characters)
*/

View File

@@ -76,6 +76,8 @@ const handlers = Object.fromEntries([
['USER_SETTINGS_UPDATE', require('./USER_SETTINGS_UPDATE')],
['USER_GUILD_SETTINGS_UPDATE', require('./USER_GUILD_SETTINGS_UPDATE')],
['VOICE_CHANNEL_STATUS_UPDATE', require('./VOICE_CHANNEL_STATUS_UPDATE')],
['MESSAGE_POLL_VOTE_ADD', require('./MESSAGE_POLL_VOTE_ADD')],
['MESSAGE_POLL_VOTE_REMOVE', require('./MESSAGE_POLL_VOTE_REMOVE')],
]);
module.exports = handlers;