Broken button handler: "interaction.isButton is not a function"

Discord.js npm version: 14.16.3 Node.js version: 20.9.0 Since yesterday I cant handle any interaction events where I check if the interaction is a button / chatinputcommand or modalsubmit interaction anymore (I only have these three). They are all build similar. Here is my handleButtons code for the interactionCreate event:
import { mainLogger } from "../../config";
import { ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder, ModalActionRowComponentBuilder, ButtonInteraction } from "discord.js";

module.exports = async (interaction: ButtonInteraction) => {
// Creating the logging Object for our command handler
const buttonExecutionLoggingObj = { main: false, sub: true };
const buttonExecutionLogger = mainLogger.getSubLogger({ name: "ButtonExecutionLogger" }, buttonExecutionLoggingObj);

// Loglevel setting 0 = silly, 1 = trace, 2 = debug, 3 = info, 4 = warn, 5 = error, 6 = fatal
buttonExecutionLogger.settings.minLevel = 2;

buttonExecutionLogger.debug("Button execution started...");
buttonExecutionLogger.debug("Interaction customId ", interaction.customId)

// Check if the interaction is a command
buttonExecutionLogger.debug(`Checking if the interaction is with a button...`);
if (!interaction.isButton()) {
buttonExecutionLogger.trace("Interaction is not with a button.");
return;
}

// Doing things afterwards...

}
import { mainLogger } from "../../config";
import { ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder, ModalActionRowComponentBuilder, ButtonInteraction } from "discord.js";

module.exports = async (interaction: ButtonInteraction) => {
// Creating the logging Object for our command handler
const buttonExecutionLoggingObj = { main: false, sub: true };
const buttonExecutionLogger = mainLogger.getSubLogger({ name: "ButtonExecutionLogger" }, buttonExecutionLoggingObj);

// Loglevel setting 0 = silly, 1 = trace, 2 = debug, 3 = info, 4 = warn, 5 = error, 6 = fatal
buttonExecutionLogger.settings.minLevel = 2;

buttonExecutionLogger.debug("Button execution started...");
buttonExecutionLogger.debug("Interaction customId ", interaction.customId)

// Check if the interaction is a command
buttonExecutionLogger.debug(`Checking if the interaction is with a button...`);
if (!interaction.isButton()) {
buttonExecutionLogger.trace("Interaction is not with a button.");
return;
}

// Doing things afterwards...

}
The error is attached as a screenshot because of discords text limitations. If you need any more code or other information, please feel free to ask
No description
7 Replies
d.js toolkit
d.js toolkit2mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
treble/luna
treble/luna2mo ago
How are you calling that function
d.js docs
d.js docs2mo ago
To share long code snippets, use a service like gist, sourcebin, pastebin, or similar instead of posting them as large code blocks or files.
Luke5090
Luke5090OP2mo ago
The interactionCreate event is loaded via my event handler: https://pastebin.com/kcRbutFB
Pastebin
eventHandler.ts - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
d.js docs
d.js docs2mo ago
The order of function parameters must match between definition and function call.
function execute(client, interaction) { ... };
execute(interaction, client);
function execute(client, interaction) { ... };
execute(interaction, client);
- mismatch! you pass an interaction where the client is expected - mismatch! you pass the client where an interaction is expected
treble/luna
treble/luna2mo ago
Yeah you pass in a client there But never account for it, nor do you need to pass one in Virtually all djs structures have a client property
Luke5090
Luke5090OP2mo ago
Ohh thats good to know. Thank you I really did not look at my parameter input there. Suprisingly it was working all the time, it just broke a few days ago. I`ll try the other ones as well. If it works I will mark this as solved :)
Want results from more Discord servers?
Add your server