PART 2: ESLINT, EXAMPLES & MORE

This commit is contained in:
purpshell
2022-12-23 13:09:01 +02:00
parent a519105870
commit 2020d00ee4
8 changed files with 49 additions and 14 deletions

View File

@@ -50,7 +50,7 @@ class Message extends Base {
* Message content
* @type {string}
*/
this.body = this.hasMedia ? data.caption || '' : data.body || '';
this.body = this.hasMedia ? data.caption || '' : data.body || data.pollName || '';
/**
* Message type
@@ -250,7 +250,7 @@ class Message extends Base {
/** Current poll votes, refresh with Message.refreshPollVotes() */
this.pollVotes = data.pollVotes.map((pollVote) => {
return new PollVote(this.client, pollVote);
return new PollVote(this.client, {...pollVote, pollCreationMessage: this});
});
}
@@ -549,10 +549,10 @@ class Message extends Base {
async refreshPollVotes() {
if (this.type != MessageTypes.POLL_CREATION) throw 'Invalid usage! Can only be used with a pollCreation message';
const pollVotes = await this.client.evaluate((parentMsgId) => {
return Store.PollVote.getForParent(parentMsgId).getModelsArray().map(a => a.serialize())
return window.Store.PollVote.getForParent(parentMsgId).getModelsArray().map(a => a.serialize());
}, this.id);
this.pollVotes = pollVotes.map((pollVote) => {
return new PollVote(this.client, pollVote);
return new PollVote(this.client, {...pollVote, pollCreationMessage: this});
});
return;
}

View File

@@ -1,5 +1,6 @@
'use strict';
const { Message } = require('.');
const Base = require('./Base');
/**
@@ -20,11 +21,14 @@ class PollVote extends Base {
});
/** Sender of the Poll vote */
this.sender = data.sender;
this.sender = data.sender._serialized;
/** Timestamp of the time it was sent in milliseconds */
this.senderTimestampMs = data.senderTimestampMs;
/** The poll creation message associated with the poll vote */
this.parentPollMessage = new Message(this.client, data.pollCreationMessage);
return super._patch(data);
}
}