refactor(db): move db functions to separate folders to aid distinguishing functions

This commit is contained in:
Anthony Berg 2024-08-07 00:48:40 +02:00
parent 325dc0d0d0
commit a09b007831
41 changed files with 39 additions and 39 deletions

View File

@ -20,7 +20,7 @@
import { Command, RegisterBehavior } from '@sapphire/framework'; import { Command, RegisterBehavior } from '@sapphire/framework';
import type { User, Guild, Message } from 'discord.js'; import type { User, Guild, Message } from 'discord.js';
import { updateUser } from '#utils/database/dbExistingUser'; import { updateUser } from '#utils/database/dbExistingUser';
import { getBalance } from '#utils/database/economy'; import { getBalance } from '#utils/database/fun/economy';
import { EmbedBuilder } from 'discord.js'; import { EmbedBuilder } from 'discord.js';
export class BalanceCommand extends Command { export class BalanceCommand extends Command {

View File

@ -21,7 +21,7 @@ import { Command, RegisterBehavior } from '@sapphire/framework';
import { Time } from '@sapphire/time-utilities'; import { Time } from '@sapphire/time-utilities';
import type { User, Guild, GuildMember, Message } from 'discord.js'; import type { User, Guild, GuildMember, Message } from 'discord.js';
import { updateUser } from '#utils/database/dbExistingUser'; import { updateUser } from '#utils/database/dbExistingUser';
import { daily, getLastDaily } from '#utils/database/economy'; import { daily, getLastDaily } from '#utils/database/fun/economy';
import { EmbedBuilder } from 'discord.js'; import { EmbedBuilder } from 'discord.js';
import IDs from '#utils/ids'; import IDs from '#utils/ids';

View File

@ -20,7 +20,7 @@
import { Args, Command, RegisterBehavior } from '@sapphire/framework'; import { Args, Command, RegisterBehavior } from '@sapphire/framework';
import type { User, Guild, Message } from 'discord.js'; import type { User, Guild, Message } from 'discord.js';
import { updateUser } from '#utils/database/dbExistingUser'; import { updateUser } from '#utils/database/dbExistingUser';
import { getBalance, transfer } from '#utils/database/economy'; import { getBalance, transfer } from '#utils/database/fun/economy';
import { EmbedBuilder, TextChannel } from 'discord.js'; import { EmbedBuilder, TextChannel } from 'discord.js';
import IDs from '#utils/ids'; import IDs from '#utils/ids';

View File

@ -20,7 +20,7 @@
import { Command, RegisterBehavior } from '@sapphire/framework'; import { Command, RegisterBehavior } from '@sapphire/framework';
import { EmbedBuilder, GuildMember } from 'discord.js'; import { EmbedBuilder, GuildMember } from 'discord.js';
import { N1984 } from '#utils/gifs'; import { N1984 } from '#utils/gifs';
import { addFunLog, countTotal } from '#utils/database/fun'; import { addFunLog, countTotal } from '#utils/database/fun/fun';
export class N1984Command extends Command { export class N1984Command extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) { public constructor(context: Command.LoaderContext, options: Command.Options) {

View File

@ -20,7 +20,7 @@
import { Command, RegisterBehavior } from '@sapphire/framework'; import { Command, RegisterBehavior } from '@sapphire/framework';
import { EmbedBuilder, GuildMember } from 'discord.js'; import { EmbedBuilder, GuildMember } from 'discord.js';
import { Cringe } from '#utils/gifs'; import { Cringe } from '#utils/gifs';
import { addFunLog, countTotal } from '#utils/database/fun'; import { addFunLog, countTotal } from '#utils/database/fun/fun';
export class CringeCommand extends Command { export class CringeCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) { public constructor(context: Command.LoaderContext, options: Command.Options) {

View File

@ -20,7 +20,7 @@
import { Command, RegisterBehavior } from '@sapphire/framework'; import { Command, RegisterBehavior } from '@sapphire/framework';
import { EmbedBuilder, GuildMember } from 'discord.js'; import { EmbedBuilder, GuildMember } from 'discord.js';
import { Hugs } from '#utils/gifs'; import { Hugs } from '#utils/gifs';
import { addFunLog, countTotal } from '#utils/database/fun'; import { addFunLog, countTotal } from '#utils/database/fun/fun';
export class HugCommand extends Command { export class HugCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) { public constructor(context: Command.LoaderContext, options: Command.Options) {

View File

@ -20,7 +20,7 @@
import { Command, RegisterBehavior } from '@sapphire/framework'; import { Command, RegisterBehavior } from '@sapphire/framework';
import { EmbedBuilder, GuildMember } from 'discord.js'; import { EmbedBuilder, GuildMember } from 'discord.js';
import { Kill } from '#utils/gifs'; import { Kill } from '#utils/gifs';
import { addFunLog, countTotal } from '#utils/database/fun'; import { addFunLog, countTotal } from '#utils/database/fun/fun';
export class KillCommand extends Command { export class KillCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) { public constructor(context: Command.LoaderContext, options: Command.Options) {

View File

@ -20,7 +20,7 @@
import { Command, RegisterBehavior } from '@sapphire/framework'; import { Command, RegisterBehavior } from '@sapphire/framework';
import { EmbedBuilder, GuildMember } from 'discord.js'; import { EmbedBuilder, GuildMember } from 'discord.js';
import { Poke } from '#utils/gifs'; import { Poke } from '#utils/gifs';
import { addFunLog, countTotal } from '#utils/database/fun'; import { addFunLog, countTotal } from '#utils/database/fun/fun';
export class PokeCommand extends Command { export class PokeCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) { public constructor(context: Command.LoaderContext, options: Command.Options) {

View File

@ -21,9 +21,9 @@ import { Args, Command, RegisterBehavior } from '@sapphire/framework';
import type { User, Message, Snowflake, TextChannel, Guild } from 'discord.js'; import type { User, Message, Snowflake, TextChannel, Guild } from 'discord.js';
import { EmbedBuilder } from 'discord.js'; import { EmbedBuilder } from 'discord.js';
import IDs from '#utils/ids'; import IDs from '#utils/ids';
import { addBan, checkBan } from '#utils/database/ban'; import { addBan, checkBan } from '#utils/database/moderation/ban';
import { addEmptyUser, updateUser } from '#utils/database/dbExistingUser'; import { addEmptyUser, updateUser } from '#utils/database/dbExistingUser';
import { checkTempBan, removeTempBan } from '#utils/database/tempBan'; import { checkTempBan, removeTempBan } from '#utils/database/moderation/tempBan';
export class BanCommand extends Command { export class BanCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) { public constructor(context: Command.LoaderContext, options: Command.Options) {

View File

@ -22,7 +22,7 @@ import { Duration, DurationFormatter } from '@sapphire/time-utilities';
import type { User, Snowflake, TextChannel, Guild } from 'discord.js'; import type { User, Snowflake, TextChannel, Guild } from 'discord.js';
import { EmbedBuilder, Message } from 'discord.js'; import { EmbedBuilder, Message } from 'discord.js';
import IDs from '#utils/ids'; import IDs from '#utils/ids';
import { addTempBan, checkTempBan } from '#utils/database/tempBan'; import { addTempBan, checkTempBan } from '#utils/database/moderation/tempBan';
import { addEmptyUser, updateUser } from '#utils/database/dbExistingUser'; import { addEmptyUser, updateUser } from '#utils/database/dbExistingUser';
export class TempBanCommand extends Command { export class TempBanCommand extends Command {

View File

@ -28,8 +28,8 @@ import type {
} from 'discord.js'; } from 'discord.js';
import { EmbedBuilder } from 'discord.js'; import { EmbedBuilder } from 'discord.js';
import IDs from '#utils/ids'; import IDs from '#utils/ids';
import { removeBan, checkBan, addBan } from '#utils/database/ban'; import { removeBan, checkBan, addBan } from '#utils/database/moderation/ban';
import { checkTempBan, removeTempBan } from '#utils/database/tempBan'; import { checkTempBan, removeTempBan } from '#utils/database/moderation/tempBan';
import { addEmptyUser, addExistingUser } from '#utils/database/dbExistingUser'; import { addEmptyUser, addExistingUser } from '#utils/database/dbExistingUser';
export class UnbanCommand extends Command { export class UnbanCommand extends Command {

View File

@ -36,7 +36,7 @@ import {
updateUser, updateUser,
fetchRoles, fetchRoles,
} from '#utils/database/dbExistingUser'; } from '#utils/database/dbExistingUser';
import { restrict, checkActive } from '#utils/database/restriction'; import { restrict, checkActive } from '#utils/database/moderation/restriction';
import { randint } from '#utils/maths'; import { randint } from '#utils/maths';
import { blockedRolesAfterRestricted } from '#utils/blockedRoles'; import { blockedRolesAfterRestricted } from '#utils/blockedRoles';

View File

@ -21,7 +21,7 @@ import { Args, Command, RegisterBehavior } from '@sapphire/framework';
import { ChannelType, EmbedBuilder } from 'discord.js'; import { ChannelType, EmbedBuilder } from 'discord.js';
import type { Message, TextChannel, Guild, Snowflake } from 'discord.js'; import type { Message, TextChannel, Guild, Snowflake } from 'discord.js';
import IDs from '#utils/ids'; import IDs from '#utils/ids';
import { getRestrictions } from '#utils/database/restriction'; import { getRestrictions } from '#utils/database/moderation/restriction';
import { checkStaff } from '#utils/checker'; import { checkStaff } from '#utils/checker';
export class RestrictLogsCommand extends Command { export class RestrictLogsCommand extends Command {

View File

@ -26,7 +26,7 @@ import {
unRestrict, unRestrict,
checkActive, checkActive,
unRestrictLegacy, unRestrictLegacy,
} from '#utils/database/restriction'; } from '#utils/database/moderation/restriction';
export class UnRestrictCommand extends Command { export class UnRestrictCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) { public constructor(context: Command.LoaderContext, options: Command.Options) {

View File

@ -39,7 +39,7 @@ import {
getNote, getNote,
deactivateNote, deactivateNote,
deactivateAllNotes, deactivateAllNotes,
} from '#utils/database/sus'; } from '#utils/database/moderation/sus';
import { checkStaff } from '#utils/checker'; import { checkStaff } from '#utils/checker';
import IDs from '#utils/ids'; import IDs from '#utils/ids';
import { createSusLogEmbed } from '#utils/embeds'; import { createSusLogEmbed } from '#utils/embeds';

View File

@ -19,7 +19,7 @@
import { Args, Command, RegisterBehavior } from '@sapphire/framework'; import { Args, Command, RegisterBehavior } from '@sapphire/framework';
import type { GuildMember, Message } from 'discord.js'; import type { GuildMember, Message } from 'discord.js';
import { addMute, removeMute, checkActive } from '#utils/database/vcMute'; import { addMute, removeMute, checkActive } from '#utils/database/moderation/vcMute';
import { addExistingUser } from '#utils/database/dbExistingUser'; import { addExistingUser } from '#utils/database/dbExistingUser';
export class VCMuteCommand extends Command { export class VCMuteCommand extends Command {

View File

@ -21,7 +21,7 @@ import { Args, Command, RegisterBehavior } from '@sapphire/framework';
import { EmbedBuilder, TextChannel } from 'discord.js'; import { EmbedBuilder, TextChannel } from 'discord.js';
import type { Message, Guild, User } from 'discord.js'; import type { Message, Guild, User } from 'discord.js';
import IDs from '#utils/ids'; import IDs from '#utils/ids';
import { deleteWarning, fetchWarning } from '#utils/database/warnings'; import { deleteWarning, fetchWarning } from '#utils/database/moderation/warnings';
import { checkStaff } from '#utils/checker'; import { checkStaff } from '#utils/checker';
export class DeleteWarningCommand extends Command { export class DeleteWarningCommand extends Command {

View File

@ -25,7 +25,7 @@ import {
} from '@sapphire/framework'; } from '@sapphire/framework';
import type { User, Message, Snowflake, Guild, TextChannel } from 'discord.js'; import type { User, Message, Snowflake, Guild, TextChannel } from 'discord.js';
import { updateUser } from '#utils/database/dbExistingUser'; import { updateUser } from '#utils/database/dbExistingUser';
import { addWarn } from '#utils/database/warnings'; import { addWarn } from '#utils/database/moderation/warnings';
import { EmbedBuilder } from 'discord.js'; import { EmbedBuilder } from 'discord.js';
import IDs from '#utils/ids'; import IDs from '#utils/ids';

View File

@ -21,7 +21,7 @@ import { Args, Command, RegisterBehavior } from '@sapphire/framework';
import { ChannelType, EmbedBuilder } from 'discord.js'; import { ChannelType, EmbedBuilder } from 'discord.js';
import type { Message, Guild, User } from 'discord.js'; import type { Message, Guild, User } from 'discord.js';
import IDs from '#utils/ids'; import IDs from '#utils/ids';
import { fetchWarnings } from '#utils/database/warnings'; import { fetchWarnings } from '#utils/database/moderation/warnings';
import { checkStaff } from '#utils/checker'; import { checkStaff } from '#utils/checker';
import { createWarningsEmbed } from '#utils/embeds'; import { createWarningsEmbed } from '#utils/embeds';

View File

@ -20,7 +20,7 @@
import { Args, Command, RegisterBehavior } from '@sapphire/framework'; import { Args, Command, RegisterBehavior } from '@sapphire/framework';
import type { User, Guild, Message } from 'discord.js'; import type { User, Guild, Message } from 'discord.js';
import { EmbedBuilder } from 'discord.js'; import { EmbedBuilder } from 'discord.js';
import { getRank, xpToNextLevel } from '#utils/database/xp'; import { getRank, xpToNextLevel } from '#utils/database/fun/xp';
export class RankCommand extends Command { export class RankCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) { public constructor(context: Command.LoaderContext, options: Command.Options) {

View File

@ -20,7 +20,7 @@
import { Listener } from '@sapphire/framework'; import { Listener } from '@sapphire/framework';
import type { GuildBan } from 'discord.js'; import type { GuildBan } from 'discord.js';
import { AuditLogEvent, EmbedBuilder, TextChannel } from 'discord.js'; import { AuditLogEvent, EmbedBuilder, TextChannel } from 'discord.js';
import { addBan, checkBan } from '#utils/database/ban'; import { addBan, checkBan } from '#utils/database/moderation/ban';
import IDs from '#utils/ids'; import IDs from '#utils/ids';
import { addEmptyUser, addExistingUser } from '#utils/database/dbExistingUser'; import { addEmptyUser, addExistingUser } from '#utils/database/dbExistingUser';

View File

@ -19,8 +19,8 @@
import { Listener } from '@sapphire/framework'; import { Listener } from '@sapphire/framework';
import type { GuildMember } from 'discord.js'; import type { GuildMember } from 'discord.js';
import { checkBan, getBanReason } from '#utils/database/ban'; import { checkBan, getBanReason } from '#utils/database/moderation/ban';
import { checkTempBan } from '#utils/database/tempBan'; import { checkTempBan } from '#utils/database/moderation/tempBan';
export class BanJoinListener extends Listener { export class BanJoinListener extends Listener {
public constructor( public constructor(

View File

@ -20,7 +20,7 @@
import { Listener } from '@sapphire/framework'; import { Listener } from '@sapphire/framework';
import type { GuildBan } from 'discord.js'; import type { GuildBan } from 'discord.js';
import { AuditLogEvent, EmbedBuilder, TextChannel } from 'discord.js'; import { AuditLogEvent, EmbedBuilder, TextChannel } from 'discord.js';
import { addBan, checkBan, removeBan } from '#utils/database/ban'; import { addBan, checkBan, removeBan } from '#utils/database/moderation/ban';
import IDs from '#utils/ids'; import IDs from '#utils/ids';
import { addEmptyUser, addExistingUser } from '#utils/database/dbExistingUser'; import { addEmptyUser, addExistingUser } from '#utils/database/dbExistingUser';

View File

@ -21,7 +21,7 @@
import { Listener } from '@sapphire/framework'; import { Listener } from '@sapphire/framework';
import type { Message } from 'discord.js'; import type { Message } from 'discord.js';
import { getLastCount, addCount } from '#utils/database/counting'; import { getLastCount, addCount } from '#utils/database/fun/counting';
import IDs from '#utils/ids'; import IDs from '#utils/ids';
export class XpListener extends Listener { export class XpListener extends Listener {

View File

@ -22,14 +22,14 @@ import { ChannelType } from 'discord.js';
import type { GuildChannel, EmbedBuilder } from 'discord.js'; import type { GuildChannel, EmbedBuilder } from 'discord.js';
import { setTimeout } from 'timers/promises'; import { setTimeout } from 'timers/promises';
import IDs from '#utils/ids'; import IDs from '#utils/ids';
import { checkActive, getRestrictions } from '#utils/database/restriction'; import { checkActive, getRestrictions } from '#utils/database/moderation/restriction';
import { findNotes } from '#utils/database/sus'; import { findNotes } from '#utils/database/moderation/sus';
import { import {
createRestrictLogEmbed, createRestrictLogEmbed,
createSusLogEmbed, createSusLogEmbed,
createWarningsEmbed, createWarningsEmbed,
} from '#utils/embeds'; } from '#utils/embeds';
import { fetchWarnings } from '#utils/database/warnings'; import { fetchWarnings } from '#utils/database/moderation/warnings';
export class ModMailCreateListener extends Listener { export class ModMailCreateListener extends Listener {
public constructor( public constructor(

View File

@ -28,7 +28,7 @@ import type {
import { ChannelType } from 'discord.js'; import { ChannelType } from 'discord.js';
import { fetchRoles, getLeaveRoles } from '#utils/database/dbExistingUser'; import { fetchRoles, getLeaveRoles } from '#utils/database/dbExistingUser';
import { blockTime } from '#utils/database/verification'; import { blockTime } from '#utils/database/verification';
import { checkActive, getSection } from '#utils/database/restriction'; import { checkActive, getSection } from '#utils/database/moderation/restriction';
import { blockedRoles, blockedRolesAfterRestricted } from '#utils/blockedRoles'; import { blockedRoles, blockedRolesAfterRestricted } from '#utils/blockedRoles';
import IDs from '#utils/ids'; import IDs from '#utils/ids';

View File

@ -19,7 +19,7 @@
import { Listener } from '@sapphire/framework'; import { Listener } from '@sapphire/framework';
import type { VoiceState } from 'discord.js'; import type { VoiceState } from 'discord.js';
import { checkActive, removeMute } from '#utils/database/vcMute'; import { checkActive, removeMute } from '#utils/database/moderation/vcMute';
export class VCMuteListener extends Listener { export class VCMuteListener extends Listener {
public constructor( public constructor(

View File

@ -50,7 +50,7 @@ import {
startVerification, startVerification,
finishVerification, finishVerification,
} from '#utils/database/verification'; } from '#utils/database/verification';
import { findNotes } from '#utils/database/sus'; import { findNotes } from '#utils/database/moderation/sus';
import { addExistingUser } from '#utils/database/dbExistingUser'; import { addExistingUser } from '#utils/database/dbExistingUser';
import { rolesToString } from '#utils/formatter'; import { rolesToString } from '#utils/formatter';
import IDs from '#utils/ids'; import IDs from '#utils/ids';

View File

@ -19,7 +19,7 @@
import { Listener } from '@sapphire/framework'; import { Listener } from '@sapphire/framework';
import type { Message } from 'discord.js'; import type { Message } from 'discord.js';
import { addXp, checkCanAddXp } from '#utils/database/xp'; import { addXp, checkCanAddXp } from '#utils/database/fun/xp';
import { randint } from '#utils/maths'; import { randint } from '#utils/maths';
export class XpListener extends Listener { export class XpListener extends Listener {

View File

@ -20,8 +20,8 @@
import { ScheduledTask } from '@sapphire/plugin-scheduled-tasks'; import { ScheduledTask } from '@sapphire/plugin-scheduled-tasks';
import IDs from '#utils/ids'; import IDs from '#utils/ids';
import { EmbedBuilder } from 'discord.js'; import { EmbedBuilder } from 'discord.js';
import { checkBan } from '#utils/database/ban'; import { checkBan } from '#utils/database/moderation/ban';
import { checkTempBan, removeTempBan } from '#utils/database/tempBan'; import { checkTempBan, removeTempBan } from '#utils/database/moderation/tempBan';
export class TempBan extends ScheduledTask { export class TempBan extends ScheduledTask {
public constructor( public constructor(

View File

@ -18,9 +18,9 @@
*/ */
import type { Guild, User } from 'discord.js'; import type { Guild, User } from 'discord.js';
import { EmbedBuilder } from 'discord.js'; import { EmbedBuilder } from 'discord.js';
import type { SusNotes } from '#utils/database/sus'; import type { SusNotes } from '#utils/database/moderation/sus';
import { RestrictionLogs } from '#utils/database/restriction'; import { RestrictionLogs } from '#utils/database/moderation/restriction';
import { Warnings } from '#utils/database/warnings'; import { Warnings } from '#utils/database/moderation/warnings';
export function createSusLogEmbed(notes: SusNotes, user: User, guild: Guild) { export function createSusLogEmbed(notes: SusNotes, user: User, guild: Guild) {
const embed = new EmbedBuilder() const embed = new EmbedBuilder()