> For the complete documentation index, see [llms.txt](https://ephf.gitbook.io/discord-short/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ephf.gitbook.io/discord-short/creating-bot-commands/reactions-command-replies.md).

# Reactions / Command Replies

Discord.Short offers a lot of cool things you can do with reactions

When you make a command, you can get the output / reply by running a function, lets start off by creating a giveaway command:

```javascript
new ds.Command({
    name: 'giveaway',
    async execute({send}) {
        send('Hello!');
    }
});
```

we can get the `"Hello!"` message by running this function:

```javascript
new ds.Command({
    name: 'giveaway',
    async execute({send}) {
        send('Hello!');
        let hello = await ds.getNextReply(); // here!
    }
});
```

now we have a message object of the reply, although this is not how we are going to make the command, lets react with a party popper

```javascript
new ds.Command({
    name: 'giveaway',
    async execute({send}) {
        send('Hello!');
        let hello = await ds.getNextReply();
        hello.react('🎉');
    }
});
```

When we run the `!giveaway` command, we will get this:

![in discord](https://1070540812-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M_6wR-SQ66c91BUYwWE%2F-M_CmAKjs8FbtezCwlAw%2F-M_DQ-Z9ycDV8kFdwDp9%2Fgiveawayhello.png?alt=media\&token=7ce8637f-7931-40f0-8dd1-3aaff08a75d0)

This is cool, but we want something to actually happen when we react to the message, so lets run this function

```javascript
new ds.Command({
    name: 'giveaway',
    async execute({send}) {
        send('Hello!');
        let hello = await ds.getNextReply();
        // here!
        ds.reactEvent(hello, '🎉', function({arguments}) {
            // args
        });
    }
});
```

where the function says `arguments` you can add any of these:

* `user` - the person who reacted
* `channel` - the channel the message that was reacted to was in
* `message` - the message that was reacted to
* `send()` - send a message in the channel where the reaction was

so lets make it send a message whenever someone reacts:

```javascript
new ds.Command({
    name: 'giveaway',
    async execute({send}) {
        send('Hello!');
        let hello = await ds.getNextReply();
        ds.reactEvent(hello, '🎉', function({send, user}) {
            send(`${user.username} reacted with 🎉`); // here!
        });
    }
});
```

now when we run the command and react, it should look like this:

![in discord](https://1070540812-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M_6wR-SQ66c91BUYwWE%2F-M_CmAKjs8FbtezCwlAw%2F-M_DSYE5-g3VFIXPIxv5%2Fgiveawayhelloreact.png?alt=media\&token=d69b42c1-6292-403e-af7a-28f88a04cafe)

then, we can make the giveaway work. I have a simple premade example, so ill just show it here:

```javascript
new ds.Command({
    name: 'giveaway',
    async execute({send, author, args}) {
        send(new MessageEmbed({
            title: '🎉 Giveaway!',
            description: `<@${author.id}> is giving away **${args[0]}**`,
            footer: {
                text: 'to enter, react to this message with 🎉'
            },
            color: 'BLUE'
        }));
        let players = [];
        ds.reactEvent(await ds.getNextReply(), '🎉', function({user}) {
            players.push(user);
        });
        setTimeout(function() {
            let rng = Math.floor(Math.random() * (players.length - 1));
            send(`Congrats! 🎉\n> <@${players[rng].id}> won **${args[0]}**`);
        }, Number(args[1]) * 1000);
    }
});
```

now if we run, `!giveaway example 10` it will create a giveaway for "example" and will end in 10 seconds

after the giveaway, it will look something like this:

![in discord](https://1070540812-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M_6wR-SQ66c91BUYwWE%2F-M_CmAKjs8FbtezCwlAw%2F-M_DTLPzIzcebdfL-L56%2Fgiveawayend.png?alt=media\&token=fda04f46-cf79-4783-9cab-c6c316f5b2ff)

Similarly to `ds.reactEvent();` you can see when someone un-reacts, it has the same syntax:

```javascript
ds.unreactEvent(await ds.getNextReply(), '🎉', function({arguments}) {
    // args
});
```
