<function> is not a function

Hey, I have a function out of anything, at top of my code named ticket. It works anywhere else but does not work in a specific line of code. Idk why, but it declares it a parameter instead of a function! + node.js 16 + discord.js v13.12.0 + using mongodb
6 Replies
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
Pooyan
Pooyan17mo ago
if (interaction.customId == 'ticket_create_ped') {
const Schema = require('./models/ticket');
const profile = require('./models/user');

await profile.findOne({ userId: interaction.user.id }, async (err, data) => {
if (data) {
data.tickets.forEach(async ticket => {
if (ticket == 'pedbackstory') {
return interaction.reply({ content: ':x: There is already a Ticket opened with Reason (Ped Backstory) by you!', ephemeral: true });
} else {
ticket('1067743171431374918', 'ped', 'pedbackstory', 'Ped Backstory', interaction) //! it doesn't work here and this function is turned to a (parameter)
}
})
} else {
ticket('1067743171431374918', 'ped', 'pedbackstory', 'Ped Backstory', interaction) // ticket('CATEGORY_ID', 'channel_name', 'reason_db', 'Topic', interaction)
new profile({
userId: interaction.user.id,
tickets: 'pedbackstory'
}).save();
}
})
}
if (interaction.customId == 'ticket_create_ped') {
const Schema = require('./models/ticket');
const profile = require('./models/user');

await profile.findOne({ userId: interaction.user.id }, async (err, data) => {
if (data) {
data.tickets.forEach(async ticket => {
if (ticket == 'pedbackstory') {
return interaction.reply({ content: ':x: There is already a Ticket opened with Reason (Ped Backstory) by you!', ephemeral: true });
} else {
ticket('1067743171431374918', 'ped', 'pedbackstory', 'Ped Backstory', interaction) //! it doesn't work here and this function is turned to a (parameter)
}
})
} else {
ticket('1067743171431374918', 'ped', 'pedbackstory', 'Ped Backstory', interaction) // ticket('CATEGORY_ID', 'channel_name', 'reason_db', 'Topic', interaction)
new profile({
userId: interaction.user.id,
tickets: 'pedbackstory'
}).save();
}
})
}
Pooyan
Pooyan17mo ago
Parogo_72
Parogo_7217mo ago
Unless I am reading it incorrectly, ticket is a string You are comparing it with pedbackstory Perhaps you messed up with the variable names
Pooyan
Pooyan17mo ago
no check your dm I think I fixed it.. When I run it, it's a parameter But when I stop the bot it's a function :/ the function of forEach is the same name as the TICKET FUNCTION
Yinoguns
Yinoguns17mo ago
This is also not a DJS issue #useful-servers / #resources / <#869652447881207858>