Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types: fix recurrence rule types #10693

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

vladfrangu
Copy link
Member

Please describe the changes this PR makes and why it should be merged:

Fixes types for recurrence rule being wrong, thanks to a report from @favna

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

Copy link

vercel bot commented Jan 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Visit Preview Jan 5, 2025 10:56pm
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Jan 5, 2025 10:56pm

Copy link
Contributor

@favna favna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with the following code:

await guild.scheduledEvents.create({
  name: eventData.name,
  entityType: GuildScheduledEventEntityType.External,
  entityMetadata: { location: "FC House" },
  privacyLevel: GuildScheduledEventPrivacyLevel.GuildOnly,
  scheduledStartTime: eventData.instance.dateTime,
  scheduledEndTime: addHours(eventData.instance.dateTime, eventData.duration),
  description: eventData.description ?? undefined,
  reason: `Event created by ${leaderUser.user.username}`,

  ...(eventData.interval &&
  (eventData.interval === $Enums.EventInterval.WEEKLY ||
    eventData.interval === $Enums.EventInterval.ONCE_EVERY_OTHER_WEEK)
    ? {
        recurrenceRule: {
          startAt: eventData.instance.dateTime.toISOString(),
          frequency: GuildScheduledEventRecurrenceRuleFrequency.Weekly,
          interval: eventData.interval === $Enums.EventInterval.WEEKLY ? 1 : 2,
          byWeekday: [getISODay(eventData.instance.dateTime) - 1],
          endAt: addHours(eventData.instance.dateTime, eventData.duration),
        },
      }
    : {}),
});

ishare-1736117222-discord
ishare-1736117233-discord

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

3 participants