using System; using System.Reflection; namespace Discord.Interactions { /// /// Create a Message Context Command. /// /// /// s won't add prefixes to this command. /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public class MessageCommandAttribute : ContextCommandAttribute { /// /// Register a method as a Message Context Command. /// /// Name of the context command. public MessageCommandAttribute(string name) : base(name, ApplicationCommandType.Message) { } internal override void CheckMethodDefinition(MethodInfo methodInfo) { var parameters = methodInfo.GetParameters(); if (parameters.Length != 1 || !typeof(IMessage).IsAssignableFrom(parameters[0].ParameterType)) throw new InvalidOperationException($"Message Commands must have only one parameter that is a type of {nameof(IMessage)}"); } } }