[Feature] Initial user apps support (#2883)
* omg it kinda works somehow * more things added * a bit of xmldocs * added interaction framework support * working? IF * more builder stuff * space * rename attribute to prevent conflict with `ContextType` enum * context type * moar features * remove integration types * trigger workflow * modelzzzz * `InteractionContextType` * allow setting custom status with `SetGameAsync` * bugzzz * app permissions * message interaction context * hm * push for cd * structs lets goooo * whoops forgot to change types * whoops x2 * tweak some things * xmldocs + missing prop + fix enabled in dm * moar validations * deprecate a bunch of stuffz * disable moar obsolete warnings * add IF sample * Apply suggestions from code review Co-authored-by: Quin Lynch <49576606+quinchs@users.noreply.github.com> * Update src/Discord.Net.Rest/Entities/RestApplication.cs Co-authored-by: Quin Lynch <49576606+quinchs@users.noreply.github.com> --------- Co-authored-by: Quin Lynch <49576606+quinchs@users.noreply.github.com>
This commit is contained in:
@@ -51,12 +51,13 @@ namespace Discord.Interactions.Builders
|
||||
/// <summary>
|
||||
/// Gets and sets the default permission of this module.
|
||||
/// </summary>
|
||||
[Obsolete($"To be deprecated soon, use {nameof(IsEnabledInDm)} and {nameof(DefaultMemberPermissions)} instead.")]
|
||||
[Obsolete($"To be deprecated soon, use {nameof(ContextTypes)} and {nameof(DefaultMemberPermissions)} instead.")]
|
||||
public bool DefaultPermission { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether this command can be used in DMs.
|
||||
/// </summary>
|
||||
[Obsolete("This property will be deprecated soon. Use ContextTypes instead.")]
|
||||
public bool IsEnabledInDm { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
@@ -114,6 +115,16 @@ namespace Discord.Interactions.Builders
|
||||
/// </summary>
|
||||
public IReadOnlyList<ModalCommandBuilder> ModalCommands => _modalCommands;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the install method for this command.
|
||||
/// </summary>
|
||||
public HashSet<ApplicationIntegrationType> IntegrationTypes { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the context types this command can be executed in.
|
||||
/// </summary>
|
||||
public HashSet<InteractionContextType> ContextTypes { get; set; } = null;
|
||||
|
||||
internal TypeInfo TypeInfo { get; set; }
|
||||
|
||||
internal ModuleBuilder(InteractionService interactionService, ModuleBuilder parent = null)
|
||||
@@ -189,6 +200,7 @@ namespace Discord.Interactions.Builders
|
||||
/// <returns>
|
||||
/// The builder instance.
|
||||
/// </returns>
|
||||
[Obsolete("This method will be deprecated soon. Use WithContextTypes instead.")]
|
||||
public ModuleBuilder SetEnabledInDm(bool isEnabled)
|
||||
{
|
||||
IsEnabledInDm = isEnabled;
|
||||
@@ -423,6 +435,28 @@ namespace Discord.Interactions.Builders
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the <see cref="IntegrationTypes"/> on this <see cref="ModuleBuilder"/>.
|
||||
/// </summary>
|
||||
/// <param name="integrationTypes">Install types for this command.</param>
|
||||
/// <returns>The builder instance.</returns>
|
||||
public ModuleBuilder WithIntegrationTypes(params ApplicationIntegrationType[] integrationTypes)
|
||||
{
|
||||
IntegrationTypes = new HashSet<ApplicationIntegrationType>(integrationTypes);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the <see cref="ContextTypes"/> on this <see cref="ModuleBuilder"/>.
|
||||
/// </summary>
|
||||
/// <param name="contextTypes">Context types the command can be executed in.</param>
|
||||
/// <returns>The builder instance.</returns>
|
||||
public ModuleBuilder WithContextTypes(params InteractionContextType[] contextTypes)
|
||||
{
|
||||
ContextTypes = new HashSet<InteractionContextType>(contextTypes);
|
||||
return this;
|
||||
}
|
||||
|
||||
internal ModuleInfo Build(InteractionService interactionService, IServiceProvider services, ModuleInfo parent = null)
|
||||
{
|
||||
if (TypeInfo is not null && ModuleClassBuilder.IsValidModuleDefinition(TypeInfo))
|
||||
|
||||
Reference in New Issue
Block a user