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

Extension methods on IMessageChannel to get the first and last message of the channel as an IMessage #1736

Closed
Rekkonnect opened this issue Jan 2, 2021 · 3 comments

Comments

@Rekkonnect
Copy link
Contributor

Rekkonnect commented Jan 2, 2021

I believe that this functionality is relatively common among several bots, and having to do

var firstMessage = (await channel.GetMessagesAsync(0, Direction.After, 1).FlattenAsync()).FirstOrDefault();
var lastMessage = (await channel.GetMessagesAsync(1).FlattenAsync()).FirstOrDefault();

quickly becomes confusing to read.

Having a GetFirstMessageAsync() and GetLastMessageAsync() would greatly reduce the complexity of the above snippet.

@Rekkonnect Rekkonnect changed the title Extension methods on IMessageChannel to get the first and last message of the channel as an IMessage Extension methods on IMessageChannel to get the first and last message of the channel as an IMessage Jan 2, 2021
@Quahu
Copy link
Contributor

Quahu commented Jan 2, 2021

I think it's not really that common (especially the former method) and you can always make an extension method, if it's used commonly enough throughout your code.

@Rekkonnect
Copy link
Contributor Author

I've already made those extension methods in my code, but would it really hurt to have them in the API itself? Besides, they don't add any clutter, as they're only extension methods, and can only be consumed.

@SubZero0
Copy link
Member

SubZero0 commented Jan 3, 2021

Imo they are too specific and don't really have any good general purpose or are that common. So it's a no for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants