Process Command function

    0

    15

    khalid35

    Discord Js Cookbook

    Shortcut: discord.processcommand

    function processCommand(receivedMessage) {
        let fullCommand = receivedMessage.content.substr(1) // Remove the leading exclamation mark
        let splitCommand = fullCommand.split(" ") // Split the message up in to pieces for each space
        let primaryCommand = splitCommand[0] // The first word directly after the exclamation is the command
        let arguments = splitCommand.slice(1) // All other words are arguments/parameters/options for the command
        console.log("Command received: " + primaryCommand)
        console.log("Arguments: " + arguments) // There may not be any arguments
        if (primaryCommand == "<Enter Command 1>") { //Enter Command 1
          <Enter Command 1>Command(arguments, receivedMessage)
        } else if (primaryCommand == "<Enter Command 2>") { //Enter Command 2
            <Enter Command 2>(arguments, receivedMessage)}
        else if (primaryCommand == "<Enter Command 2>") {  //Enter Command 3
                <Enter Command 2>(arguments, receivedMessage)
        } 
        else {
            receivedMessage.channel.send("I don't understand the command. Try Something else")//enter your error message
        }
    }
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.