Skip to content

Commit

Permalink
Fix logic around responding with mentions (#131)
Browse files Browse the repository at this point in the history
* Fix logic around responding with mentions

* Clean up code
  • Loading branch information
abitofevrything authored Sep 25, 2023
1 parent a3ec0bc commit a9f3d55
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ build/
doc/
.vscode/
.idea/
pubspec_overrides.yaml
10 changes: 6 additions & 4 deletions lib/src/util/mixins.dart
Original file line number Diff line number Diff line change
Expand Up @@ -819,10 +819,12 @@ mixin MessageRespondMixin implements InteractiveMixin {
if (builder.replyId == null) {
builder.replyId = message.id;

// Calling [AllowedMentions.allow] here will only change anything if [level.mention] is
// non-null, in which case we want to change it. Otherwise, this does nothing.
builder.allowedMentions!.parse =
{...(builder.allowedMentions!.parse ?? <String>[]), 'replied_user'}.toList();
if (level.mention case final shouldMention?) {
final allowedMentions = builder.allowedMentions ?? AllowedMentions();
final replyMentions = AllowedMentions(repliedUser: shouldMention);
builder.allowedMentions =
shouldMention ? allowedMentions | replyMentions : allowedMentions & replyMentions;
}
}

return channel.sendMessage(builder);
Expand Down

0 comments on commit a9f3d55

Please sign in to comment.