Browse Source

init

pull/2169/head
Cenk Ergen 3 years ago
parent
commit
d8a7ddbd34
2 changed files with 58 additions and 0 deletions
  1. +39
    -0
      src/Discord.Net.Interactions/Builders/Parameters/ComponentCommandParameterBuilder.cs
  2. +19
    -0
      src/Discord.Net.Interactions/Info/Parameters/ComponentCommandParameterInfo.cs

+ 39
- 0
src/Discord.Net.Interactions/Builders/Parameters/ComponentCommandParameterBuilder.cs View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Discord.Interactions.Builders
{
public class ComponentCommandParameterBuilder : ParameterBuilder<ComponentCommandParameterInfo, ComponentCommandParameterBuilder>
{
public TypeReader TypeReader { get; private set; }
protected override ComponentCommandParameterBuilder Instance => this;

public ComponentCommandParameterBuilder(ICommandBuilder command) : base(command) { }

public ComponentCommandParameterBuilder(ICommandBuilder command, string name, Type type) : base(command, name, type) { }

/// <inheritdoc/>
public override ComponentCommandParameterBuilder SetParameterType(Type type) => SetParameterType(type, null);

/// <summary>
/// Sets <see cref="ParameterBuilder{TInfo, TBuilder}.ParameterType"/>.
/// </summary>
/// <param name="type">New value of the <see cref="ParameterBuilder{TInfo, TBuilder}.ParameterType"/>.</param>
/// <param name="services">Service container to be used to resolve the dependencies of this parameters <see cref="TypeConverter"/>.</param>
/// <returns>
/// The builder instance.
/// </returns>
public ComponentCommandParameterBuilder SetParameterType(Type type, IServiceProvider services = null)
{
base.SetParameterType(type);
TypeReader = Command.Module.InteractionService.GetTypeConverter(ParameterType, services);
return this;
}

internal override ComponentCommandParameterInfo Build(ICommandInfo command)
=> new(this, command);
}
}

+ 19
- 0
src/Discord.Net.Interactions/Info/Parameters/ComponentCommandParameterInfo.cs View File

@@ -0,0 +1,19 @@
using Discord.Interactions.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Discord.Interactions
{
public class ComponentCommandParameterInfo : CommandParameterInfo
{
public TypeReader TypeReader { get; }
internal ComponentCommandParameterInfo(ComponentCommandParameterBuilder builder, ICommandInfo command) : base(builder, command)
{
TypeReader = builder.TypeReader;
}
}
}

Loading…
Cancel
Save