-
-
Notifications
You must be signed in to change notification settings - Fork 740
Open
Description
A majority of entities use the new modifier in order to implement features on their derived types, instead of a virtual function and then overriding it. This causes issues when you have the base class, leading to errors when the derived type's implementation is vastly different. An example is for RestFollowupMessage
RestFollowupMessage m;
await ((IUserMessage)m).ModifyAsync(m => m.Content = "Foo"); // will throwWhich leads you to do something like this
async Task Components(IUserMessage message)
{
var menu = SelectMenu(user, type);
var components = GetMessageComponents(message).WithSelectMenu(menu).Build();
await (message switch
{
RestInteractionMessage m => m.ModifyAsync(r => r.Components = components),
RestFollowupMessage m => m.ModifyAsync(r => r.Components = components),
_ => message.ModifyAsync(r => r.Components = components)
});
}The call stack for the exception shows that it comes from a RestUserMessage and not from a RestFollowupMessage as example.
Discord.Net.HttpException: The server responded with error 10008: Unknown Message
at Discord.Net.Queue.RequestBucket.SendAsync(RestRequest request)
at Discord.Net.Queue.RequestQueue.SendAsync(RestRequest request)
at Discord.API.DiscordRestApiClient.SendInternalAsync(String method, String endpoint, RestRequest request)
at Discord.API.DiscordRestApiClient.SendJsonAsync[TResponse](String method, String endpoint, Object payload, BucketId bucketId, ClientBucketType clientBucket, RequestOptions options)
at Discord.API.DiscordRestApiClient.ModifyMessageAsync(UInt64 channelId, UInt64 messageId, ModifyMessageParams args, RequestOptions options)
at Discord.Rest.MessageHelper.ModifyAsync(UInt64 channelId, UInt64 msgId, BaseDiscordClient client, Action`1 func, RequestOptions options)
at Discord.Rest.RestUserMessage.ModifyAsync(Action`1 func, RequestOptions options)
Metadata
Metadata
Assignees
Type
Projects
Status
Planned