Skip to content

Commit fa4394f

Browse files
committed
Bug fixes. Fixes #164 and #167
1 parent ba6590a commit fa4394f

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

src/discordHandler.js

+5
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,15 @@ client.on('messageCreate', async (message) => {
310310
});
311311

312312
client.on('messageUpdate', async (_, message) => {
313+
if (message.webhookId != null) {
314+
return;
315+
}
316+
313317
const jid = utils.discord.channelIdToJid(message.channelId);
314318
if (jid == null) {
315319
return;
316320
}
321+
317322
const messageId = state.lastMessages[message.id];
318323
if (messageId == null) {
319324
await message.channel.send("Couldn't edit the message. You can only edit the last 500 messages.");

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const storage = require('./storage.js');
77
const whatsappHandler = require('./whatsappHandler.js');
88

99
(async () => {
10-
const version = 'v0.10.18';
10+
const version = 'v0.10.19';
1111
state.logger = pino({ mixin() { return { version }; } }, pino.destination('logs.txt'));
1212
let autoSaver = setInterval(() => storage.save(), 5 * 60 * 1000);
1313
['SIGINT', 'uncaughtException', 'SIGTERM'].forEach((eventName) => process.on(eventName, async (err) => {

src/utils.js

+8
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,14 @@ const whatsapp = {
573573
message: { conversation: refMessage.content },
574574
};
575575
},
576+
577+
async deleteSession() {
578+
const dir = './storage/baileys';
579+
const files = await fs.promises.readdir(dir);
580+
for (let file of files) {
581+
fs.unlinkSync(path.join(dir, file));
582+
}
583+
}
576584
};
577585

578586
const requests = {

src/whatsappHandler.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const connectToWhatsApp = async (retry = 1) => {
4040
await connectToWhatsApp(retry + 1);
4141
} else {
4242
await controlChannel.send('Connection failed 5 times. Please rescan the QR code.');
43+
await utils.whatsapp.deleteSession();
4344
await actions.start(true);
4445
}
4546
} else if (connection === 'open') {
@@ -185,7 +186,7 @@ const connectToWhatsApp = async (retry = 1) => {
185186
text: message.content,
186187
edit: key,
187188
}
188-
).then(console.log)
189+
)
189190
});
190191

191192
client.ev.on('discordReaction', async ({ jid, reaction, removed }) => {

0 commit comments

Comments
 (0)