-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from mimotej/add-db
feat: Add mongodb as a default database for application
- Loading branch information
Showing
13 changed files
with
494 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* Listenes for kick or ban actions and adds either a removed or ban value to user status if user is verified | ||
* also check for ban remove and adds removed value to user status so that user can be verified again | ||
*/ | ||
|
||
import { Client, GuildBan } from 'discord.js'; | ||
import { prisma } from '../model'; | ||
|
||
export default (client: Client) => { | ||
client.on('guildBanAdd', async (guildBan: GuildBan) => { | ||
const user = await prisma.users.findFirst({ | ||
where: { | ||
discordId: guildBan.user.id, | ||
}, | ||
}); | ||
if (user) { | ||
await prisma.users.update({ | ||
where: { | ||
id: user.id, | ||
}, | ||
data: { | ||
status: 'banned', | ||
}, | ||
}); | ||
} | ||
}); | ||
client.on('guildBanRemove', async (guildBan: GuildBan) => { | ||
const user = await prisma.users.findFirst({ | ||
where: { | ||
discordId: guildBan.user.id, | ||
}, | ||
}); | ||
if (user) { | ||
await prisma.users.update({ | ||
where: { | ||
id: user.id, | ||
}, | ||
data: { | ||
status: 'removed', | ||
}, | ||
}); | ||
} | ||
}); | ||
|
||
client.on('guildMemberRemove', async (member) => { | ||
const user = await prisma.users.findFirst({ | ||
where: { | ||
discordId: member.id, | ||
}, | ||
}); | ||
if (user && user.status !== 'banned') { | ||
await prisma.users.update({ | ||
where: { | ||
id: user.id, | ||
}, | ||
data: { | ||
status: 'removed', | ||
}, | ||
}); | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
/** | ||
* Listeners which are called when event happens | ||
*/ | ||
export { default as actionListener } from './actionListener'; | ||
export { default as interactionListener } from './interactionListener'; | ||
export { default as channelListener } from './channelListener'; | ||
export { default as pinVoteListener } from './pinVoteListener'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './prisma'; |
Oops, something went wrong.