#Modal

1 messages · Page 1 of 1 (latest)

thorny fractal
#

How do I use the ModalInteraction attribut when using ModelBuilder?

urban vapor
#

By using custom IDs :P
Set it with ModalBuilder
Make sure it's the same in the ModalInteractionAttribute's parameter

thorny fractal
# urban vapor By using custom IDs :P Set it with `ModalBuilder` Make sure it's the same in the...

It doesn't work -_-

[ComponentInteraction("...", runMode: RunMode.Async)]
public async Task HnadleButtonInteractionAsync()
{
    TextInputBuilder notificationTextInput = new TextInputBuilder()
        .WithPlaceholder("Webhook Title")
        .WithLabel("Enter the webhook title")
        .WithValue("Title")
        .WithMaxLength(80)
        .WithRequired(false)
        .WithStyle(TextInputStyle.Short)
        .WithCustomId("WebhookBuilder_TextInput");

    Modal notificationModal = new ModalBuilder()
        .WithTitle("Webhook Title")
        .WithCustomId("WebhookBuilder_Title_Modal")
        .AddTextInput(notificationTextInput)
        .Build();

    await RespondWithModalAsync(notificationModal).ConfigureAwait(false);
}

[ModalInteraction("WebhookBuilder_Title_Modal", runMode: RunMode.Async)]
public async Task HandleModalInteractionAsync(string title)
{
    await RespondAsync("Test").ConfigureAwait(false);
}
urban vapor
thorny fractal
#

Why shouldn't it work with ModalInteraction?

#

@late cipher

#

sry for ping

late cipher
#

#support-dnet message

sweet crystalBOT
#
keylami
Message:

Continuation of the previous Generic Modal writeup. This one uses typeconverters.

// This code will handle all current layouts possible with modals, in 25 lines of code.
public class GenericInputModal<T1> : IModal
{
  public string Title => string.Empty;
  [ModalTextInput("first")]
  public T1 First {get;set;}
}
public class GenericInputModal<T1, T2> : GenericInputModal<T1>
{
  [ModalTextInput("second")]
  public T2 Second {get;set;}
}
public class GenericInputModal<T1, T2, T3> : GenericInputModal<T1,T2>
{
  [ModalTextInput("third")]
  public T3 Third {get;set;}
}
public class GenericInputModal<T1, T2, T3, T4> : GenericInputModal<T1, T2, T3>
{
    [ModalTextInput("fourth")]
    public T4 Fourth {get;set;}
}
public class GenericInputModal<T1, T2, T3, T4, T5> : GenericInputModal<T1, T2, T3, T4>
{
    [ModalTextInput("fifth")]
    public T5 Fifth {get;set;}
}
var ModalBuilderA = new ModalBuilder();
ModalBuilderA.WithTitle("Modal A");
ModalBuilderA.WithCustomId("modal-a");
ModalBuilderA.AddTe...
Quoted By:

@late cipher from #support-dnet in Discord.Net

tiny igloo
#

My project supports button interactions, slash commands, etc. Am I perhaps missing something that isn't in the intro ?

late cipher
#

is the handler for one in a class with Group attribute?

tiny igloo
#

Yes, it's in the same class as the command

#

Oh I did see you comment something about gruops in another help request...

late cipher
#

same thing applies to modal interactions

tiny igloo
#

Oh it's ModuleGroup

late cipher
#

You won't believe it

#

yup

tiny igloo
#

What if I don't want to ignore group names ?

#

What prefix do I have to give?

late cipher
#

you need to set a delimiter char first

#

in the InteractionServiceConfig
*one is passed into interaction service ctor

#

and then
let's say

  • the delimiter is |
  • you have a group module called module_name
  • you have a ModalInteraction("custom_id")
    set the custom id of the modal you respond with to module_name|custom_id
tiny igloo
#

I put '.', is that a dangerous one to use ?