mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-11-03 15:49:50 +01:00
refactor(utils): move fibonacci and randint to one file
This commit is contained in:
parent
4d75f72989
commit
dda77483eb
@ -37,7 +37,6 @@ import type {
|
|||||||
Snowflake,
|
Snowflake,
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import IDs from '#utils/ids';
|
import IDs from '#utils/ids';
|
||||||
import { randint } from '#utils/random';
|
|
||||||
import {
|
import {
|
||||||
addEmptyUser,
|
addEmptyUser,
|
||||||
updateUser,
|
updateUser,
|
||||||
@ -45,6 +44,7 @@ import {
|
|||||||
fetchRoles,
|
fetchRoles,
|
||||||
} from '#utils/database/dbExistingUser';
|
} from '#utils/database/dbExistingUser';
|
||||||
import { restrict, checkActive } from '#utils/database/restriction';
|
import { restrict, checkActive } from '#utils/database/restriction';
|
||||||
|
import { randint } from '#utils/maths';
|
||||||
|
|
||||||
export async function restrictRun(
|
export async function restrictRun(
|
||||||
userId: Snowflake,
|
userId: Snowflake,
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import { time, ChannelType, PermissionsBitField } from 'discord.js';
|
|||||||
import { maxVCs, leaveBan } from '#utils/verificationConfig';
|
import { maxVCs, leaveBan } from '#utils/verificationConfig';
|
||||||
import { getUser, checkFinish, countIncomplete } from '#utils/database/verification';
|
import { getUser, checkFinish, countIncomplete } from '#utils/database/verification';
|
||||||
import { fetchRoles } from '#utils/database/dbExistingUser';
|
import { fetchRoles } from '#utils/database/dbExistingUser';
|
||||||
import { fibonacci } from '#utils/mathsSeries';
|
import { fibonacci } from '#utils/maths';
|
||||||
import IDs from '#utils/ids';
|
import IDs from '#utils/ids';
|
||||||
|
|
||||||
export class VerificationLeaveVCListener extends Listener {
|
export class VerificationLeaveVCListener extends Listener {
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import type { GuildMember } 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/mathsSeries';
|
import { fibonacci } from '#utils/maths';
|
||||||
|
|
||||||
export async function joinVerification(channelId: string, user: GuildMember) {
|
export async function joinVerification(channelId: string, 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
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
/*
|
/*
|
||||||
Animal Rights Advocates Discord Bot
|
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
|
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
|
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
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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
|
// Created because Stove loves Fibonacci sequences
|
||||||
// A fibonacci sequence where n = 0 => 1
|
// A fibonacci sequence where n = 0 => 1
|
||||||
@ -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;
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user