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

@@ -543,8 +543,7 @@ class Client extends EventEmitter {
}
}
});
window.Store.PollVote.on('add', (vote) => window.onPollVote)
window.Store.PollVote.on('add', (vote) => window.onPollVote(vote));
{
const module = window.Store.createOrUpdateReactionsModule;
const ogMethod = module.createOrUpdateReactions;

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);
}
}

View File

@@ -407,7 +407,7 @@ exports.LoadUtils = () => {
}
if (msg.type == 'poll_creation') {
msg.pollVotes = Store.PollVote.getForParent(msg.id).getModelsArray().map(a => a.serialize());
msg.pollVotes = window.Store.PollVote.getForParent(msg.id).getModelsArray().map(a => a.serialize());
}
delete msg.pendingAckUpdate;
@@ -636,7 +636,7 @@ exports.LoadUtils = () => {
for (const option of selectedOptions) {
if (a.name == option) localIdSet.add(a.localId);
}
})
});
await window.Store.SendVote.sendVote(msg, localIdSet);
}
};
};