SEBAS
SEBAS
Explore posts from servers
DTDrizzle Team
Created by SEBAS on 3/17/2025 in #help
TypeError: Cannot read properties of undefined
I eventually used the sql template to use the insert and it worked as expected:
async insertELOEntities(entities){
try{
const sqlClient = neon(process.env.DATABASE_URL_TEST);
const db = drizzle({ client: sqlClient });
const eloEntities = entities.map(entity => ({
entity_cagematch_id: entity.id,
type_id: getEntityTypeByDescription(entity.type).id,
entity_name: entity.name,
elo_date: entity.lastMatchDate,
elo_prev_elo: entity.oldElo,
elo_new_elo: entity.newELO
}));
const sqlChunk = [];
sqlChunk.push(sql`INSERT INTO ${vEntityEloView} `);
sqlChunk.push( sql`(entity_cagematch_id,type_id,entity_name,elo_date,elo_prev_elo,elo_new_elo) values `);
for(let i = 0; i < eloEntities.length; i++){
const entity = eloEntities[i];
sqlChunk.push(sql`(${entity.entity_cagematch_id},${entity.type_id},${entity.entity_name},${entity.elo_date},${entity.elo_prev_elo},${entity.elo_new_elo})`);
if(i < eloEntities.length - 1){
sqlChunk.push(sql`,`);
}
}
const response = await db.execute(sql.join(sqlChunk));
if(response.rowCount > 0){
return response.rowCount;
}
return response;
} catch(e){
logger.error({message: e.message, stack: e.stack});
}
return null;
}
async insertELOEntities(entities){
try{
const sqlClient = neon(process.env.DATABASE_URL_TEST);
const db = drizzle({ client: sqlClient });
const eloEntities = entities.map(entity => ({
entity_cagematch_id: entity.id,
type_id: getEntityTypeByDescription(entity.type).id,
entity_name: entity.name,
elo_date: entity.lastMatchDate,
elo_prev_elo: entity.oldElo,
elo_new_elo: entity.newELO
}));
const sqlChunk = [];
sqlChunk.push(sql`INSERT INTO ${vEntityEloView} `);
sqlChunk.push( sql`(entity_cagematch_id,type_id,entity_name,elo_date,elo_prev_elo,elo_new_elo) values `);
for(let i = 0; i < eloEntities.length; i++){
const entity = eloEntities[i];
sqlChunk.push(sql`(${entity.entity_cagematch_id},${entity.type_id},${entity.entity_name},${entity.elo_date},${entity.elo_prev_elo},${entity.elo_new_elo})`);
if(i < eloEntities.length - 1){
sqlChunk.push(sql`,`);
}
}
const response = await db.execute(sql.join(sqlChunk));
if(response.rowCount > 0){
return response.rowCount;
}
return response;
} catch(e){
logger.error({message: e.message, stack: e.stack});
}
return null;
}
9 replies
DTDrizzle Team
Created by SEBAS on 3/17/2025 in #help
TypeError: Cannot read properties of undefined
It worked for the select, but for some reason it doesn't work when I try to insert it
9 replies
DTDrizzle Team
Created by SEBAS on 3/17/2025 in #help
TypeError: Cannot read properties of undefined
Sorry, didn't show all the file, yeah I exported the view:
const { pgView, integer, text, date, boolean, timestamp } = require('drizzle-orm/pg-core');

const vEntityEloView = pgView('v_entity_elo', {
elo_id: integer('elo_id'),
entity_id: integer('entity_id'),
name_id: integer('name_id'),
entity_name: text('entity_name'),
entity_cagematch_id: integer('entity_cagematch_id'),
entity_type: text('entity_type'),
type_id: integer('type_id'),
elo_prev_elo: integer('elo_prev_elo'),
elo_new_elo: integer('elo_new_elo'),
elo_difference: integer('elo_difference'),
elo_date: date('elo_date'),
elo_current: boolean('elo_current'),
elo_created_date: timestamp('elo_created_date'),
elo_edited_date: timestamp('elo_edited_date')
}).existing();

module.exports = vEntityEloView;
const { pgView, integer, text, date, boolean, timestamp } = require('drizzle-orm/pg-core');

