NetCordDev / NetCord

The modern and fully customizable C# Discord library.
https://netcord.dev
MIT License
63 stars 9 forks source link

Generic message types #30

Closed KubaZ2 closed 2 weeks ago

KubaZ2 commented 1 month ago

Description

I have seen some confusion with message sending. It was caused by endpoints having their own unique message types.

It causes problems when trying to creating a generic API for many endpoints, for example for both channel messages and interaction responses.

This issue exists so that the pros and cons of generic message types and possible solutions can be collected.

KubaZ2 commented 1 month ago

What I think could be done is MessageProperties as a base for all messages. It would contain only fields used for all message types across Discord. I think we could add:

Having MessageProperties as the default type rather than an interface would allow for using new() for creating an instance while allowing for generic APIs building messages unless they would like to use some unique message specific property.

I am open to any comments/questions.

KubaZ2 commented 1 month ago

Actually, I think accepting MessageProperties type for most methods would cause confusion. Maybe a better idea is to create IMessageProperties interface that will contain properties common for all message properties.