docs(database): add JSDoc for ban functions

This commit is contained in:
Anthony Berg 2023-07-27 12:07:15 +01:00
parent d42cc6be0b
commit 29df8bf2c4

View File

@ -1,5 +1,11 @@
import { container } from '@sapphire/framework';
/**
* Add an entry to the database to log a ban for a user
* @param {string} userId Snowflake for the User to ban
* @param {string} modId Snowflake for the Moderator who is banning the user
* @param {string} reason Reason for banning the user
*/
export async function addBan(userId: string, modId: string, reason: string) {
// Add the user to the database
await container.database.ban.create({
@ -19,6 +25,11 @@ export async function addBan(userId: string, modId: string, reason: string) {
});
}
/**
* Deactivates the ban on the database for the user
* @param {string} userId Snowflake for the User to unban
* @param {string} modId Snowflake for the Moderator who is unbanning the user
*/
export async function removeBan(userId: string, modId: string) {
const ban = await container.database.ban.findFirst({
where: {
@ -46,6 +57,11 @@ export async function removeBan(userId: string, modId: string) {
});
}
/**
* Check if the user is banned on the database
* @param userId Snowflake of the User to check the ban on
* @return {boolean} If the ban is active on the database
*/
export async function checkBan(userId: string) {
const ban = await container.database.ban.findFirst({
where: {
@ -63,6 +79,11 @@ export async function checkBan(userId: string) {
return ban.active;
}
/**
* Get the ban reason for a user from the database
* @param {string} userId Snowflake for the User
* @return {string} User's reason for being banned
*/
export async function getBanReason(userId: string) {
const ban = await container.database.ban.findFirst({
where: {