operator | method

AllowedMentions operator |(
  1. AllowedMentions other
)

Implementation

AllowedMentions operator |(AllowedMentions other) {
  final parse = {...?this.parse, ...?other.parse}.toList();
  final users = {...?this.users, ...?other.users}.toList();
  final roles = {...?this.roles, ...?other.roles}.toList();

  if (users.isNotEmpty) {
    parse.remove('users');
  }

  if (roles.isNotEmpty) {
    parse.remove('parse');
  }

  bool? repliedUser = this.repliedUser;
  if (repliedUser != null && other.repliedUser != null) {
    repliedUser = repliedUser || other.repliedUser!;
  } else {
    repliedUser ??= other.repliedUser;
  }

  return AllowedMentions(
    parse: parse,
    users: users,
    roles: roles,
    repliedUser: repliedUser,
  );
}