[Feature] Generic autocomplete (#2935)
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Discord.Interactions
|
namespace Discord.Interactions;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set the <see cref="ApplicationCommandOptionProperties.IsAutocomplete"/> to <see langword="true"/>.
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]
|
||||||
|
public class AutocompleteAttribute : Attribute
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Set the <see cref="ApplicationCommandOptionProperties.IsAutocomplete"/> to <see langword="true"/>.
|
|
||||||
/// </summary>
|
|
||||||
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]
|
|
||||||
public class AutocompleteAttribute : Attribute
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Type of the <see cref="AutocompleteHandler"/>.
|
/// Type of the <see cref="AutocompleteHandler"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -27,10 +27,12 @@ namespace Discord.Interactions
|
|||||||
|
|
||||||
AutocompleteHandlerType = autocompleteHandlerType;
|
AutocompleteHandlerType = autocompleteHandlerType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Set the <see cref="ApplicationCommandOptionProperties.IsAutocomplete"/> to <see langword="true"/> without specifying a <see cref="AutocompleteHandler"/>.
|
|
||||||
/// </summary>
|
|
||||||
public AutocompleteAttribute() { }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set the <see cref="ApplicationCommandOptionProperties.IsAutocomplete"/> to <see langword="true"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">Type of the <see cref="AutocompleteHandler"/> that will be used to handle Autocomplete interactions targeting the parameter.</typeparam>
|
||||||
|
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]
|
||||||
|
public class AutocompleteAttribute<T>() : AutocompleteAttribute(typeof(T))
|
||||||
|
where T : class, IAutocompleteHandler;
|
||||||
|
|||||||
Reference in New Issue
Block a user