UNPKG

@lilybird/transformers

Version:
47 lines (46 loc) 1.48 kB
import { Message } from "./message.js"; import { User } from "./user.js"; export class PollAnswer { channelId; messageId; id; media; client; constructor(client, channelId, messageId, answer) { this.client = client; this.channelId = channelId; this.messageId = messageId; this.id = answer.answer_id; this.media = answer.poll_media; } async fetchVoters(params = {}) { const voters = await this.client.rest.getAnswerVoters(this.channelId, this.messageId, this.id, params); return voters.users.map((voter) => new User(this.client, voter)); } } export class Poll { channelId; messageId; question; answers; expiresTimestamp; allowMultiselect; layoutType; results; client; constructor(client, channelId, messageId, poll) { this.client = client; this.channelId = channelId; this.messageId = messageId; this.question = poll.question; this.answers = poll.answers.map((answer) => new PollAnswer(this.client, this.channelId, this.messageId, answer)); this.allowMultiselect = poll.allow_multiselect; this.layoutType = poll.layout_type; this.results = poll.results; if (poll.expiry != null) this.expiresTimestamp = new Date(poll.expiry); } async end() { return new Message(this.client, await this.client.rest.endPoll(this.channelId, this.messageId)); } }