const vEntityEloView = pgView('v_entity_elo', {
elo_id: integer('elo_id'),
entity_id: integer('entity_id'),
name_id: integer('name_id'),
entity_name: text('entity_name'),
entity_cagematch_id: integer('entity_cagematch_id'),
entity_type: text('entity_type'),
type_id: integer('type_id'),
elo_prev_elo: integer('elo_prev_elo'),
elo_new_elo: integer('elo_new_elo'),
elo_difference: integer('elo_difference'),
elo_date: date('elo_date'),
elo_current: boolean('elo_current'),
elo_created_date: timestamp('elo_created_date'),
elo_edited_date: timestamp('elo_edited_date')
}).existing();

module.exports = vEntityEloView;
9 replies
DTDrizzle Team
Created by SEBAS on 3/17/2025 in #help
TypeError: Cannot read properties of undefined
Another thing to note, is that the view has an insert trigger, which was also tested with those same parameters
9 replies
DTDrizzle Team
Created by SEBAS on 3/17/2025 in #help
TypeError: Cannot read properties of undefined
The strange part is that none of the parameters are null, because I previously successfully inserted them to the original table
9 replies
DTDrizzle Team
Created by SEBAS on 3/17/2025 in #help
TypeError: Cannot read properties of undefined
And this is the schema for the view:
const vEntityEloView = pgView('v_entity_elo', {
elo_id: integer('elo_id'),
entity_id: integer('entity_id'),
name_id: integer('name_id'),
entity_name: text('entity_name'),
entity_cagematch_id: integer('entity_cagematch_id'),
entity_type: text('entity_type'),
type_id: integer('type_id'),
elo_prev_elo: integer('elo_prev_elo'),
elo_new_elo: integer('elo_new_elo'),
elo_difference: integer('elo_difference'),
elo_date: date('elo_date'),
elo_current: boolean('elo_current'),
elo_created_date: timestamp('elo_created_date'),
elo_edited_date: timestamp('elo_edited_date')
}).existing();
const vEntityEloView = pgView('v_entity_elo', {
elo_id: integer('elo_id'),
entity_id: integer('entity_id'),
name_id: integer('name_id'),
entity_name: text('entity_name'),
entity_cagematch_id: integer('entity_cagematch_id'),
entity_type: text('entity_type'),
type_id: integer('type_id'),
elo_prev_elo: integer('elo_prev_elo'),
elo_new_elo: integer('elo_new_elo'),
elo_difference: integer('elo_difference'),
elo_date: date('elo_date'),
elo_current: boolean('elo_current'),
elo_created_date: timestamp('elo_created_date'),
elo_edited_date: timestamp('elo_edited_date')
}).existing();
9 replies
DIAdiscord.js - Imagine an app
Created by SEBAS on 1/23/2025 in #djs-questions
Message Component Collector is not collecting after String Select Menu Interaction
Quick Update: I resolved the issue by passing the withResponse parameter to the replied message, and it works now! If anyone else is facing the same problem, here’s an example of the implementation:
const response = await interaction.reply({ content: confirmationMessage, withResponse: true })
const message = response.resource.message;
const collectorButton = message.createMessageComponentCollector({ filter:messageFilter,componentType: ComponentType.Button, time: TIME_LIMIT_CONFIRMATION });
const response = await interaction.reply({ content: confirmationMessage, withResponse: true })
const message = response.resource.message;
const collectorButton = message.createMessageComponentCollector({ filter:messageFilter,componentType: ComponentType.Button, time: TIME_LIMIT_CONFIRMATION });
I’m marking this as solved, but I still find it confusing that, without this workaround, the collector only worked with the Command Interaction and not the String Select Menu Interaction. If anyone could verify whether this is the intended behavior, it would be greatly appreciated!
4 replies
DIAdiscord.js - Imagine an app
Created by SEBAS on 1/23/2025 in #djs-questions
Message Component Collector is not collecting after String Select Menu Interaction
Here are the files. As a note, the replyInteraction is a wrapper that in both cases execute the interaction.reply(message) function for the interaction passed as a parameter
4 replies
DIAdiscord.js - Imagine an app
Created by SEBAS on 12/1/2023 in #djs-questions
Workaround Invalid Webhook Token Error
Thank you, just tested and it works!
14 replies
DIAdiscord.js - Imagine an app
Created by SEBAS on 12/1/2023 in #djs-questions
Workaround Invalid Webhook Token Error
Do you recommend me to change it to update the last collected interaction?
14 replies
DIAdiscord.js - Imagine an app
Created by SEBAS on 12/1/2023 in #djs-questions
Workaround Invalid Webhook Token Error
You're right, the error happens after I call an editReply, which I call after the collector ends
14 replies
DIAdiscord.js - Imagine an app
Created by SEBAS on 12/1/2023 in #djs-questions
Workaround Invalid Webhook Token Error
Sorry, had to replicate it again because I had the error stack turned off
14 replies
DIAdiscord.js - Imagine an app
Created by SEBAS on 12/1/2023 in #djs-questions
Workaround Invalid Webhook Token Error
I call the update on every buttonInteraction I collect
14 replies
DIAdiscord.js - Imagine an app
Created by SEBAS on 12/1/2023 in #djs-questions
Workaround Invalid Webhook Token Error
This is the error message I received: Invalid Webhook Token { "requestBody": { "files": [], "json": { "content": "Fall Ended", "tts": false, "embeds": [ { "color": 39423, "title": "Singles 2/3 Falls Match", "fields": [ { "name": "🟢 SEBAS ", "value": "Health: 9%", "inline": true }, { "name": "🔴 vamtibu", "value": "Health: 0%", "inline": true }, { "name": "Match Actions", "value": "🤼 SEBAS launched an incredible dropkick to vamtibu, resulting in 19% damage.\n💀 vamtibu WAS ELIMINATED BY SEBAS\n🛎️ And the winner of this fall is...\nSEBAS!!! 🎉🎉\nThe scores are:\nSEBAS: 1 fall\nvamtibu: 0 falls" } ] } ], "components": [ { "type": 1, "components": [ { "type": 2, "custom_id": "nextFall", "label": "👍 Next Fall? 0/2", "style": 1 }, { "type": 2, "custom_id": "leave", "label": "🏃 Leave", "style": 4 } ] } ] } }, "rawError": { "message": "Invalid Webhook Token", "code": 50027 }, "code": 50027, "status": 401, "method": "PATCH", "url": "https://discord.com/api/v10/webhooks/1164768291542269983/aW50ZXJhY3Rpb246MTE4MDE4NjY0NzEyODcxMTE4ODphVzU5dkZIYzBNSjJDaU5aWExIRTN2dzBWVmZJS2htMkUycEcwUlJQYXdkaFViQmJuVE5DanJ4Q0N4SlR2N3BERHZ1SzJTaHRua1VlRlNFRDdrSGlTTm5pMUNyaW16dUZiaXByelRvVmVRZlBYN294QjVDUEVuMFlhMVhZempjcA/messages/@original" }
14 replies
DIAdiscord.js - Imagine an app
Created by SEBAS on 12/1/2023 in #djs-questions
Workaround Invalid Webhook Token Error
I tested it using update instead of editReply, it seems that it still expires the token
14 replies
DIAdiscord.js - Imagine an app
Created by SEBAS on 12/1/2023 in #djs-questions
Workaround Invalid Webhook Token Error
Thanks
14 replies
DIAdiscord.js - Imagine an app
Created by SEBAS on 12/1/2023 in #djs-questions
Workaround Invalid Webhook Token Error
Ok, I'm going to try it
14 replies
DIAdiscord.js - Imagine an app
Created by SEBAS on 12/1/2023 in #djs-questions
Workaround Invalid Webhook Token Error
When one of those interaction is collected, it triggers a event that, by using a queue system, defers the interaction and edit the original message
14 replies
DIAdiscord.js - Imagine an app
Created by SEBAS on 12/1/2023 in #djs-questions
Workaround Invalid Webhook Token Error
They interact with button/select menu interaction, every valid interaction is collected
14 replies