create a command that has spaces as one arg

for example, i would want a command with multiple spaces for each arg, such as !command <argwithspaces1> <argwithspaces2>, or even using seperators like | i just dont know where to start or if its even possible at all ( i tried using args.repeat and args.nextMaybe but that didnt work at all )
10 Replies
Oreo ™
Oreo ™2y ago
u can do that with qoutes !command "this is the first arg" "this is the second arg" docs: https://sapphirejs.dev/docs/Documentation/api-framework/interfaces/CommandOptions#quotes
Sapphire Framework
Interface: CommandOptions | Sapphire
The Command options.
Oreo ™
Oreo ™2y ago
otherwise its impossible to know when an arg ends
Oreo ™
Oreo ™2y ago
Sapphire Framework
Creating your own arguments | Sapphire
Creating an argument can be done by extending the Argument class which can be imported from the framework:
Favna
Favna2y ago
or just use slash commands because string options natively support spaces 👀
Bejasc
Bejasc2y ago
This is the best option, but doesn't work for every case. For example, you can't use newlines or any formatting characters in it. One of my main use cases (and the quotes work totally fine for this) is that you can create a message embed.
"**To format the description**,

I often find myself running message commands _that look like_
- this
"
"**To format the description**,

I often find myself running message commands _that look like_
- this
"
You cannot get that from the slash command - it would be returned as To format the description, I often find myself running message commands that look like this
djoh the III
djoh the III2y ago
I'm pretty sure you can use \n for newlines
Bejasc
Bejasc2y ago
Nope - does not work. formatting *does* work - I thought I'd had issues with that in the past (In the context of my command, you wouldn't be formatting without newlines.
No description
No description
djoh the III
djoh the III2y ago
:DentGeHmm:
KaydaFox
KaydaFox2y ago
The only way I know of without using modal commands for actual new line support is to use a modal
MRDGH2821
MRDGH28212y ago
I had this solved, your code receives \\n instead of \n. So you need some preprocessing before sending out the embed I don't remember the syntax, but its something like this:
string.replace('\\n', '\n')
string.replace('\\n', '\n')
or this:
string.replaceAll('\\n','\n')
string.replaceAll('\\n','\n')

Did you find this page helpful?