Inhibitor

Inhibitors always run before the command itself.
Here is a blacklist example:

let blacklist = (await client.database.get("blacklist")) || [];

client.dispatcher.addInhibitor((client, { respond, message, interaction, author }) => {
  if ((message) && blacklist.includes(author.id)) {
    respond({
      content: "You are blacklisted from using this bot!",
      ephemeral: true,
    });
    return false;
  } else if (
    interaction &&
    interaction.isMessageComponent() &&
    blacklist.includes(author.id)
  ) {
    interaction.reply.send({
      content: "You are blacklisted from interacting with this bot!",
      ephemeral: true,
    });
    return false;
  }

  return true;
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
let blacklist = (await client.database.get("blacklist")) || [];

client.dispatcher.addInhibitor((client, { respond, interaction, message, author }) => {
  if (
    interaction &&
    interaction.isMessageComponent() &&
    blacklist.includes(author.id)
  ) {
    respond({
      content: `You are blacklisted from ${
        interaction.isButton() ? "pressing buttons" : "filling select menus"
      } from this bot!`,
      ephemeral: true,
    });
    return false;
  }

  return true;
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19