简体   繁体   中英

How can i get an 'number' input in discord.js

I want to make a basic calculator in 'discord.js', but the calculating command doesn't work. Main input command is ':hiz'. When someone types something like ':hiz 5' it should add 10 to 5.

    if(message.content == ':hiz ')
{
    var input = message.content;
    var sayi = input.substr('4');
    console.log(sayi);
}

That is the code that i tried. It doesn't get the number that inputted. Is there an another way to do it?

您应该检查message.content.startsWith(':hiz ')而不是message.content == ':hiz '

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM