|
@@ -172,6 +172,22 @@ namespace Discord.Rest |
|
|
Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed."); |
|
|
Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed."); |
|
|
Preconditions.AtMost(allowedMentions?.UserIds?.Count ?? 0, 100, nameof(allowedMentions.UserIds), "A max of 100 user Ids are allowed."); |
|
|
Preconditions.AtMost(allowedMentions?.UserIds?.Count ?? 0, 100, nameof(allowedMentions.UserIds), "A max of 100 user Ids are allowed."); |
|
|
|
|
|
|
|
|
|
|
|
// check that user flag and user Id list are exclusive, same with role flag and role Id list |
|
|
|
|
|
if (allowedMentions != null && allowedMentions.AllowedTypes.HasValue) |
|
|
|
|
|
{ |
|
|
|
|
|
if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Users) && |
|
|
|
|
|
allowedMentions.UserIds != null && allowedMentions.UserIds.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
throw new ArgumentException("The Users flag is mutually exclusive with the list of User Ids.", nameof(allowedMentions)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Roles) && |
|
|
|
|
|
allowedMentions.RoleIds != null && allowedMentions.RoleIds.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
throw new ArgumentException("The Roles flag is mutually exclusive with the list of Role Ids.", nameof(allowedMentions)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var args = new CreateMessageParams(text) { IsTTS = isTTS, Embed = embed?.ToModel(), AllowedMentions = allowedMentions?.ToModel() }; |
|
|
var args = new CreateMessageParams(text) { IsTTS = isTTS, Embed = embed?.ToModel(), AllowedMentions = allowedMentions?.ToModel() }; |
|
|
var model = await client.ApiClient.CreateMessageAsync(channel.Id, args, options).ConfigureAwait(false); |
|
|
var model = await client.ApiClient.CreateMessageAsync(channel.Id, args, options).ConfigureAwait(false); |
|
|
return RestUserMessage.Create(client, channel, client.CurrentUser, model); |
|
|
return RestUserMessage.Create(client, channel, client.CurrentUser, model); |
|
|