Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

i`m try to make this:

!send <id> message who sended (message who sended is 3 args but i'm need one)

Who send arguments after message ID (args[0]) for everyone who reacted to message in DM. How make from arguments after first argument, next argument?

        const messageID = parseInt(args[0]);
        var messageContent = message.substring(1).split(' ');

I`m try this, but I'm not sure it will work.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
358 views
Welcome To Ask or Share your Answers For Others

1 Answer

If you want to join multiple arguments together, you can use splice and join

To begin, we need to define it as a new variable equal to args

messageable = args

Next, use splice to make a new array out of the index. If you want to make it so it is everything after the <id>, remove ,5, so .splice(2)

messageable = args.splice(2,5)

Finally, join it into a string using join, adding a space in-between the arguments

messageable = args.splice(2,5).join(" ")

With this, messageable should look like "message who sended"


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...