mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-20 21:43:33 +01:00
types: fix recurrence rule types (#10694)
* types: fix recurrence rule types * fix: endAt not endsAt * types: remove fields that cannot be set by the client * chore: cleanup JS lands too * chore: missed you * chore: bite me --------- Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
This commit is contained in:
@@ -41,15 +41,12 @@ class GuildScheduledEventManager extends CachedManager {
|
|||||||
* Options for setting a recurrence rule for a guild scheduled event.
|
* Options for setting a recurrence rule for a guild scheduled event.
|
||||||
* @typedef {Object} GuildScheduledEventRecurrenceRuleOptions
|
* @typedef {Object} GuildScheduledEventRecurrenceRuleOptions
|
||||||
* @property {DateResolvable} startAt The time the recurrence rule interval starts at
|
* @property {DateResolvable} startAt The time the recurrence rule interval starts at
|
||||||
* @property {?DateResolvable} endAt The time the recurrence rule interval ends at
|
|
||||||
* @property {GuildScheduledEventRecurrenceRuleFrequency} frequency How often the event occurs
|
* @property {GuildScheduledEventRecurrenceRuleFrequency} frequency How often the event occurs
|
||||||
* @property {number} interval The spacing between the events
|
* @property {number} interval The spacing between the events
|
||||||
* @property {?GuildScheduledEventRecurrenceRuleWeekday[]} byWeekday The days within a week to recur on
|
* @property {?GuildScheduledEventRecurrenceRuleWeekday[]} byWeekday The days within a week to recur on
|
||||||
* @property {?GuildScheduledEventRecurrenceRuleNWeekday[]} byNWeekday The days within a week to recur on
|
* @property {?GuildScheduledEventRecurrenceRuleNWeekday[]} byNWeekday The days within a week to recur on
|
||||||
* @property {?GuildScheduledEventRecurrenceRuleMonth[]} byMonth The months to recur on
|
* @property {?GuildScheduledEventRecurrenceRuleMonth[]} byMonth The months to recur on
|
||||||
* @property {?number[]} byMonthDay The days within a month to recur on
|
* @property {?number[]} byMonthDay The days within a month to recur on
|
||||||
* @property {?number[]} byYearDay The days within a year to recur on
|
|
||||||
* @property {?number} count The total amount of times the event is allowed to recur before stopping
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -63,16 +63,12 @@ function _transformAPIMessageInteractionMetadata(client, messageInteractionMetad
|
|||||||
function _transformGuildScheduledEventRecurrenceRule(recurrenceRule) {
|
function _transformGuildScheduledEventRecurrenceRule(recurrenceRule) {
|
||||||
return {
|
return {
|
||||||
start: new Date(recurrenceRule.startAt).toISOString(),
|
start: new Date(recurrenceRule.startAt).toISOString(),
|
||||||
// eslint-disable-next-line eqeqeq
|
|
||||||
end: recurrenceRule.endAt != null ? new Date(recurrenceRule.endAt).toISOString() : recurrenceRule.endAt,
|
|
||||||
frequency: recurrenceRule.frequency,
|
frequency: recurrenceRule.frequency,
|
||||||
interval: recurrenceRule.interval,
|
interval: recurrenceRule.interval,
|
||||||
by_weekday: recurrenceRule.byWeekday,
|
by_weekday: recurrenceRule.byWeekday,
|
||||||
by_n_weekday: recurrenceRule.byNWeekday,
|
by_n_weekday: recurrenceRule.byNWeekday,
|
||||||
by_month: recurrenceRule.byMonth,
|
by_month: recurrenceRule.byMonth,
|
||||||
by_month_day: recurrenceRule.byMonthDay,
|
by_month_day: recurrenceRule.byMonthDay,
|
||||||
by_year_day: recurrenceRule.byYearDay,
|
|
||||||
count: recurrenceRule.count,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
35
packages/discord.js/typings/index.d.ts
vendored
35
packages/discord.js/typings/index.d.ts
vendored
@@ -6378,18 +6378,35 @@ export interface GuildScheduledEventCreateOptions {
|
|||||||
recurrenceRule?: GuildScheduledEventRecurrenceRuleOptions;
|
recurrenceRule?: GuildScheduledEventRecurrenceRuleOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GuildScheduledEventRecurrenceRuleOptions {
|
export type GuildScheduledEventRecurrenceRuleOptions =
|
||||||
startAt: DateResolvable;
|
| BaseGuildScheduledEventRecurrenceRuleOptions<
|
||||||
endAt: DateResolvable;
|
GuildScheduledEventRecurrenceRuleFrequency.Yearly,
|
||||||
frequency: GuildScheduledEventRecurrenceRuleFrequency;
|
{
|
||||||
interval: number;
|
|
||||||
byWeekday: readonly GuildScheduledEventRecurrenceRuleWeekday[];
|
|
||||||
byNWeekday: readonly GuildScheduledEventRecurrenceRuleNWeekday[];
|
|
||||||
byMonth: readonly GuildScheduledEventRecurrenceRuleMonth[];
|
byMonth: readonly GuildScheduledEventRecurrenceRuleMonth[];
|
||||||
byMonthDay: readonly number[];
|
byMonthDay: readonly number[];
|
||||||
byYearDay: readonly number[];
|
|
||||||
count: number;
|
|
||||||
}
|
}
|
||||||
|
>
|
||||||
|
| BaseGuildScheduledEventRecurrenceRuleOptions<
|
||||||
|
GuildScheduledEventRecurrenceRuleFrequency.Monthly,
|
||||||
|
{
|
||||||
|
byNWeekday: readonly GuildScheduledEventRecurrenceRuleNWeekday[];
|
||||||
|
}
|
||||||
|
>
|
||||||
|
| BaseGuildScheduledEventRecurrenceRuleOptions<
|
||||||
|
GuildScheduledEventRecurrenceRuleFrequency.Weekly | GuildScheduledEventRecurrenceRuleFrequency.Daily,
|
||||||
|
{
|
||||||
|
byWeekday: readonly GuildScheduledEventRecurrenceRuleWeekday[];
|
||||||
|
}
|
||||||
|
>;
|
||||||
|
|
||||||
|
type BaseGuildScheduledEventRecurrenceRuleOptions<
|
||||||
|
Frequency extends GuildScheduledEventRecurrenceRuleFrequency,
|
||||||
|
Extra extends {},
|
||||||
|
> = {
|
||||||
|
startAt: DateResolvable;
|
||||||
|
interval: number;
|
||||||
|
frequency: Frequency;
|
||||||
|
} & Extra;
|
||||||
|
|
||||||
export interface GuildScheduledEventEditOptions<
|
export interface GuildScheduledEventEditOptions<
|
||||||
Status extends GuildScheduledEventStatus,
|
Status extends GuildScheduledEventStatus,
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ import {
|
|||||||
APIMentionableSelectComponent,
|
APIMentionableSelectComponent,
|
||||||
APIModalInteractionResponseCallbackData,
|
APIModalInteractionResponseCallbackData,
|
||||||
WebhookType,
|
WebhookType,
|
||||||
|
GuildScheduledEventRecurrenceRuleFrequency,
|
||||||
|
GuildScheduledEventRecurrenceRuleMonth,
|
||||||
|
GuildScheduledEventRecurrenceRuleWeekday,
|
||||||
} from 'discord-api-types/v10';
|
} from 'discord-api-types/v10';
|
||||||
import {
|
import {
|
||||||
ApplicationCommand,
|
ApplicationCommand,
|
||||||
@@ -214,6 +217,7 @@ import {
|
|||||||
PollData,
|
PollData,
|
||||||
UserManager,
|
UserManager,
|
||||||
InteractionCallbackResponse,
|
InteractionCallbackResponse,
|
||||||
|
GuildScheduledEventRecurrenceRuleOptions,
|
||||||
ThreadOnlyChannel,
|
ThreadOnlyChannel,
|
||||||
} from '.';
|
} from '.';
|
||||||
import {
|
import {
|
||||||
@@ -2690,3 +2694,89 @@ client.on('interactionCreate', interaction => {
|
|||||||
|
|
||||||
declare const guildScheduledEventManager: GuildScheduledEventManager;
|
declare const guildScheduledEventManager: GuildScheduledEventManager;
|
||||||
await guildScheduledEventManager.edit(snowflake, { recurrenceRule: null });
|
await guildScheduledEventManager.edit(snowflake, { recurrenceRule: null });
|
||||||
|
|
||||||
|
{
|
||||||
|
expectNotAssignable<GuildScheduledEventRecurrenceRuleOptions>({
|
||||||
|
startAt: new Date(),
|
||||||
|
frequency: GuildScheduledEventRecurrenceRuleFrequency.Yearly,
|
||||||
|
interval: 1,
|
||||||
|
byMonth: [GuildScheduledEventRecurrenceRuleMonth.May],
|
||||||
|
byMonthDay: [4],
|
||||||
|
// Invalid property
|
||||||
|
byWeekday: [GuildScheduledEventRecurrenceRuleWeekday.Monday],
|
||||||
|
});
|
||||||
|
|
||||||
|
expectNotAssignable<GuildScheduledEventRecurrenceRuleOptions>({
|
||||||
|
startAt: new Date(),
|
||||||
|
frequency: GuildScheduledEventRecurrenceRuleFrequency.Yearly,
|
||||||
|
interval: 1,
|
||||||
|
byMonth: [GuildScheduledEventRecurrenceRuleMonth.May],
|
||||||
|
byMonthDay: [4],
|
||||||
|
// Invalid property
|
||||||
|
byNWeekday: [{ n: 1, day: GuildScheduledEventRecurrenceRuleWeekday.Monday }],
|
||||||
|
});
|
||||||
|
|
||||||
|
expectAssignable<GuildScheduledEventRecurrenceRuleOptions>({
|
||||||
|
startAt: new Date(),
|
||||||
|
frequency: GuildScheduledEventRecurrenceRuleFrequency.Yearly,
|
||||||
|
interval: 1,
|
||||||
|
byMonth: [GuildScheduledEventRecurrenceRuleMonth.May],
|
||||||
|
byMonthDay: [4],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
expectAssignable<GuildScheduledEventRecurrenceRuleOptions>({
|
||||||
|
startAt: new Date(),
|
||||||
|
frequency: GuildScheduledEventRecurrenceRuleFrequency.Monthly,
|
||||||
|
interval: 1,
|
||||||
|
byNWeekday: [{ n: 1, day: GuildScheduledEventRecurrenceRuleWeekday.Monday }],
|
||||||
|
});
|
||||||
|
|
||||||
|
expectNotAssignable<GuildScheduledEventRecurrenceRuleOptions>({
|
||||||
|
startAt: new Date(),
|
||||||
|
frequency: GuildScheduledEventRecurrenceRuleFrequency.Monthly,
|
||||||
|
interval: 1,
|
||||||
|
byNWeekday: [{ n: 1, day: GuildScheduledEventRecurrenceRuleWeekday.Monday }],
|
||||||
|
// Invalid property
|
||||||
|
byWeekday: [GuildScheduledEventRecurrenceRuleWeekday.Monday],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
expectAssignable<GuildScheduledEventRecurrenceRuleOptions>({
|
||||||
|
startAt: new Date(),
|
||||||
|
frequency: GuildScheduledEventRecurrenceRuleFrequency.Weekly,
|
||||||
|
interval: 1,
|
||||||
|
byWeekday: [GuildScheduledEventRecurrenceRuleWeekday.Monday],
|
||||||
|
});
|
||||||
|
|
||||||
|
expectNotAssignable<GuildScheduledEventRecurrenceRuleOptions>({
|
||||||
|
startAt: new Date(),
|
||||||
|
frequency: GuildScheduledEventRecurrenceRuleFrequency.Weekly,
|
||||||
|
interval: 1,
|
||||||
|
byWeekday: [GuildScheduledEventRecurrenceRuleWeekday.Monday],
|
||||||
|
// Invalid property
|
||||||
|
byNWeekday: [{ n: 1, day: GuildScheduledEventRecurrenceRuleWeekday.Monday }],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
expectNotAssignable<GuildScheduledEventRecurrenceRuleOptions>({
|
||||||
|
startAt: new Date(),
|
||||||
|
frequency: GuildScheduledEventRecurrenceRuleFrequency.Daily,
|
||||||
|
interval: 1,
|
||||||
|
byWeekday: [GuildScheduledEventRecurrenceRuleWeekday.Monday],
|
||||||
|
// Invalid property
|
||||||
|
byNWeekday: [{ n: 1, day: GuildScheduledEventRecurrenceRuleWeekday.Monday }],
|
||||||
|
});
|
||||||
|
|
||||||
|
expectNotAssignable<GuildScheduledEventRecurrenceRuleOptions>({
|
||||||
|
startAt: new Date(),
|
||||||
|
frequency: GuildScheduledEventRecurrenceRuleFrequency.Daily,
|
||||||
|
interval: 1,
|
||||||
|
byWeekday: [GuildScheduledEventRecurrenceRuleWeekday.Monday],
|
||||||
|
// Invalid property
|
||||||
|
byMonth: [GuildScheduledEventRecurrenceRuleMonth.May],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user