Property of 'lang' cannot be read - javascript

I am trying to make a text to speech discord bot. I'm more of a newbie to coding so I don't exactly understand what is going on here. The code I wrote is for executing a simple command called 'lang' which will switch the TTS language.
const prefix = process.env.prefix;
const languages = require('../../data/languages.json');
module.exports = {
name: 'lang',
description: 'Change the TTS language.',
emoji: ':map:',
execute(message, options) {
let [newLang] = options.args;
const { ttsPlayer } = message.guild;
if (!newLang) {
message.reply(`to set-up the TTS language, run: **${prefix}lang <lang_code>**
To see a list of the available lang codes, run: **${prefix}langs**.
The current language is set to: **${languages[ttsPlayer.lang]}**.`);
return;
}
newLang = newLang.toString().toLowerCase();
ttsPlayer.setLang(newLang)
.then((setLang) => {
message.reply(`language has been set to **${setLang}**.`);
})
.catch((error) => {
message.reply(error);
});
}
}
The error I get is:
2020-03-04T22:04:23.278707+00:00 app[worker.1]: [31m(10:04:23 PM) - [ERROR] - TypeError: Cannot read property 'lang' of null
2020-03-04T22:04:23.278709+00:00 app[worker.1]: at Object.execute (/app/src/commands/lang.js:15:63)
2020-03-04T22:04:23.278710+00:00 app[worker.1]: at executeCommand (/app/src/common/utils.js:46:13)
2020-03-04T22:04:23.278710+00:00 app[worker.1]: at Object.handleMessage (/app/src/events/handlers/app.js:50:3)
2020-03-04T22:04:23.278711+00:00 app[worker.1]: at Client.<anonymous> (/app/index.js:33:55)
2020-03-04T22:04:23.278711+00:00 app[worker.1]: at Client.emit (events.js:323:22)
2020-03-04T22:04:23.278712+00:00 app[worker.1]: at MessageCreateAction.handle (/app/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
2020-03-04T22:04:23.278713+00:00 app[worker.1]: at Object.module.exports [as MESSAGE_CREATE] (/app/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
2020-03-04T22:04:23.278715+00:00 app[worker.1]: at WebSocketManager.handlePacket (/app/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
2020-03-04T22:04:23.278715+00:00 app[worker.1]: at WebSocketShard.onPacket (/app/node_modules/discord.js/src/client/websocket/WebSocketShard.js:435:22)
2020-03-04T22:04:23.278715+00:00 app[worker.1]: at WebSocketShard.onMessage (/app/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)
Can someone help me out?

I suppose problem is that variable ttsPlayer is null.
Please check if such property is present at message.guild?

Related

Read information from embed message Discord.JS

enter image description here
I want my keytritz bot to react to an embed when the title is naruto / Naruto but in the first one I got an error (# 1) but it did not affect the functionality but in the second embed (#2) I got an error that the keytritz bot did not react and did not commented
, I leave a link where is the code of both bots, the mudae bot is not mine.
https://mega.nz/folder/IIUHEabJ#IIaRNcMgUS2gC-d_lZXQZw
https://top.gg/bot/432610292342587392
CODE Keytritz:
for(var i = 0; i < message.embeds.length; i++) {
message.channel.send(message.content.embeds);
if(message.embeds[i].title.includes("naruto")){
message.react(" ")
message.channel.send("Detected");
break;
}
}
Embed lxXxandresxXxl
if(message.content.startsWith(prefix+"r")) {
message.channel.send({ embed: {
color: 3447003,
author: {
name: client.user.username,
icon_url: client.user.displayAvatarURL()
},
title: "This is an naruto embed",
url: "http://google.com",
description: "This is a test embed to showcase what they look like and what they can do.",
fields: [{
name: "Fields",
value: "They can have different fields with small headlines."
},
{
name: "Masked links",
value: "You can put [masked links](http://google.com) inside of rich embeds."
},
{
name: "Markdown",
value: "You can put all the *usual* **__Markdown__** inside of them."
}
],
timestamp: new Date(),
footer: {
icon_url: client.user.displayAvatarURL(),
text: "© Example"
}
}
});
}
Error 1#
(node:1744) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message
at RequestHandler.execute (/rbd/pnpm-volume/8bd4e7c9-1711-40fc-be45-7d082848ec2a/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/src/rest/RequestHandler.js:154:13)
at processTicksAndRejections (internal/process/task_queues.js:88:5)
at async RequestHandler.push (/rbd/pnpm-volume/8bd4e7c9-1711-40fc-be45-7d082848ec2a/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/src/rest/RequestHandler.js:39:14)
(node:1744) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1744) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Error 2#
if(message.embeds[i].title.includes("naruto")){
^
TypeError: Cannot read property 'includes' of null
at Client.<anonymous> (/app/server.js:90:36)
at Client.emit (events.js:196:13)
at MessageCreateAction.handle (/rbd/pnpm-volume/8bd4e7c9-1711-40fc-be45-7d082848ec2a/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/rbd/pnpm-volume/8bd4e7c9-1711-40fc-be45-7d082848ec2a/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/rbd/pnpm-volume/8bd4e7c9-1711-40fc-be45-7d082848ec2a/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/rbd/pnpm-volume/8bd4e7c9-1711-40fc-be45-7d082848ec2a/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/rbd/pnpm-volume/8bd4e7c9-1711-40fc-be45-7d082848ec2a/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/rbd/pnpm-volume/8bd4e7c9-1711-40fc-be45-7d082848ec2a/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/node_modules/ws/lib/event-target.js:132:16)
at WebSocket.emit (events.js:196:13)
at Receiver.receiverOnMessage (/rbd/pnpm-volume/8bd4e7c9-1711-40fc-be45-7d082848ec2a/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/node_modules/ws/lib/websocket.js:983:20)
I evaluate some code to tries to basically replicated what you do. and i come up with this code. Might help you a little bit, and also i tried this with my other test bot and i also found out if you sends a link for example https://google.com it will have an embed but on discord it isnt meaning it just read actual embed like from other bot or smth, anyway here what i got so far.
Discord.js V13
client.on('messageCreate', message => {
if(message.embeds.length >= 0)
// Check if the Message has embed or not
{
let embed = message.embeds
// console.log(embed) just a console.log
for(let i = 0; i < embed.length; i++)
// Loop it since in v13 you can send multiple embed in single message
{
if(embed[i].title === null) return;
// check each embed if it has title or not, if it doesnt then do nothing
if(embed[i].title.toLowerCase().includes('hi'))
// check each embed if it includes word 'hi' or not
{
message.react('🔳')
message.react('🎉')
}
}
}
})
P.S. This code will read another bot message
P.S.S If someone has a better way explained the code or wants to make changes, feel free to edit it

Resulting document after update is larger than 16777216

I'm getting two errors when I try adding new data to an array with mongoose. Here is my code:
return await db.fileMeta.findOneAndUpdate({
username: username,
'files.fileUID': {
$ne: data.fileUID
}
}, {
$addToSet: {
files: data
}
}).exec();
data is a JavaScript object with 25 items that amounts to 789 bytes... Nothing near 16MBs. My code worked fine until recently (last few days) then I started getting this error:
MongoError: BSONObj size: 16829075 (0x100CA93) is invalid. Size must be between 0 and 16793600(16MB) First element: $v: 1
at MessageStream.messageHandler (/home/user/projects/web-app/node_modules/mongoose/node_modules/mongodb/lib/cmap/connection.js:268:20)
at MessageStream.emit (events.js:314:20)
at processIncomingData (/home/user/projects/web-app/node_modules/mongoose/node_modules/mongodb/lib/cmap/message_stream.js:144:12)
at MessageStream._write (/home/user/projects/web-app/node_modules/mongoose/node_modules/mongodb/lib/cmap/message_stream.js:42:5)
at doWrite (_stream_writable.js:403:12)
at writeOrBuffer (_stream_writable.js:387:5)
at MessageStream.Writable.write (_stream_writable.js:318:11)
at TLSSocket.ondata (_stream_readable.js:719:22)
at TLSSocket.emit (events.js:314:20)
at addChunk (_stream_readable.js:298:12)
at readableAddChunk (_stream_readable.js:273:9)
at TLSSocket.Readable.push (_stream_readable.js:214:10)
at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23) {
ok: 0,
code: 10334,
codeName: 'BSONObjectTooLarge'
}
Then the above error stopped and I got anther instead:
MongoError: Resulting document after update is larger than 16777216
at MessageStream.messageHandler (/home/user/projects/web-app/node_modules/mongoose/node_modules/mongodb/lib/cmap/connection.js:268:20)
at MessageStream.emit (events.js:314:20)
at processIncomingData (/home/user/projects/web-app/node_modules/mongoose/node_modules/mongodb/lib/cmap/message_stream.js:144:12)
at MessageStream._write (/home/user/projects/web-app/node_modules/mongoose/node_modules/mongodb/lib/cmap/message_stream.js:42:5)
at doWrite (_stream_writable.js:403:12)
at writeOrBuffer (_stream_writable.js:387:5)
at MessageStream.Writable.write (_stream_writable.js:318:11)
at TLSSocket.ondata (_stream_readable.js:719:22)
at TLSSocket.emit (events.js:314:20)
at addChunk (_stream_readable.js:298:12)
at readableAddChunk (_stream_readable.js:273:9)
at TLSSocket.Readable.push (_stream_readable.js:214:10)
at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23) {
ok: 0,
code: 17419,
codeName: 'Location17419'
}
Using MongoDB Compass I can see this:
Note the total size of 16.2MB, this is the only thing that I can think of that is even lose to 16MBs.
I would understand that if the error was trying to say that my data object was too large, but since it is so small (789 bytes) I don't understand why I'm getting the error or how to fix it. If the error is because the entire DB is larger than 16MBs then something must be wrong because obviously DBs should scale larger than 16MBs.
How can I prevent this error?
I took #Evert's advice and flattened my DB so that each file's metadata was it's own document instead of an array within a document. And now it works fine.
const fileMetadataDocument = new db.FileMetadata(data);
const saved = await fileMetadataDocument.save();
//Works

TypeError: Cannot read property 'send' of undefined .What should I do when I get such an error and want to keep the currents settings

An error started popping up for me when I added the "wiezienie.send ("test");" function.
My error is:
TypeError: Cannot read property 'send' of undefined
at Object.run (C:\Users\User\Desktop\ZukBot-master\src\commands\warn.command.js:63:19)
at Client.<anonymous> (C:\Users\User\Desktop\ZukBot-master\src\handlers\command.handler.js:126:11)
at Client.emit (events.js:327:22)
at MessageCreateAction.handle (C:\Users\User\Desktop\ZukBot-master\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\User\Desktop\ZukBot-master\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\User\Desktop\ZukBot-master\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31)
at WebSocketShard.onPacket (C:\Users\User\Desktop\ZukBot-master\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22)
at WebSocketShard.onMessage (C:\Users\User\Desktop\ZukBot-master\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)
at WebSocket.onMessage (C:\Users\User\Desktop\ZukBot-master\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:315:20)
My code is:
const {
Permissions: { FLAGS }, Message, Client,
} = require("discord.js")
const { MessageEmbed } = require("discord.js")
const client = new Client({ partials: ['MESSAGE', 'REACTION'] });
module.exports = {
name: "warn",
description: "Ostrzegasz kogoś",
args: true,
usage: "<użytkownik>",
botPermissions: [FLAGS.BAN_MEMBERS],
userPermissions: [FLAGS.BAN_MEMBERS],
run(msg, args, message) {
let wiezienie = client.channels.cache.get("761902640552083466")
msg.delete().catch(O_o=>{});
const { channel, guild, mentions, author } = msg
const userArg = args[0]
const reasonArg = [...args].slice(1).join(" ")
const userToKick = mentions.users.first()
if (!userToKick) {
msg.author.send(`⛔ Wystąpił problem szefie! \`Nie ma takiego gracza na serwerze!\``)
return
}
if (userToKick.id === author.id) {
msg.author.send(`⛔ Wystąpił problem szefie! \`Nie możesz otrzegać siebie byczku!\``)
return
}
const memberToKick = guild.members.cache.get(userToKick.id)
if (!memberToKick.kickable) {
msg.author.send(`⛔ Wystąpił problem szefie! \`Bot nie ma permisji do ostrzeżenia tego użytkownika!\``)
return
}
const wsukces = new MessageEmbed()
// Set the title of the field
.setTitle(`⛔ Więzienie`)
// Set the color of the embed
.setColor(0xec5454)
// Set the main content of the embed
.setDescription("Użytkownik został wtrącony do więzienia na godzinę. Nałożono ostrzeżenie")
memberToKick.roles.add("761901722305298432")
memberToKick.roles.remove("724576322952888422")
const ksukces = new MessageEmbed()
// Set the title of the field
.setTitle(`⛔ Zostałeś wtrącony do więzienia/ostrzeżony na serwerze \`among us gang\``)
// Set the color of the embed
.setColor(0xec5454)
// Set the main content of the embed
.setDescription("Zostałeś wtrącony do więzienia, czyli administrator nałożył na twoje konto ostrzeżenie. Posiadasz dostęp do jedynie najważniejszych informacji")
.addField("Okres:", "Patrząc na twoją aktywną liczbę ostrzeżenień, w więzieniu pozostaniesz jeszcze godzinę", true)
.setFooter("Zostałeś ostrzeżony!")
memberToKick.send(ksukces)
channel.send (wsukces)
wiezienie.send("test");
setTimeout(function(){
memberToKick.roles.add("724576322952888422")
memberToKick.roles.remove("761901722305298432")
memberToKick.send("Twoje ostrzeżenie zniknęło. Miej się na baczności!")
}, 3600000); //time in milliseconds
}
}
You are getting this error because you are trying to access the send property of an undefined variable wiezienie.
You should check this line:
let wiezienie = client.channels.cache.get("761902640552083466")
Most likely it's not returning what you expect it to.
I also got an error like this.
Try to change this line
let wiezienie = client.channels.cache.get("761902640552083466")
into
let wiezienie = client.channels.fetch("761902640552083466")

heroku node.js error

code So, I decided to make a discord points bot using heroku and node.js but I keep getting this error:
error: syntax error at or near "DUPLICATE"
I tried debugging but got no results so yeah... i need help.
what im sending to the sql postgresql database with javascript stuff:
'INSERT INTO points (Roblox_name, Points) VALUES (' + name + ', ' + amount + ') ON DUPLICATE KEY UPDATE Points=VALUES(' + amount + ')'
example{
amount = 322
and
name = george
}
EDIT:
raw application log [with VALUES(' + amount + ')' changed to ' + amount]:
2018-07-26T19:32:08.576609+00:00 app[worker.1]: Ready to serve on 1 servers,
for 6 users.
2018-07-26T19:32:42.536398+00:00 app[worker.1]: /app/bot.js:56
2018-07-26T19:32:42.536422+00:00 app[worker.1]: if (err) throw
err;
2018-07-26T19:32:42.536424+00:00 app[worker.1]: ^
2018-07-26T19:32:42.536425+00:00 app[worker.1]:
2018-07-26T19:32:42.536427+00:00 app[worker.1]: error: syntax error at or
near "DUPLICATE"
2018-07-26T19:32:42.536429+00:00 app[worker.1]: at Connection.parseE
(/app/node_modules/pg/lib/connection.js:553:11)
2018-07-26T19:32:42.536431+00:00 app[worker.1]: at
Connection.parseMessage (/app/node_modules/pg/lib/connection.js:378:19)
2018-07-26T19:32:42.536432+00:00 app[worker.1]: at TLSSocket.<anonymous>
(/app/node_modules/pg/lib/connection.js:119:22)
2018-07-26T19:32:42.536434+00:00 app[worker.1]: at emitOne
(events.js:116:13)
2018-07-26T19:32:42.536435+00:00 app[worker.1]: at TLSSocket.emit
(events.js:211:7)
2018-07-26T19:32:42.536437+00:00 app[worker.1]: at addChunk
(_stream_readable.js:263:12)
2018-07-26T19:32:42.536439+00:00 app[worker.1]: at readableAddChunk
(_stream_readable.js:250:11)
2018-07-26T19:32:42.536440+00:00 app[worker.1]: at
TLSSocket.Readable.push (_stream_readable.js:208:10)
2018-07-26T19:32:42.536442+00:00 app[worker.1]: at TLSWrap.onread
(net.js:597:20)
2018-07-26T19:32:42.629819+00:00 heroku[worker.1]: Process exited with
status 1
2018-07-26T19:32:42.738809+00:00 heroku[worker.1]: State changed from up to
crashed
EDIT new error log:
2018-07-27T12:24:05.106369+00:00 app[worker.1]: { error: syntax error at or
near
"DUPLICATE"
2018-07-27T12:24:05.106409+00:00 app[worker.1]: at Connection.parseE
(/app/node_modules/pg/lib/connection.js:553:11)
2018-07-27T12:24:05.106411+00:00 app[worker.1]: at
Connection.parseMessage
(/app/node_modules/pg/lib/connection.js:378:19)
2018-07-27T12:24:05.106412+00:00 app[worker.1]: at TLSSocket.<anonymous>
(/app/node_modules/pg/lib/connection.js:119:22)
2018-07-27T12:24:05.106413+00:00 app[worker.1]: at emitOne
(events.js:116:13)
2018-07-27T12:24:05.106414+00:00 app[worker.1]: at TLSSocket.emit
(events.js:211:7)
2018-07-27T12:24:05.106415+00:00 app[worker.1]: at addChunk
(_stream_readable.js:263:12)
2018-07-27T12:24:05.106417+00:00 app[worker.1]: at readableAddChunk
(_stream_readable.js:250:11)
2018-07-27T12:24:05.106418+00:00 app[worker.1]: at
TLSSocket.Readable.push
(_stream_readable.js:208:10)
2018-07-27T12:24:05.106419+00:00 app[worker.1]: at TLSWrap.onread
(net.js:597:20)
2018-07-27T12:24:05.106420+00:00 app[worker.1]: name: 'error',
2018-07-27T12:24:05.106422+00:00 app[worker.1]: length: 98,
2018-07-27T12:24:05.106423+00:00 app[worker.1]: severity: 'ERROR',
2018-07-27T12:24:05.106424+00:00 app[worker.1]: code: '42601',
2018-07-27T12:24:05.106425+00:00 app[worker.1]: detail: undefined,
2018-07-27T12:24:05.106426+00:00 app[worker.1]: hint: undefined,
2018-07-27T12:24:05.106427+00:00 app[worker.1]: position: '72',
2018-07-27T12:24:05.106428+00:00 app[worker.1]: internalPosition:
undefined,
2018-07-27T12:24:05.106429+00:00 app[worker.1]: internalQuery: undefined,
2018-07-27T12:24:05.106430+00:00 app[worker.1]: where: undefined,
2018-07-27T12:24:05.106431+00:00 app[worker.1]: schema: undefined,
2018-07-27T12:24:05.106433+00:00 app[worker.1]: table: undefined,
2018-07-27T12:24:05.106434+00:00 app[worker.1]: column: undefined,
2018-07-27T12:24:05.106435+00:00 app[worker.1]: dataType: undefined,
2018-07-27T12:24:05.106436+00:00 app[worker.1]: constraint: undefined,
2018-07-27T12:24:05.106437+00:00 app[worker.1]: file: 'scan.l',
2018-07-27T12:24:05.106438+00:00 app[worker.1]: line: '1087',
2018-07-27T12:24:05.106439+00:00 app[worker.1]: routine: 'scanner_yyerror'
}
You don't need to re-specify values in this part of the statement Points=Values(' + amount + ')'
It can instead just be Points = amount. Perhaps you'll need to CAST or CONVERT amount to an integer value, but that should be it.
if Roblox_name and Points is string then value must be set in 'values'
"INSERT INTO points (Roblox_name, Points) VALUES ('" + name + "','" + amount + "')
ON DUPLICATE KEY UPDATE Points=VALUES('" + amount + "')"
and you should use
if(err !== null){
console.error(err);
return;
}
instead of
if (err) throw err;

Sequelize TypeError: Cannot read property '1' of null

Normally this type of error would not be a problem but i simply cannot understand where this is happening:
Here is my setup:
router.route('/api/academyModule')
.post(function (req, res) {
req.body.academyModule.module_id = req.body.academyModule.module.id;
req.body.academyModule.module_module_type_id = req.body.academyModule.module.module_type.id;
var am = AcademyModule.build(req.body.academyModule);
am.add(req.body.academyModule.requirements, req.body.academyModule, function (success) {
res.json({id: this[null]});
},
function (err) {
res.status(err).send(err);
});
if(req.body.teams != null)
{
req.body.teams.forEach(function(y)
{
var atm = academy_team_has_academy_module.build({academy_team_id: y.id, academy_id: y.academy_id, academy_module_module_id: req.body.academyModule.module_id })
atm.add(function(success)
{
}, function(err)
{
res.status(err).send(err);
});
});
}
})
For this i have the following model:
academy_team_has_academy_module = sequelize.define('academy_team_has_academy_module', {
academy_team_id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: false
},
academy_id: DataTypes.INTEGER,
academy_module_module_id: DataTypes.INTEGER
}, {
freezeTableName: true,
instanceMethods: {
add: function (onSuccess, onError) {
academy_team_has_academy_module.build(this.dataValues)
.save().ok(onSuccess).error(onError);
}
}
});
i know for sure this happens in this model and not AcademyModule because when i remove this code it runs without any issues. So in my console i get the following print out:
Executing (default): INSERT INTO `requirements` (`id`,`value`,`requirement_type_id`) VALUES (DEFAULT,5,'2');
Executing (default): INSERT INTO `academy_team_has_academy_module` (`academy_team_id`,`academy_id`,`academy_module_module_id`) VALUES (1,3,11);
Executing (default): INSERT INTO `academy_module` (`academy_id`,`module_id`,`module_module_type_id`,`sort_number`,`requirements_id`) VALUES ('3',11,4,4,40);
And just right after i get:
/var/www/learningbankapi/src/node_modules/mysql/lib/protocol/Parser.js:82
throw err;
^
TypeError: Cannot read property '1' of null
at module.exports.Query.formatError (/var/www/learningbankapi/src/node_modules/sequelize/lib/dialects/mysql/query.js:155:23)
at Query.module.exports.Query.run [as _callback] (/var/www/learningbankapi/src/node_modules/sequelize/lib/dialects/mysql/query.js:38:23)
at Query.Sequence.end (/var/www/learningbankapi/src/node_modules/mysql/lib/protocol/sequences/Sequence.js:96:24)
at Query.ErrorPacket (/var/www/learningbankapi/src/node_modules/mysql/lib/protocol/sequences/Query.js:93:8)
at Protocol._parsePacket (/var/www/learningbankapi/src/node_modules/mysql/lib/protocol/Protocol.js:271:23)
at Parser.write (/var/www/learningbankapi/src/node_modules/mysql/lib/protocol/Parser.js:77:12)
at Protocol.write (/var/www/learningbankapi/src/node_modules/mysql/lib/protocol/Protocol.js:39:16)
at Socket.Connection.connect (/var/www/learningbankapi/src/node_modules/mysql/lib/Connection.js:82:28)
at Socket.EventEmitter.emit (events.js:95:17)
at Socket.stream.pause.paused (_stream_readable.js:746:14)
at Socket.EventEmitter.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:408:10)
at emitReadable (_stream_readable.js:404:5)
at readableAddChunk (_stream_readable.js:165:9)
at Socket.Readable.push (_stream_readable.js:127:10)
at TCP.onread (net.js:526:21)
Ive debugged the whole thing and i can't seem to find any undefined variables. What might have gone wrong here?
Your problem is a ForeignKeyContraintError. Sequelize is trying to throw a new error but get's an unexpected error.message. If your configuration is fine, this may be an bug of sequelize.
Maybe deactivating foreign contraint checks (if possible) will solve your problem.
See: https://github.com/sequelize/sequelize/blob/master/lib/dialects/mysql/query.js#L153

Categories