# 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')
    },
  })
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://n-f9.gitbook.io/quack.js/guide/ping-pong.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
