Skip to content

Commit

Permalink
Merge pull request #69 from net-tech/feat/about-memory-usage-and-chores
Browse files Browse the repository at this point in the history
  • Loading branch information
net-tech authored Jan 20, 2024
2 parents 5666cf8 + f4daef0 commit 0819e49
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Version 2.1.0
- Bump dependencies
- Show guild count and memory usage in /about
- Delete guilds from database when the bot leaves them

## Version 2.0.1
- Fetch guilds which can be pruned from the database and loop over them, instead of fetching all guilds the client is in and then fetching the settings of each guild from the database.
- Add `select` to database functions.
Expand Down
17 changes: 17 additions & 0 deletions src/events/guildDelete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Events } from "discord.js"
import { logger } from "../util/logger.js"
import type { Event } from "./index.js"
import { prisma } from "../util/database.ts";

export default {
name: Events.GuildDelete,
once: true,
async execute(guild) {
logger.info(`Left guild ${guild.name} (${guild.id})`)
prisma.guild.delete({
where: {
id: guild.id
}
})
}
} satisfies Event<"guildDelete">
7 changes: 1 addition & 6 deletions src/jobs/prune.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,8 @@ const pruneJob = async (client: Client) => {
const clientGuild = await client.guilds.fetch(guildSetting.id)
if (!clientGuild) {
logger.warn(
`Skipping prune for guild ${guildSetting.id} because I am not in it and deleting it from the database.`
`Skipping prune for guild ${guildSetting.id} because I am not in it.`
)
await prisma.guild.delete({
where: {
id: guildSetting.id
}
})
continue
}

Expand Down

0 comments on commit 0819e49

Please sign in to comment.