

- #JAVASCRIPT ERROR ON DISCORD WONT OPEN INSTALL#
- #JAVASCRIPT ERROR ON DISCORD WONT OPEN FULL#
- #JAVASCRIPT ERROR ON DISCORD WONT OPEN CODE#
#JAVASCRIPT ERROR ON DISCORD WONT OPEN CODE#
Put it together, we will have this small piece of code // ntent = "$quote Crawl Grey is too cute" // expected result = "Crawl said: Grey is too cute" // the first word of the content is the command and thus can be ignored after we run command check // the second word (args1) is the author of the quote // the rest of the content (args2) is the content of the quote This will put all the Array elements into a string, separated by the separator. This method will return an array.Īrray.slice(position, ) kinda similar to the String.slice, Array.slice will return part of the array starting from the position and has an optional length.Īrray.join(separator) is the opposite of the String.split. String.split(separator) will split the string into smaller strings which were previously separated by the separator, and then put them into an array. And luckily, javascript have a method that does exactly that. So if you want to have several arguments, each arguments separated by a space, then you will need a way to "split" the string into array. This is simple and easy to understand, however if you have several arguments, then things will get a little dicey. This is a basic string manipulation to get the content of the message after the first space. However if you want to change the nickname of someone else, you might need to get the content AFTER the command. In ping command, you don't need arguments. This will be a problem if the content is just simply "$ping" though, so we add a space at the end of the message's content as well, and now both the content and the command checking will match.
#JAVASCRIPT ERROR ON DISCORD WONT OPEN FULL#
let content = msg.content + ' ' īy adding a space at the end of the command, we indicate that the "ping" is a full word, and "pingAister" or "pinguin" won't trigger the command. The way we do this is by add a space at the end of the command as well as the command. This works for most of the time, however it does have some downsides: If there's another command that starts with the same string as another command, for example, " inviteMe" which give a bot's auth link and " invite" which will give the guild's invite link, then there might be some conflict due to ("$invite") will also return true for the "$inviteMe". The code above will direct the process flow into the Ping command block if the message's content starts with "$ping", if it doesn't (aka else), it will check if the content starts with "$repeat" and goes into the Repeat command block if it does.

#JAVASCRIPT ERROR ON DISCORD WONT OPEN INSTALL#
Best case scenario it works and all future updates work, worst case scenario you have to use the web version if it won't install at all. And unless you know when you can not use it, please use it to properly mark the start and end of the block. I reckon your best option (if you haven't already), is to completely uninstall discord from your machine, head to the website and download the latest installer. The basic guides made by evie use this method, which basically check if the message's content starts with a certain string, in our case, it's prefix + command if (( "$ping")) indicate a block, and in this case, an if and else if block.

Almost all the discord.js basic tutorial, be it text or video, is using this method. This method use simple logic to make the process flow goes into different blocks depends on the command. The if - else block is the most basic way to handle commands.
