feature: Include allowed mentions payload on message creation (#1455)

* Feature: Allowed mentions object on msg create (interface breaking)

This change implements the AllowedMentions object for the payload of message creation. By default, the mentions behavior remains unchanged, the message content is parsed for all mentionable entities and they are all notified. If this payload is not null, it will use the content of the allowed_mentions field to determine if a role is notified, or just displayed.

This change is interface breaking. This follows the conventions of keeping RequestOptions as the last argument, but could break some users who specify each of these arguments without using named arguments.

* lint: remove commented-out code

This change removes the commented-out code which was added during testing from the previous commit.

* fix interface break: reorder allowedMentions arg so that it's after options

This change modifies the order of the AllowedMentions argument of SendMessageAsync so that this addition shouldn't be interface breaking. The downside to this change is that it breaks the convention followed by other methods, where the RequestOptions argument is normally last.

* docs: fix typo in allowedMentions arg doc

* fix interface break arg from IRestMessageChannel

* docs: update xmldoc for allowedMentions args

* fix interface breaking arg order for ISocketMessageChannel

* fix mocked classes that weren't updated

* fix: RestDMChannel#SendMessageAsync bug, allowed mentions always null

This change fixes a bug that was introduced while testing changes to the interface of the SendMessageAsync method to try and retain interface compatibility

* docs: update xmldoc for AllowedMentions type

* docs: reword xmldoc of AllowedMentionTypes type

* docs: fix typo

* fix: validate that User/Role flags and UserIds/RoleIds lists are mutually exclusive

This change adds validation to SendMessageAsync which checks that the User flag is mutually exclusive with the list of UserIds, and that the Role flag is also mutually exclusive with the list of RoleIds

* docs: reword summaries for AllowedMentions type

* Add util properties for specifying all or no mentions

Adds read only properties which specify that all mentions or no mentions will notify users. These settings might be more common than others, so this would make them easier to use.

* docs: Resolve PR comments for documentation issues/typos
This commit is contained in:
Chris Johnston
2020-05-07 06:13:57 -07:00
committed by GitHub
parent f8b2b5627e
commit 89b6b7e1a5
21 changed files with 204 additions and 37 deletions

View File

@@ -83,7 +83,7 @@ namespace Discord
throw new NotImplementedException();
}
public Task<IUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null)
public Task<IUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null)
{
throw new NotImplementedException();
}

View File

@@ -91,7 +91,7 @@ namespace Discord
throw new NotImplementedException();
}
public Task<IUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null)
public Task<IUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null)
{
throw new NotImplementedException();
}

View File

@@ -177,7 +177,7 @@ namespace Discord
throw new NotImplementedException();
}
public Task<IUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null)
public Task<IUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null)
{
throw new NotImplementedException();
}