I wanted to work on reading embeds with my eris bot in Javascript
Well it dosnt realy work as expected
If someone knows how to make it work please tell me
if it dosnt work please tell me i worked kinda a long time on it and i think it would be sad to just throw it away
here are the logs
Received message: <@1204873782519398520> test from toxiclikeme1599 (ID: 1015941241533366366) in channel 1325089634946125868
Received message: .dep 1015941241533366366 1000 from EHFB | Finance Bank Bot (ID: 1204873782519398520) in channel 1325089634946125868
Detected .dep command
User mention: 1015941241533366366, Amount: 1000
Waiting for .pay message…
Received message: .pay <@1325065822636609578> 1000 from toxiclikeme1599 (ID: 1015941241533366366) in channel 1197500600791863346
Filter check – Channel: true, Command: true, Mention: false
Received message: from UnbelievaBoat (ID: 292953664492929025) in channel 1197500600791863346
Filter check – Channel: true, Command: false, Mention: false
bot.on('messageCreate', async (msg) => {
console.log(
`Received message: ${msg.content} from ${msg.author.username} (ID: ${msg.author.id}) in channel ${msg.channel.id}`
);
if (
msg.channel.id === BOT_CHANNEL_ID &&
msg.content.startsWith('.dep ') &&
msg.author.id === '1204873782519398520'
) {
console.log('Detected .dep command');
const args = msg.content.split(' ');
if (args.length !== 3 || isNaN(args[2])) {
bot.createMessage(msg.channel.id, 'Invalid command format. Usage: `.dep <@user> <amount>`');
return;
}
const userMention = args[1];
const userID = userMention.replace(/[<@!>]/g, ''); // Extract user ID from mention
const amount = args[2];
console.log(`User mention: ${userMention}, Amount: ${amount}`);
const filterPay = (m) => {
const isCorrectChannel = m.channel.id === PAY_CHANNEL_ID;
const isPayCommand = m.content.startsWith('.pay');
const includesUserMention =
m.content.includes(`<@${userID}>`) || m.content.includes(`<@!${userID}>`);
console.log(
`Filter check - Channel: ${isCorrectChannel}, Command: ${isPayCommand}, Mention: ${includesUserMention}`
);
return isCorrectChannel && isPayCommand && includesUserMention;
};
console.log('Waiting for .pay message...');
const payMessage = await waitForMessage(filterPay, 600000);
if (!payMessage) {
bot.createMessage(msg.channel.id, 'No `.pay` message received within the time limit.');
return;
}
console.log('Received .pay message:', payMessage.content);
const filterResponse = (m) => {
const hasEmbed = m.embeds && m.embeds.length > 0;
if (!hasEmbed) return false;
const embed = m.embeds[0];
const descriptionMatches =
embed.description.includes(`<@${userID}>`) || embed.description.includes(`<@!${userID}>`);
const authorMatches = embed.author && embed.author.name === payMessage.author.username;
console.log(
`Response filter check - Has Embed: ${hasEmbed}, Description Matches: ${descriptionMatches}, Author Matches: ${authorMatches}`
);
return descriptionMatches && authorMatches;
};
console.log('Waiting for response embed from UnbelievaBoat...');
const responseMessage = await waitForMessage(filterResponse, 600000);
if (!responseMessage) {
bot.createMessage(msg.channel.id, 'No response embed received within the time limit.');
return;
}
console.log('Received response embed:', responseMessage.embeds[0].description);
}
});
async function waitForMessage(filter, time) {
return new Promise((resolve) => {
const timeout = setTimeout(() => resolve(null), time);
const listener = (message) => {
if (filter(message)) {
clearTimeout(timeout);
bot.off('messageCreate', listener);
resolve(message);
}
};
bot.on('messageCreate', listener);
});
}```