Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mentionables #533

Merged
merged 16 commits into from
Mar 31, 2020
Merged

Mentionables #533

merged 16 commits into from
Mar 31, 2020

Conversation

Lachee
Copy link
Contributor

@Lachee Lachee commented Mar 4, 2020

Summary

Added support for Mentionables

Details

Adds support for Discord's new mentionables. https://discordapp.com/developers/docs/resources/channel#allowed-mentions-object

Changes proposed

  • Created new DiscordMentions object for internals
  • Created new IMention. UserMention, RoleMention and EveryoneMention extend this.
  • Updated CreateMessage and UploadFiles internals and usages to support IEnumerable<IMention>

Notes

Tested and it works. There is a edge case to account for:
If a user says they want to whitelist a specific user AND allow all user mentions.
The discord API will throw a bad request if this is sent. I am currently just ignoring the specific whitelist and assuming the user actually wanted the allow all user mentions. Is this the best case?

@Lachee
Copy link
Contributor Author

Lachee commented Mar 4, 2020

This will need to be added to webhooks too I suppose

Lachee added 2 commits March 5, 2020 12:59
They didn't have the mentions and now they do. They are added as optionals for backwards compatability.
@Lachee Lachee changed the title Patch/mentionables Mentionables Mar 5, 2020
@Emzi0767 Emzi0767 self-assigned this Mar 6, 2020
@Emzi0767 Emzi0767 added this to the v4.0 release milestone Mar 6, 2020
Lachee added 2 commits March 8, 2020 20:11
d#mention will trigger some user mentions for testing.
Needs discussion. In short the Parse and User Ids are mutually exclusive.
I have added the ability to supply no ID and that will be considered as "Parse all users", and the ability to supply an ID which will be "Parse this specific user".

According to the documentation, having both Parse Users and Specified Users is a validation error and will throw 400: Bad Request. The solution I used was to always use Parse Users when available and ignoring the Specified Users, but this maybe not desired outcome? Please discuss.
@Lachee Lachee marked this pull request as ready for review March 8, 2020 09:15
@Lachee
Copy link
Contributor Author

Lachee commented Mar 8, 2020

What is the best way to handle the following:
Parse and User/Role options are mutually exclusive and will throw validation errors if both are present. The current solution implemented by commit bd130c8 was to ignore the user/role whitelist if their global parse was present instead. (I wish discord just allowed for IDs as 0 for "everyone").

We may want to throw an exception if we detect both Parse and User/Roles present, or we could just let it throw the 400: Bad Request.

I confused myself with the Everyone mention. I assumed it would allow me to mention everyone I listed but it is only specifically for the @ everyone and @ here.

I rewrote the documentation to be more clear about all the fields.
@Emzi0767
Copy link
Contributor

Emzi0767 commented Mar 8, 2020

I'll put this as on hold for (reason being, it's not yet finalized) now so that nobody accidentally merges this.

Maxine suggested to add Everyone static. I believe All is more appropriately suited though.

Unsure about EveryoneMention.All however. I implemented it for consistency with the others but it isn't required.
@Lachee
Copy link
Contributor Author

Lachee commented Mar 12, 2020

Tested it and it works. Updated the notes in original PR.

@Emzi0767 Emzi0767 added the v4.x label Mar 24, 2020
@Emzi0767
Copy link
Contributor

Interface looks OK. I wonder how long until we have to switch to a message builder 😔.

@Emzi0767 Emzi0767 removed the on-hold label Mar 31, 2020
@Emzi0767 Emzi0767 merged commit 1b9aa3e into DSharpPlus:master Mar 31, 2020
Lachee added a commit to Lachee/DSharpPlus that referenced this pull request Jun 21, 2020
* Initial Mentions and DiscordMentions

The DiscordMentions will be for internal user and the Mentions interface will be exposed on message functions.

* Added Mentions to the payload

* Sealed interface

* Added exception

* Added CreateMessage

* Added mentions to UploadFileAsync

* Moved to Create Payload

Edits don't effect pings
- Emzi

* Added mentions to webhooks

They didn't have the mentions and now they do. They are added as optionals for backwards compatability.

* Fixed build failure.

* Added test command

d#mention will trigger some user mentions for testing.

* Updated Mentions to work,

Needs discussion. In short the Parse and User Ids are mutually exclusive.
I have added the ability to supply no ID and that will be considered as "Parse all users", and the ability to supply an ID which will be "Parse this specific user".

According to the documentation, having both Parse Users and Specified Users is a validation error and will throw 400: Bad Request. The solution I used was to always use Parse Users when available and ignoring the Specified Users, but this maybe not desired outcome? Please discuss.

* Updated Documentation

I confused myself with the Everyone mention. I assumed it would allow me to mention everyone I listed but it is only specifically for the @ everyone and @ here.

I rewrote the documentation to be more clear about all the fields.

* Added All static.

Maxine suggested to add Everyone static. I believe All is more appropriately suited though.

Unsure about EveryoneMention.All however. I implemented it for consistency with the others but it isn't required.
OoLunar pushed a commit that referenced this pull request Oct 3, 2024
* Initial Mentions and DiscordMentions

The DiscordMentions will be for internal user and the Mentions interface will be exposed on message functions.

* Added Mentions to the payload

* Sealed interface

* Added exception

* Added CreateMessage

* Added mentions to UploadFileAsync

* Moved to Create Payload

Edits don't effect pings
- Emzi

* Added mentions to webhooks

They didn't have the mentions and now they do. They are added as optionals for backwards compatability.

* Fixed build failure.

* Added test command

d#mention will trigger some user mentions for testing.

* Updated Mentions to work,

Needs discussion. In short the Parse and User Ids are mutually exclusive.
I have added the ability to supply no ID and that will be considered as "Parse all users", and the ability to supply an ID which will be "Parse this specific user".

According to the documentation, having both Parse Users and Specified Users is a validation error and will throw 400: Bad Request. The solution I used was to always use Parse Users when available and ignoring the Specified Users, but this maybe not desired outcome? Please discuss.

* Updated Documentation

I confused myself with the Everyone mention. I assumed it would allow me to mention everyone I listed but it is only specifically for the @ everyone and @ here.

I rewrote the documentation to be more clear about all the fields.

* Added All static.

Maxine suggested to add Everyone static. I believe All is more appropriately suited though.

Unsure about EveryoneMention.All however. I implemented it for consistency with the others but it isn't required.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants