refactor(arabot): change types to Snowflake

This commit is contained in:
smyalygames 2023-02-20 12:30:37 +00:00
parent 23b4250e0a
commit 1533fdeeb5

View File

@ -17,13 +17,13 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import type { GuildMember } from 'discord.js'; import type { GuildMember, Snowflake } from 'discord.js';
import { container } from '@sapphire/framework'; import { container } from '@sapphire/framework';
import { updateUser } from '#utils/database/dbExistingUser'; import { updateUser } from '#utils/database/dbExistingUser';
import { leaveBan } from '#utils/verificationConfig'; import { leaveBan } from '#utils/verificationConfig';
import { fibonacci } from '#utils/maths'; import { fibonacci } from '#utils/maths';
export async function joinVerification(channelId: string, user: GuildMember) { export async function joinVerification(channelId: Snowflake, user: GuildMember) {
// Update the user on the database with the current roles they have // Update the user on the database with the current roles they have
await updateUser(user); await updateUser(user);
@ -39,7 +39,7 @@ export async function joinVerification(channelId: string, user: GuildMember) {
}); });
} }
export async function startVerification(channelId: string) { export async function startVerification(channelId: Snowflake) {
await container.database.verify.update({ await container.database.verify.update({
where: { where: {
id: channelId, id: channelId,
@ -50,7 +50,7 @@ export async function startVerification(channelId: string) {
}); });
} }
export async function getUser(channelId: string) { export async function getUser(channelId: Snowflake) {
// Get the snowflake of the user verifying // Get the snowflake of the user verifying
const user = await container.database.verify.findUnique({ const user = await container.database.verify.findUnique({
where: { where: {
@ -71,8 +71,8 @@ export async function getUser(channelId: string) {
} }
export async function finishVerification( export async function finishVerification(
channelId: string, channelId: Snowflake,
verifierId: string, verifierId: Snowflake,
info: { info: {
page: number, page: number,
find: { find: {
@ -121,7 +121,7 @@ export async function finishVerification(
} }
// Checks if verification was complete // Checks if verification was complete
export async function checkFinish(channelId: string) { export async function checkFinish(channelId: Snowflake) {
// Get the snowflake of the user verifying // Get the snowflake of the user verifying
const finish = await container.database.verify.findUnique({ const finish = await container.database.verify.findUnique({
where: { where: {
@ -142,7 +142,7 @@ export async function checkFinish(channelId: string) {
} }
// Counts how many times the user has not had a verifier join their VC before leaving // Counts how many times the user has not had a verifier join their VC before leaving
export async function countIncomplete(userId: string) { export async function countIncomplete(userId: Snowflake) {
// Count how many times the user has not completed a verification // Count how many times the user has not completed a verification
const incompleteCount = await container.database.verify.count({ const incompleteCount = await container.database.verify.count({
where: { where: {
@ -155,7 +155,7 @@ export async function countIncomplete(userId: string) {
} }
// Gets the amount of time left on the block // Gets the amount of time left on the block
export async function blockTime(userId: string) { export async function blockTime(userId: Snowflake) {
// Count how many times the user has not completed a verification // Count how many times the user has not completed a verification
const verification = await container.database.verify.findFirst({ const verification = await container.database.verify.findFirst({
where: { where: {