refactor(utils): move fibonacci and randint to one file

This commit is contained in:
smyalygames 2023-02-17 02:53:30 +00:00
parent 4d75f72989
commit dda77483eb
5 changed files with 13 additions and 27 deletions

View File

@ -37,7 +37,6 @@ import type {
Snowflake,
} from 'discord.js';
import IDs from '#utils/ids';
import { randint } from '#utils/random';
import {
addEmptyUser,
updateUser,
@ -45,6 +44,7 @@ import {
fetchRoles,
} from '#utils/database/dbExistingUser';
import { restrict, checkActive } from '#utils/database/restriction';
import { randint } from '#utils/maths';
export async function restrictRun(
userId: Snowflake,

View File

@ -25,7 +25,7 @@ import { time, ChannelType, PermissionsBitField } from 'discord.js';
import { maxVCs, leaveBan } from '#utils/verificationConfig';
import { getUser, checkFinish, countIncomplete } from '#utils/database/verification';
import { fetchRoles } from '#utils/database/dbExistingUser';
import { fibonacci } from '#utils/mathsSeries';
import { fibonacci } from '#utils/maths';
import IDs from '#utils/ids';
export class VerificationLeaveVCListener extends Listener {

View File

@ -21,7 +21,7 @@ import type { GuildMember } from 'discord.js';
import { container } from '@sapphire/framework';
import { updateUser } from '#utils/database/dbExistingUser';
import { leaveBan } from '#utils/verificationConfig';
import { fibonacci } from '#utils/mathsSeries';
import { fibonacci } from '#utils/maths';
export async function joinVerification(channelId: string, user: GuildMember) {
// Update the user on the database with the current roles they have

View File

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
/*
Animal Rights Advocates Discord Bot
Copyright (C) 2022 Anthony Berg
Copyright (C) 2023 Anthony Berg
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -16,6 +16,15 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* Creates a (PRNG) random integer between minimum and maximum both inclusive
* @param min minimum integer
* @param max maximum integer
* @returns number a random integer between min and max
*/
export function randint(min: number, max: number) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// Created because Stove loves Fibonacci sequences
// A fibonacci sequence where n = 0 => 1

View File

@ -1,23 +0,0 @@
// SPDX-License-Identifier: GPL-3.0-or-later
/*
Animal Rights Advocates Discord Bot
Copyright (C) 2023 Anthony Berg
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// Random integer between min and max
export function randint(min: number, max: number) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}