Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Modal interactions don't support Regex. #2838

Open
3 tasks done
ImNoOSRS opened this issue Feb 7, 2024 · 4 comments
Open
3 tasks done

[Bug]: Modal interactions don't support Regex. #2838

ImNoOSRS opened this issue Feb 7, 2024 · 4 comments
Labels

Comments

@ImNoOSRS
Copy link
Contributor

ImNoOSRS commented Feb 7, 2024

Check The Docs

  • I double checked the docs and couldn't find any useful information.

Verify Issue Source

  • I verified the issue was caused by Discord.Net.

Check your intents

  • I double checked that I have the required intents.

Description

Modal interactions don't work with Regex (*)
ComponentInteraction's do work like that but modals do not.

Version

3.13.0

Working Version

No response

Logs

N/A

Sample

public class BotInteraction<TInteraction> : InteractionModuleBase<SocketInteractionContext<TInteraction>> where TInteraction : SocketInteraction
{
    
}
public class ModalCommands : BotInteraction<SocketModal>
{
    [ModalInteraction("example-modal-*")]
    public async Task exampleModalInteraction(GiveawayInfoModal modal)
    {
       await Context.Channel.SendMessageAsync("Oh this works now? Let ImNo know.");
    }
}

Packages

Discord.Interactions

Environment

Any

@ImNoOSRS ImNoOSRS added the bug label Feb 7, 2024
@Misha-133
Copy link
Member

Misha-133 commented Feb 11, 2024

Hey
Try setting TreatAsRegex to true for the ModalInteraction
ex.

[ModalInteraction("example-modal-*", TreatAsRegex = true)]

by default it treats the * as a wildcard for a parameter

@ImNoOSRS
Copy link
Contributor Author

Hey

Try setting TreatAsRegex to true for the ModalInteraction

ex.

[ModalInteraction("example-modal-*", TreatAsRegex = true)]

by default it treats the * as a wildcard for a parameter

Great idea, did not seem to work sadly :(

@krypto5863
Copy link

krypto5863 commented Oct 1, 2024

Unfortunately I can confirm this one too. A single asterisk worked when I turned on TreatAsRegex when I was testing with something akin to

// customId = example-modal-1
[ModalInteraction("example-modal-*", TreatAsRegex = true)]

But I need to pass through more complex information and it seems anything longer fails.

@BobVul
Copy link
Contributor

BobVul commented Oct 31, 2024

Hold on, in regex * is supposed to just mean "0 or more of the previous character". So example-modal-* would be expected to accept example-modal-, example-modal--, example-modal---, etc., but not example-modal-1. If you want regex to accept any character you need .* (any character, 0 or more) or .+ (any character, at least 1). So example-modal-.* or example-modal-.+ depending on your needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants