Skip to content

Commit 5a656b8

Browse files
almeidxJiralite
andauthored
refactor(PollAnswer)!: remove fetchVoters (#11059)
BREAKING CHANGE: The `PollAnswer#fetchVoters` method has been removed. Use `PollAnswer#voters#fetch` instead. Co-authored-by: Jiralite <[email protected]>
1 parent bb67f3c commit 5a656b8

File tree

4 files changed

+14
-29
lines changed

4 files changed

+14
-29
lines changed

packages/discord.js/src/managers/PollAnswerVoterManager.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ class PollAnswerVoterManager extends CachedManager {
3030
* @name PollAnswerVoterManager#cache
3131
*/
3232

33+
/**
34+
* Options used for fetching voters of a poll answer.
35+
*
36+
* @typedef {Object} BaseFetchPollAnswerVotersOptions
37+
* @property {number} [limit] The maximum number of voters to fetch
38+
* @property {Snowflake} [after] The user id to fetch voters after
39+
*/
40+
3341
/**
3442
* Fetches the users that voted on this poll answer. Resolves with a collection of users, mapped by their ids.
3543
*

packages/discord.js/src/structures/PollAnswer.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,25 +93,6 @@ class PollAnswer extends Base {
9393
get partial() {
9494
return this.poll.partial || (this.text === null && this.emoji === null);
9595
}
96-
97-
/**
98-
* Options used for fetching voters of a poll answer.
99-
*
100-
* @typedef {Object} BaseFetchPollAnswerVotersOptions
101-
* @property {number} [limit] The maximum number of voters to fetch
102-
* @property {Snowflake} [after] The user id to fetch voters after
103-
*/
104-
105-
/**
106-
* Fetches the users that voted for this answer.
107-
*
108-
* @param {BaseFetchPollAnswerVotersOptions} [options={}] The options for fetching voters
109-
* @returns {Promise<Collection<Snowflake, User>>}
110-
* @deprecated Use {@link PollAnswerVoterManager#fetch} instead
111-
*/
112-
async fetchVoters({ after, limit } = {}) {
113-
return this.voters.fetch({ after, limit });
114-
}
11596
}
11697

11798
exports.PollAnswer = PollAnswer;

packages/discord.js/test/polls.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ client.on(Events.ClientReady, async () => {
1616
// console.dir(message.poll, { depth: Infinity });
1717

1818
// const answer = message.poll.answers.first();
19-
// const voters = await answer.fetchVoters();
19+
// const voters = await answer.voters.fetch();
2020
// console.dir(voters);
2121

2222
const message = await channel.send({

packages/discord.js/typings/index.d.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2753,6 +2753,11 @@ export interface PollQuestionMedia {
27532753
text: string | null;
27542754
}
27552755

2756+
export interface BaseFetchPollAnswerVotersOptions {
2757+
after?: Snowflake;
2758+
limit?: number;
2759+
}
2760+
27562761
export class PollAnswerVoterManager extends CachedManager<Snowflake, User, UserResolvable> {
27572762
private constructor(answer: PollAnswer);
27582763
public answer: PollAnswer;
@@ -2777,11 +2782,6 @@ export class Poll extends Base {
27772782
public end(): Promise<Message>;
27782783
}
27792784

2780-
export interface BaseFetchPollAnswerVotersOptions {
2781-
after?: Snowflake;
2782-
limit?: number;
2783-
}
2784-
27852785
export class PollAnswer extends Base {
27862786
private constructor(client: Client<true>, data: APIPollAnswer & { count?: number }, poll: Poll);
27872787
private readonly _emoji: APIPartialEmoji | null;
@@ -2792,10 +2792,6 @@ export class PollAnswer extends Base {
27922792
public voters: PollAnswerVoterManager;
27932793
public get emoji(): Emoji | GuildEmoji | null;
27942794
public get partial(): false;
2795-
/**
2796-
* @deprecated Use {@link PollAnswerVoterManager.fetch} instead
2797-
*/
2798-
public fetchVoters(options?: BaseFetchPollAnswerVotersOptions): Promise<Collection<Snowflake, User>>;
27992795
}
28002796

28012797
export interface ReactionCollectorEventTypes extends CollectorEventTypes<Snowflake | string, MessageReaction, [User]> {

0 commit comments

Comments
 (0)