-
-
Notifications
You must be signed in to change notification settings - Fork 737
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Scheduled event recurrence rule (#3023)
* api modelsssssssss * recurrence rulesssss
- Loading branch information
Showing
24 changed files
with
585 additions
and
131 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/Discord.Net.Core/Entities/GuildScheduledEvents/GuildScheduledEventPrivacyLevel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
|
||
namespace Discord; | ||
|
||
/// <summary> | ||
/// Represents the privacy level of a guild scheduled event. | ||
/// </summary> | ||
public enum GuildScheduledEventPrivacyLevel | ||
{ | ||
/// <summary> | ||
/// The scheduled event is public and available in discovery. | ||
/// </summary> | ||
[Obsolete("This event type isn't supported yet! check back later.", true)] | ||
Public = 1, | ||
|
||
/// <summary> | ||
/// The scheduled event is only accessible to guild members. | ||
/// </summary> | ||
Private = 2, | ||
} |
76 changes: 76 additions & 0 deletions
76
src/Discord.Net.Core/Entities/GuildScheduledEvents/GuildScheduledEventRecurrenceRule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Discord; | ||
|
||
public readonly struct GuildScheduledEventRecurrenceRule | ||
{ | ||
/// <summary> | ||
/// Gets the starting time of the recurrence interval. | ||
/// </summary> | ||
public DateTimeOffset StartsAt { get; } | ||
|
||
/// <summary> | ||
/// Gets the ending time of the recurrence interval. | ||
/// </summary> | ||
public DateTimeOffset? EndsAt { get; } | ||
|
||
/// <summary> | ||
/// Gets how often the event occurs. | ||
/// </summary> | ||
public RecurrenceFrequency Frequency { get; } | ||
|
||
/// <summary> | ||
/// Gets the spacing between the events, defined by <see cref="Frequency"/>. | ||
/// </summary> | ||
public int Interval { get; } | ||
|
||
/// <summary> | ||
/// Gets the set of specific days within a week for the event to recur on. | ||
/// </summary> | ||
public IReadOnlyCollection<RecurrenceRuleWeekday> ByWeekday { get; } | ||
|
||
/// <summary> | ||
/// Gets the list of specific days within a specific week to recur on. | ||
/// </summary> | ||
public IReadOnlyCollection<RecurrenceRuleByNWeekday> ByNWeekday { get; } | ||
|
||
/// <summary> | ||
/// Gets the set of specific months to recur on. | ||
/// </summary> | ||
public IReadOnlyCollection<RecurrenceRuleMonth> ByMonth { get; } | ||
|
||
/// <summary> | ||
/// Gets the set of specific dates within a month to recur on. | ||
/// </summary> | ||
public IReadOnlyCollection<int> ByMonthDay { get; } | ||
|
||
/// <summary> | ||
/// Gets the set of days within a year to recur on. (1-364) | ||
/// </summary> | ||
public IReadOnlyCollection<int> ByYearDay { get; } | ||
|
||
/// <summary> | ||
/// Gets the total amount of times that the event is allowed to recur before stopping. | ||
/// </summary> | ||
/// <remarks> | ||
/// <see langword="null"/> if the event recurs endlessly. | ||
/// </remarks> | ||
public int? Count { get; } | ||
|
||
internal GuildScheduledEventRecurrenceRule(DateTimeOffset startsAt, DateTimeOffset? endsAt, RecurrenceFrequency frequency, | ||
int interval, IReadOnlyCollection<RecurrenceRuleWeekday> byWeekday, IReadOnlyCollection<RecurrenceRuleByNWeekday> byNWeekday, | ||
IReadOnlyCollection<RecurrenceRuleMonth> byMonth, IReadOnlyCollection<int> byMonthDay, IReadOnlyCollection<int> byYearDay, int? count) | ||
{ | ||
StartsAt = startsAt; | ||
EndsAt = endsAt; | ||
Frequency = frequency; | ||
Interval = interval; | ||
ByWeekday = byWeekday; | ||
ByNWeekday = byNWeekday; | ||
ByMonth = byMonth; | ||
ByMonthDay = byMonthDay; | ||
ByYearDay = byYearDay; | ||
Count = count; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...ord.Net.Core/Entities/GuildScheduledEvents/GuildScheduledEventRecurrenceRuleProperties.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Discord; | ||
|
||
public class GuildScheduledEventRecurrenceRuleProperties | ||
{ | ||
/// <summary> | ||
/// Gets or sets the starting time of the recurrence interval. | ||
/// </summary> | ||
public DateTimeOffset StartsAt { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets how often the event occurs. | ||
/// </summary> | ||
public RecurrenceFrequency Frequency { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the spacing between the events, defined by <see cref="Frequency"/>. | ||
/// </summary> | ||
public int Interval { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the set of specific days within a week for the event to recur on. | ||
/// </summary> | ||
public HashSet<RecurrenceRuleWeekday> ByWeekday { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the list of specific days within a specific week to recur on. | ||
/// </summary> | ||
public List<RecurrenceRuleByNWeekday> ByNWeekday { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the set of specific months to recur on. | ||
/// </summary> | ||
public HashSet<RecurrenceRuleMonth> ByMonth { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the set of specific dates within a month to recur on. | ||
/// </summary> | ||
public HashSet<int> ByMonthDay { get; set; } | ||
|
||
|
||
public GuildScheduledEventRecurrenceRuleProperties() {} | ||
|
||
public GuildScheduledEventRecurrenceRuleProperties(DateTimeOffset startsAt, RecurrenceFrequency frequency, | ||
int interval, HashSet<RecurrenceRuleWeekday> byWeekday, IEnumerable<RecurrenceRuleByNWeekday> byNWeekday, | ||
HashSet<RecurrenceRuleMonth> byMonth, HashSet<int> byMonthDay) | ||
{ | ||
StartsAt = startsAt; | ||
Frequency = frequency; | ||
Interval = interval; | ||
ByWeekday = byWeekday; | ||
ByNWeekday = byNWeekday?.ToList(); | ||
ByMonth = byMonth; | ||
ByMonthDay = byMonthDay; | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/Discord.Net.Core/Entities/GuildScheduledEvents/RecurrenceFrequency.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace Discord; | ||
|
||
public enum RecurrenceFrequency | ||
{ | ||
Yearly = 0, | ||
|
||
Monthly = 1, | ||
|
||
Weekly = 2, | ||
|
||
Daily = 3 | ||
} |
20 changes: 20 additions & 0 deletions
20
src/Discord.Net.Core/Entities/GuildScheduledEvents/RecurrenceRuleByNWeekday.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace Discord; | ||
|
||
public readonly struct RecurrenceRuleByNWeekday | ||
{ | ||
/// <summary> | ||
/// Gets the week to reoccur on. (from 1 to 5) | ||
/// </summary> | ||
public int Week { get; } | ||
|
||
/// <summary> | ||
/// Gets the day within a week to reoccur on. | ||
/// </summary> | ||
public RecurrenceRuleWeekday Day { get; } | ||
|
||
internal RecurrenceRuleByNWeekday(int week, RecurrenceRuleWeekday day) | ||
{ | ||
Week = week; | ||
Day = day; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/Discord.Net.Core/Entities/GuildScheduledEvents/RecurrenceRuleByNWeekdayProperties.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace Discord; | ||
|
||
public class RecurrenceRuleByNWeekdayProperties | ||
{ | ||
/// <summary> | ||
/// Gets or sets the week to reoccur on. (from 1 to 5) | ||
/// </summary> | ||
public int Week { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the day within a week to reoccur on. | ||
/// </summary> | ||
public RecurrenceRuleWeekday Day { get; set; } | ||
|
||
public RecurrenceRuleByNWeekdayProperties() {} | ||
|
||
public RecurrenceRuleByNWeekdayProperties(int week, RecurrenceRuleWeekday day) | ||
{ | ||
Week = week; | ||
Day = day; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Discord.Net.Core/Entities/GuildScheduledEvents/RecurrenceRuleMonth.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
namespace Discord; | ||
|
||
public enum RecurrenceRuleMonth | ||
{ | ||
January = 1, | ||
|
||
February = 2, | ||
|
||
March = 3, | ||
|
||
April = 4, | ||
|
||
May = 5, | ||
|
||
June = 6, | ||
|
||
July = 7, | ||
|
||
August = 8, | ||
|
||
September = 9, | ||
|
||
October = 10, | ||
|
||
November = 11, | ||
|
||
December = 12 | ||
} |
18 changes: 18 additions & 0 deletions
18
src/Discord.Net.Core/Entities/GuildScheduledEvents/RecurrenceRuleWeekday.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace Discord; | ||
|
||
public enum RecurrenceRuleWeekday | ||
{ | ||
Monday = 0, | ||
|
||
Tuesday = 1, | ||
|
||
Wednesday = 2, | ||
|
||
Thursday = 3, | ||
|
||
Friday = 4, | ||
|
||
Saturday = 5, | ||
|
||
Sunday = 6 | ||
} |
25 changes: 0 additions & 25 deletions
25
src/Discord.Net.Core/Entities/Guilds/GuildScheduledEventPrivacyLevel.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.