Skip to content

Commit 0474a43

Browse files
authored
fix(MessageManager): poll methods don't need a channel id (discordjs#10249)
* fix(MessageManager): end poll does not need channel id * chore: rest of the work
1 parent c91d03c commit 0474a43

File tree

5 files changed

+7
-12
lines changed

5 files changed

+7
-12
lines changed

packages/discord.js/src/managers/MessageManager.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,19 +269,17 @@ class MessageManager extends CachedManager {
269269

270270
/**
271271
* Ends a poll.
272-
* @param {Snowflake} channelId The id of the channel
273272
* @param {Snowflake} messageId The id of the message
274273
* @returns {Promise<Message>}
275274
*/
276-
async endPoll(channelId, messageId) {
277-
const message = await this.client.rest.post(Routes.expirePoll(channelId, messageId));
275+
async endPoll(messageId) {
276+
const message = await this.client.rest.post(Routes.expirePoll(this.channel.id, messageId));
278277
return this._add(message, false);
279278
}
280279

281280
/**
282281
* Options used for fetching voters of an answer in a poll.
283282
* @typedef {BaseFetchPollAnswerVotersOptions} FetchPollAnswerVotersOptions
284-
* @param {Snowflake} channelId The id of the channel
285283
* @param {Snowflake} messageId The id of the message
286284
* @param {number} answerId The id of the answer
287285
*/
@@ -291,8 +289,8 @@ class MessageManager extends CachedManager {
291289
* @param {FetchPollAnswerVotersOptions} options The options for fetching the poll answer voters
292290
* @returns {Promise<Collection<Snowflake, User>>}
293291
*/
294-
async fetchPollAnswerVoters({ channelId, messageId, answerId, after, limit }) {
295-
const voters = await this.client.rest.get(Routes.pollAnswerVoters(channelId, messageId, answerId), {
292+
async fetchPollAnswerVoters({ messageId, answerId, after, limit }) {
293+
const voters = await this.client.rest.get(Routes.pollAnswerVoters(this.channel.id, messageId, answerId), {
296294
query: makeURLSearchParams({ limit, after }),
297295
});
298296

packages/discord.js/src/structures/Poll.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class Poll extends Base {
102102
return Promise.reject(new DiscordjsError(ErrorCodes.PollAlreadyExpired));
103103
}
104104

105-
return this.message.channel.messages.endPoll(this.message.channel.id, this.message.id);
105+
return this.message.channel.messages.endPoll(this.message.id);
106106
}
107107
}
108108

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ class PollAnswer extends Base {
7878
*/
7979
fetchVoters({ after, limit } = {}) {
8080
return this.poll.message.channel.fetchPollAnswerVoters({
81-
channelId: this.poll.message.channel.id,
8281
messageId: this.poll.message.id,
8382
answerId: this.id,
8483
after,

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4399,7 +4399,6 @@ export class GuildMemberRoleManager extends DataManager<Snowflake, Role, RoleRes
43994399
}
44004400

44014401
export interface FetchPollAnswerVotersOptions extends BaseFetchPollAnswerVotersOptions {
4402-
channelId: Snowflake;
44034402
messageId: Snowflake;
44044403
answerId: number;
44054404
}
@@ -4422,7 +4421,7 @@ export abstract class MessageManager<InGuild extends boolean = boolean> extends
44224421
public react(message: MessageResolvable, emoji: EmojiIdentifierResolvable): Promise<void>;
44234422
public pin(message: MessageResolvable, reason?: string): Promise<void>;
44244423
public unpin(message: MessageResolvable, reason?: string): Promise<void>;
4425-
public endPoll(channelId: Snowflake, messageId: Snowflake): Promise<Message>;
4424+
public endPoll(messageId: Snowflake): Promise<Message>;
44264425
public fetchPollAnswerVoters(options: FetchPollAnswerVotersOptions): Promise<Collection<Snowflake, User>>;
44274426
}
44284427

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2549,9 +2549,8 @@ declare const poll: Poll;
25492549

25502550
expectType<Collection<Snowflake, User>>(await answer.fetchVoters({ after: snowflake, limit: 10 }));
25512551

2552-
await messageManager.endPoll(snowflake, snowflake);
2552+
await messageManager.endPoll(snowflake);
25532553
await messageManager.fetchPollAnswerVoters({
2554-
channelId: snowflake,
25552554
messageId: snowflake,
25562555
answerId: 1,
25572556
});

0 commit comments

Comments
 (0)