Skip to content

Commit

Permalink
Recurrence rule can be set to null when updating (#720)
Browse files Browse the repository at this point in the history
* Recurrence rule can be set to null when updating

* Update lib/src/builders/guild/scheduled_event.dart

Co-authored-by: Abitofevrything <[email protected]>

---------

Co-authored-by: Abitofevrything <[email protected]>
  • Loading branch information
Lexedia and abitofevrything authored Oct 14, 2024
1 parent 091c376 commit aaef80a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/src/builders/guild/scheduled_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class ScheduledEventUpdateBuilder extends UpdateBuilder<ScheduledEvent> {
this.type,
this.status,
this.image,
this.recurrenceRule,
this.recurrenceRule = sentinelRecurrenceRuleBuilder,
});

@override
Expand All @@ -137,7 +137,7 @@ class ScheduledEventUpdateBuilder extends UpdateBuilder<ScheduledEvent> {
if (type != null) 'entity_type': type!.value,
if (status != null) 'status': status!.value,
if (image != null) 'image': image!.buildDataString(),
if (recurrenceRule != null) 'recurrence_rule': recurrenceRule!.build(),
if (!identical(recurrenceRule, sentinelRecurrenceRuleBuilder)) 'recurrence_rule': recurrenceRule?.build(),
};
}

Expand Down
10 changes: 10 additions & 0 deletions lib/src/builders/sentinels.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:nyxx/src/builders/guild/scheduled_event.dart';
import 'package:nyxx/src/builders/image.dart';
import 'package:nyxx/src/models/channel/types/forum.dart';
import 'package:nyxx/src/models/emoji.dart';
Expand Down Expand Up @@ -109,3 +110,12 @@ class _SentinelEmoji implements Emoji {
}

const sentinelEmoji = _SentinelEmoji();

class _SentinelRecurrenceRuleBuilder implements RecurrenceRuleBuilder {
const _SentinelRecurrenceRuleBuilder();

@override
void noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
}

const sentinelRecurrenceRuleBuilder = _SentinelRecurrenceRuleBuilder();

0 comments on commit aaef80a

Please sign in to comment.