# discord-interactions-zero

> Discord Interactions API handlers.

Latest version **3.0.2** (published 2023-04-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install discord-interactions-zero
pnpm add discord-interactions-zero
yarn add discord-interactions-zero
bun add discord-interactions-zero
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2023-04-03 |
| First published | 2022-06-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 22.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Goodsie |
| Maintainers | goodsie |
| Keywords | discord, interactions, autocode |

## Links

- npm: https://www.npmjs.com/package/discord-interactions-zero
- Repository: https://github.com/gidsola/Discord-Interactions
- Homepage: https://github.com/gidsola/Discord-Interactions#readme
- Issues: https://github.com/gidsola/Discord-Interactions/issues
- npm.io page: https://npm.io/package/discord-interactions-zero

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) ^1.1.3
- [form-data](https://npm.io/package/form-data.md) ^4.0.0

## Recent versions

- 3.0.2 (latest) — 2023-04-03
- 3.0.1 — 2023-04-01
- 3.0.0 — 2023-03-31
- 2.1.1-a — 2022-11-27
- 2.1.1 — 2022-11-27
- 2.1.0-d — 2022-11-16
- 2.1.0-c — 2022-11-15
- 2.1.0-b — 2022-11-14
- 2.1.0-a — 2022-11-14
- 2.1.0 — 2022-11-13
- 2.0.9 — 2022-11-13
- 2.0.7 — 2022-11-10
- 2.0.5-f — 2022-09-04
- 2.0.5-e — 2022-09-04
- 2.0.5 — 2022-09-04
- … 10 more at https://npm.io/package/discord-interactions-zero/versions

## README

# Discord Interactions Zero
**Discord Interactions API handlers.**  

**Version 3.0.2 changelog**
  - corrected 2 inputs that got reverted somehow
  - Updated the return handler.  
  
**Version 3.0.1 changelog**
  - error outputs are up-to-date
  - used api version updated to current.  

### Callbacks:
**https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type**  

| name | type | description |
|---|---|---|
| callback.reply  | 4 | Immediately respond to an interaction. |
| callback.defer  | 5 | Show thinking state, create followup after. |
| callback.component_defer  | 6 | Deferred message for components. |
| callback.component_update  | 7 | Components message update. |
| callback.autocomplete_reply  | 8 | Show autocomplete results |
| callback.modal_reply  | 9 | Reply to command with modal popup |
| callback.get_original  | @ | Get original interaction. |
| callback.edit_original  | @ | Edit original interaction. |
| callback.delete_original  | @ | Delete original interaction. |


### FollowUps:
**https://discord.com/developers/docs/interactions/receiving-and-responding#followup-messages**  

| name  | description  |
|---|---|
| followup.create  | Create a followup message for an Interaction.  |
| followup.edit  | Edits a followup message for an Interaction.  |
| followup.get  | Returns a followup message for an Interaction.  |
| followup.del  | Deletes a followup message for an Interaction.  |

### Examples:

```js  
const interaction = require('discord-interactions-zero');  

await interaction.callback.defer(event, {ephemeral: false});

  let stuff = "Hello World";

  if (stuff) {
    try {
      await interaction.followup.create(event, {
        ephemeral: false,
        content: stuff,
      });
    } catch (e) {
      console.log(e);
    }
  }
```  


```js  
const interaction = require('discord-interactions-zero');  

await interaction.callback.modal_reply(event, {
    custom_id: `suggestion`,
    title: `Suggestion Box`,
    components: [{
      type: 1,
      components: [{
        type: 4,
        custom_id: "suggestion",
        label: "Suggestion:",
        style: 2,
        min_length: 1,
        max_length: 300,
        placeholder: "I love Ghastli!",
        required: true
      }]
    }]
  });
```  


```js
const interaction = require('discord-interactions-zero');

await interaction.callback.reply(event, {
  ephemeral: true,
  content: '',
  embeds: [
    {
      type: `rich`,
      title: `title`,
      description: `description.`,
      color: 0x082020,
      thumbnail: {
        url: `https://`,
        height: 0,
        width: 0,
      },
      author: {
        name: `author`,
      },
      footer: {
        text: `footer text goes here, you can make it substantial.`,
        icon_url: `https://`,
      },
    },
  ],
  components: [
    {
      type: 1,
      components: [
        {
          style: 2,
          label: `label`,
          custom_id: `id`,
          disabled: false,
          type: 2,
        },
        {
          style: 2,
          label: `label`,
          custom_id: `id`,
          disabled: false,
          type: 2,
        },
        {
          style: 2,
          label: `label`,
          custom_id: `id`,
          disabled: false,
          type: 2,
        },
      ],
    },
  ],
});
```


```js
const interaction = require('discord-interactions-zero');

await interaction.callback.component_defer(event, {ephemeral: true});

  if (!event.member.roles.includes(roleid)) {
    await interaction.followup.edit(event, {
      message_id: @message.id,
      content: ``,
      embeds: [
        {
          type: 'rich',
          title: `Error!`,
          description: `🔔 This is not one of your roles.`,
          color: 0x082020,
        },
      ],
      components: ,
    });  
```  

My hiding place on Discord:  
https://discord.gg/BFTzF8tj9K

---
_Source: https://npm.io/package/discord-interactions-zero · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
