> For the complete documentation index, see [llms.txt](https://n-f9.gitbook.io/quack.js/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://n-f9.gitbook.io/quack.js/guide/ping-pong.md).

# Ping Pong

Quack.js provides three options for reading in user input, slash commands, events, and triggers. Also, the events are expanded from Discord.js' base events utilizing the [discord-logs package](https://www.npmjs.com/package/discord-logs).

### Slash Command

[Slash commands](https://discord.com/blog/slash-commands-are-here) are a handy feature of Discord, they provide an easy-to-use UI and awesome development features.&#x20;

```javascript
export default (Quack) => {
  Quack.CreateCommand({
    name: 'ping', // the name of the slash command
    description: 'Ping', // the description of the slash command
    permission: 'everyone', // the permission of the slash command, 
                            // if set to everyone then anyone can run it. 
                            // It can be set to a role id for specific role 
                            // use (make sure to set the defaultPermissions
                            // as well).
    guilds: ['728269506710995034'], // the guilds which the slash command 
                                    // will be added to. If none are added,
                                    // then it's a global command.
    execute(interaction) {
      interaction.reply('pong!')
    }
  })
}
```

And boom, you added your first slash command!

### Events

Another way to create ping functionality is via events. You can simply do this y creating a messageCreate event, for example.

```javascript
export default (Quack) => {
  Quack.CreateEvent({
    name: 'messageCreate',
    execute(client, message) {
      if (message.content.startsWith('ping')) {
        message.reply('pong')
      }
    }
  })
}
```

### Triggers

Triggers are a handy little tool. If a regex or a normal string is met, the trigger will fire and you are able to perform an action.

```javascript
export default (Quack) => {
  Quack.CreateTrigger({
    name: 'ping',
    trigger: 'ping',
    execute(client, message) {
      message.reply('pong')
    },
  })
}
```
