N
N
Nikita Kudrin2020-11-27 15:26:52
Node.js
Nikita Kudrin, 2020-11-27 15:26:52

How to make the bot not see the space?

The bot has a '!' prefix, but people have T9 on their phones and after ! they automatically put a space, how to make the bot both on !help and on ! help reacted the same way? (The command was as an example.)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
REzebro, 2020-11-27
@HepkaPlay

a universal solution if you find a prefix in the message to perform actions to find the command.
I would add:
1. check for a prefix at the beginning of the line, so as not to once again check for a match of commands in a message without a prefix.
2. cut the string to the length of the prefix
and then, if you do not plan to use compound commands (of more than 1 word), compare all the content in the message, or
divide the string by spaces and save "parts of the commands" that will still be needed later.
and then you can already check where the command is

cmdName  = (cmdParts[0]== "") ?  cmdParts[1] : cmdParts[0]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question