forked from ChrisChrome/weather-bot
Reviewed-on: ChrisChrome/weather-bot#7
This commit is contained in:
commit
24a1b2acec
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -133,3 +133,4 @@ channels.db
|
|||
private/
|
||||
error/
|
||||
old/
|
||||
package-lock.json
|
|
@ -26,7 +26,6 @@
|
|||
"username": "YOUR_USERNAME",
|
||||
"password": "YOUR_PASSWORD"
|
||||
},
|
||||
,
|
||||
"uptime-kuma": {
|
||||
"enabled": false,
|
||||
"url": "",
|
||||
|
|
19
index.js
19
index.js
|
@ -763,6 +763,25 @@ discord.on('ready', async () => {
|
|||
process.exit(1);
|
||||
}
|
||||
}, 10000)
|
||||
|
||||
// Check all channels in DB, fetch them, if they dont exist, delete all subscriptions
|
||||
db.all(`SELECT channelid FROM channels`, (err, rows) => {
|
||||
if (err) {
|
||||
console.error(err.message);
|
||||
}
|
||||
rows.forEach((row) => {
|
||||
const channel = discord.channels.cache.get(row.channelid);
|
||||
if (!channel) {
|
||||
// Delete the channel from the database and return
|
||||
return db.run(`DELETE FROM channels WHERE channelid = ?`, [row.channelid], (err) => {
|
||||
if (err) {
|
||||
console.error(err.message);
|
||||
}
|
||||
console.log(`${colors.cyan("[INFO]")} Deleted channel ${row.channelid} from database`);
|
||||
});
|
||||
};
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
discord.on("interactionCreate", async (interaction) => {
|
||||
|
|
8169
package-lock.json
generated
8169
package-lock.json
generated
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue