mirror of
https://github.com/discordjs/discord.js.git
synced 2024-08-21 16:34:43 +12:00
fix(MessageManager): poll methods don't need a channel id (#10249)
* fix(MessageManager): end poll does not need channel id * chore: rest of the work
This commit is contained in:
parent
c91d03c535
commit
0474a43751
5 changed files with 7 additions and 12 deletions
|
@ -269,19 +269,17 @@ class MessageManager extends CachedManager {
|
|||
|
||||
/**
|
||||
* Ends a poll.
|
||||
* @param {Snowflake} channelId The id of the channel
|
||||
* @param {Snowflake} messageId The id of the message
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
async endPoll(channelId, messageId) {
|
||||
const message = await this.client.rest.post(Routes.expirePoll(channelId, messageId));
|
||||
async endPoll(messageId) {
|
||||
const message = await this.client.rest.post(Routes.expirePoll(this.channel.id, messageId));
|
||||
return this._add(message, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Options used for fetching voters of an answer in a poll.
|
||||
* @typedef {BaseFetchPollAnswerVotersOptions} FetchPollAnswerVotersOptions
|
||||
* @param {Snowflake} channelId The id of the channel
|
||||
* @param {Snowflake} messageId The id of the message
|
||||
* @param {number} answerId The id of the answer
|
||||
*/
|
||||
|
@ -291,8 +289,8 @@ class MessageManager extends CachedManager {
|
|||
* @param {FetchPollAnswerVotersOptions} options The options for fetching the poll answer voters
|
||||
* @returns {Promise<Collection<Snowflake, User>>}
|
||||
*/
|
||||
async fetchPollAnswerVoters({ channelId, messageId, answerId, after, limit }) {
|
||||
const voters = await this.client.rest.get(Routes.pollAnswerVoters(channelId, messageId, answerId), {
|
||||
async fetchPollAnswerVoters({ messageId, answerId, after, limit }) {
|
||||
const voters = await this.client.rest.get(Routes.pollAnswerVoters(this.channel.id, messageId, answerId), {
|
||||
query: makeURLSearchParams({ limit, after }),
|
||||
});
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ class Poll extends Base {
|
|||
return Promise.reject(new DiscordjsError(ErrorCodes.PollAlreadyExpired));
|
||||
}
|
||||
|
||||
return this.message.channel.messages.endPoll(this.message.channel.id, this.message.id);
|
||||
return this.message.channel.messages.endPoll(this.message.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,6 @@ class PollAnswer extends Base {
|
|||
*/
|
||||
fetchVoters({ after, limit } = {}) {
|
||||
return this.poll.message.channel.fetchPollAnswerVoters({
|
||||
channelId: this.poll.message.channel.id,
|
||||
messageId: this.poll.message.id,
|
||||
answerId: this.id,
|
||||
after,
|
||||
|
|
3
packages/discord.js/typings/index.d.ts
vendored
3
packages/discord.js/typings/index.d.ts
vendored
|
@ -4399,7 +4399,6 @@ export class GuildMemberRoleManager extends DataManager<Snowflake, Role, RoleRes
|
|||
}
|
||||
|
||||
export interface FetchPollAnswerVotersOptions extends BaseFetchPollAnswerVotersOptions {
|
||||
channelId: Snowflake;
|
||||
messageId: Snowflake;
|
||||
answerId: number;
|
||||
}
|
||||
|
@ -4422,7 +4421,7 @@ export abstract class MessageManager<InGuild extends boolean = boolean> extends
|
|||
public react(message: MessageResolvable, emoji: EmojiIdentifierResolvable): Promise<void>;
|
||||
public pin(message: MessageResolvable, reason?: string): Promise<void>;
|
||||
public unpin(message: MessageResolvable, reason?: string): Promise<void>;
|
||||
public endPoll(channelId: Snowflake, messageId: Snowflake): Promise<Message>;
|
||||
public endPoll(messageId: Snowflake): Promise<Message>;
|
||||
public fetchPollAnswerVoters(options: FetchPollAnswerVotersOptions): Promise<Collection<Snowflake, User>>;
|
||||
}
|
||||
|
||||
|
|
|
@ -2549,9 +2549,8 @@ declare const poll: Poll;
|
|||
|
||||
expectType<Collection<Snowflake, User>>(await answer.fetchVoters({ after: snowflake, limit: 10 }));
|
||||
|
||||
await messageManager.endPoll(snowflake, snowflake);
|
||||
await messageManager.endPoll(snowflake);
|
||||
await messageManager.fetchPollAnswerVoters({
|
||||
channelId: snowflake,
|
||||
messageId: snowflake,
|
||||
answerId: 1,
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue