#Line 33 creates the event yes but it

1 messages · Page 1 of 1 (latest)

nocturne sequoia
#

What makes me think that the client is not receiving the events is the fact that Raw and Debug never fire when clicking the button. They just sit quite until a heartbeat occurrs.

#

You could really replace response with interaction per the code in the documentation. I just used that generically across all of the events to see what was actually firing when I clicked the button.

rain pawn
#

you shouldn't be listening to Raw in the first place, a button interaction should always fire an InteractionCreate event unless you are missing the Guilds intent

nocturne sequoia
#

It should, but it isn't is the issue.

#

Client setup:

rain pawn
#

and your interactionCreate event handler how is it

nocturne sequoia
#

I was only listening to raw to see if something was happening around the interaction. But it dead silent when clicking the button.

#
# Starting the application
Debug
Debug
Debug
Debug
Debug
Debug
Raw
Debug
Debug
Debug
Raw
Debug
Debug
Raw
Debug
Client ready
Raw
Debug
Raw

# I send "asdf" message
MessageCreate message other than 'Button?' seen
Raw

# I send "Button?" message
MessageCreate message received for Button?
Raw

# Bot sends message with Button
MessageCreate message other than 'Button?' seen

# I click the button and nothing happens
# I send "asdf" message
Raw
MessageCreate message other than 'Button?' seen
rain pawn
#

okay but show me your interactionCreate handler

nocturne sequoia
#
client.on(
  Events.InteractionCreate,
  response => console.debug(
    "InteractionCreate",
    response
  )
);
#

Split for readability there.

#

I just want to know it's being called.

#

Log somethinganything.

#

But it logs nothing. I can send message and log that I saw them without issue.

rain pawn
#

you sure you imported Events correctly? which version of the library are you using?

nocturne sequoia
#
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, Client, Events, GatewayIntentBits } from "discord.js";
#

Version 14.9.0

#

If Events was imported incorrectly, I would fully expect the MessageCreate handler to not work, but it does.

rain pawn
#

Okay hmmmmm

nocturne sequoia
#

Yeah…

#

It's so weird.

rain pawn
#

can you just send the full script hiding your token

nocturne sequoia
#
"use strict";

// Third Party
import "dotenv/config";
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, Client, Events, GatewayIntentBits } from "discord.js";

// Project
import { AppConfig } from "./config.js";

const config = new AppConfig(process.env);
const client = new Client({
  intents: [
    GatewayIntentBits.DirectMessages,
    GatewayIntentBits.DirectMessageReactions,
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.GuildMessageReactions,
    GatewayIntentBits.MessageContent
  ]
});

client.login(config.discordToken);
client.once(Events.ClientReady, instance => console.debug(`Client ready`));

client.on(Events.Error, response => console.debug("Error"));
client.on(Events.Warn, response => console.debug("Warn"));
client.on(Events.Debug, response => console.debug("Debug"));
client.on(Events.Raw, response => console.debug("Raw"));
client.on(Events.InteractionCreate, response => console.debug("InteractionCreate", response));
client.on(Events.MessageCreate, message => {
  if (message.content === "Button?") {
    console.debug("MessageCreate", "message received for Button?");

    return message.reply({
      components: [
        new ActionRowBuilder()
          .addComponents(
            new ButtonBuilder()
              .setCustomId("select-test")
              .setLabel("Test Button")
              .setStyle(ButtonStyle.Primary)
          )
      ],
      content: "Test button creation."
    });
  } else {
    console.debug("MessageCreate", "message other than 'Button?' seen");
  }
});
#

AppConfig is just a wrapper for the process.env parsing.

rain pawn
#

hmm

nocturne sequoia
#

Yeah… It seems like it should work.

#

That's why I wonder if something was missing from the setup/config with the Discord Server, but it has Admin permissions and was registered using their suggested URL.

rain pawn
#

can you instead of using console.debug just do response.reply("something")

#

save and restart

nocturne sequoia
#

Did that in many ways suggested by documentation, but will do so again. = )

rain pawn
nocturne sequoia
rain pawn
#

this is weird af, I have no idea what is happening

nocturne sequoia
#

Yeah!

#

Mind. Boggling.

#

Literally cannot even with this. o_O

#

Everything suggests it should work. But nothing…

#

Just zero events.

#

I tried the raw string in place. Nope.

#

I tried logging all events listed on the Events enum, nope.

#

Are there some magic bits in the Application/Bot registration within Discord itself I need to set before inviting it? 🤔

#

Like this stuff:

rain pawn
#

the only one I know is the application.commands scope but that one is supposed to just let your bot update and create slash commands on the guild, i dont think that one should affect buttons and other interactions

tranquil bone
nocturne sequoia
nocturne sequoia
#

Added:

client.on(Events.MessageCreate, message => {
  console.debug(events.getEventListeners(client, "interactionCreate"));
  console.debug(events.getEventListeners(client, Events.InteractionCreate)
    .map(f => f.toString())
  );
#

Sent an asdf message to the channel for the message event to fire.

tranquil bone
#

That means the event is created, just not getting fired, now this issue is absolutely unsolvable

nocturne sequoia
#

😩

#

Time to go classic IRC bot style I guess… 😒

tranquil bone
nocturne sequoia
#

Hrm…

frail nebulaBOT
#

Suggestion for @nocturne sequoia:
guide Additional Information: Additions - InteractionCollector
read more

#

Suggestion for @nocturne sequoia:
guide Additional Information: Additions - InteractionCollector
read more

nocturne sequoia
#

It looks like it just auto-collects the message but not the intereaction.