forked from syntaxbullet/AuroraBot-discord
refactor: clean up unused imports and dead code across commands, services, and tests.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { createCommand } from "@lib/utils";
|
import { createCommand } from "@lib/utils";
|
||||||
import { AuroraClient } from "@/lib/BotClient";
|
import { AuroraClient } from "@/lib/BotClient";
|
||||||
import { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits, MessageFlags } from "discord.js";
|
import { SlashCommandBuilder, PermissionFlagsBits, MessageFlags } from "discord.js";
|
||||||
import { createErrorEmbed, createSuccessEmbed, createWarningEmbed } from "@lib/embeds";
|
import { createErrorEmbed, createSuccessEmbed } from "@lib/embeds";
|
||||||
|
|
||||||
export const refresh = createCommand({
|
export const refresh = createCommand({
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { createCommand } from "@lib/utils";
|
import { createCommand } from "@lib/utils";
|
||||||
import { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits, MessageFlags, ButtonBuilder, ButtonStyle, ActionRowBuilder, ComponentType } from "discord.js";
|
import { SlashCommandBuilder, PermissionFlagsBits, MessageFlags, ButtonBuilder, ButtonStyle, ActionRowBuilder, ComponentType } from "discord.js";
|
||||||
import { createErrorEmbed, createSuccessEmbed, createWarningEmbed, createInfoEmbed } from "@lib/embeds";
|
import { createErrorEmbed, createSuccessEmbed, createWarningEmbed, createInfoEmbed } from "@lib/embeds";
|
||||||
|
|
||||||
export const update = createCommand({
|
export const update = createCommand({
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { createCommand } from "@/lib/utils";
|
import { createCommand } from "@/lib/utils";
|
||||||
import { SlashCommandBuilder, PermissionFlagsBits, TextChannel, NewsChannel, VoiceChannel, MessageFlags } from "discord.js";
|
import { SlashCommandBuilder, PermissionFlagsBits, MessageFlags } from "discord.js";
|
||||||
import { createErrorEmbed } from "@/lib/embeds";
|
import { createErrorEmbed } from "@/lib/embeds";
|
||||||
import { sendWebhookMessage } from "@/lib/webhookUtils";
|
import { sendWebhookMessage } from "@/lib/webhookUtils";
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export const balance = createCommand({
|
|||||||
const targetUser = interaction.options.getUser("user") || interaction.user;
|
const targetUser = interaction.options.getUser("user") || interaction.user;
|
||||||
|
|
||||||
if (targetUser.bot) {
|
if (targetUser.bot) {
|
||||||
return; // Wait, I need to send the reply inside the if.
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = await userService.getOrCreateUser(targetUser.id, targetUser.username);
|
const user = await userService.getOrCreateUser(targetUser.id, targetUser.username);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
import { createCommand } from "@/lib/utils";
|
import { createCommand } from "@/lib/utils";
|
||||||
import { SlashCommandBuilder, EmbedBuilder, MessageFlags } from "discord.js";
|
import { SlashCommandBuilder, EmbedBuilder } from "discord.js";
|
||||||
import { economyService } from "@/modules/economy/economy.service";
|
import { economyService } from "@/modules/economy/economy.service";
|
||||||
import { createSuccessEmbed, createErrorEmbed } from "@lib/embeds";
|
import { createErrorEmbed } from "@lib/embeds";
|
||||||
import { UserError } from "@/lib/errors";
|
import { UserError } from "@/lib/errors";
|
||||||
|
|
||||||
export const daily = createCommand({
|
export const daily = createCommand({
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { SlashCommandBuilder, EmbedBuilder, MessageFlags } from "discord.js";
|
|||||||
import { economyService } from "@/modules/economy/economy.service";
|
import { economyService } from "@/modules/economy/economy.service";
|
||||||
import { userService } from "@/modules/user/user.service";
|
import { userService } from "@/modules/user/user.service";
|
||||||
import { config } from "@/lib/config";
|
import { config } from "@/lib/config";
|
||||||
import { createSuccessEmbed, createErrorEmbed } from "@lib/embeds";
|
import { createErrorEmbed } from "@lib/embeds";
|
||||||
import { UserError } from "@/lib/errors";
|
import { UserError } from "@/lib/errors";
|
||||||
|
|
||||||
export const pay = createCommand({
|
export const pay = createCommand({
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { createCommand } from "@/lib/utils";
|
import { createCommand } from "@/lib/utils";
|
||||||
import { SlashCommandBuilder, EmbedBuilder, MessageFlags } from "discord.js";
|
import { SlashCommandBuilder } from "discord.js";
|
||||||
import { inventoryService } from "@/modules/inventory/inventory.service";
|
import { inventoryService } from "@/modules/inventory/inventory.service";
|
||||||
import { userService } from "@/modules/user/user.service";
|
import { userService } from "@/modules/user/user.service";
|
||||||
import { createErrorEmbed, createSuccessEmbed } from "@lib/embeds";
|
import { createErrorEmbed, createSuccessEmbed } from "@lib/embeds";
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ const event: Event<Events.MessageCreate> = {
|
|||||||
levelingService.processChatXp(message.author.id);
|
levelingService.processChatXp(message.author.id);
|
||||||
|
|
||||||
// Activity Tracking for Lootdrops
|
// Activity Tracking for Lootdrops
|
||||||
// We do dynamic import to avoid circular dependency issues if any, though likely not needed here.
|
|
||||||
// But better safe for modules. Actually direct import is fine if structure is clean.
|
|
||||||
import("@/modules/economy/lootdrop.service").then(m => m.lootdropService.processMessage(message));
|
import("@/modules/economy/lootdrop.service").then(m => m.lootdropService.processMessage(message));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ const event: Event<Events.ClientReady> = {
|
|||||||
const execAsync = promisify(exec);
|
const execAsync = promisify(exec);
|
||||||
|
|
||||||
// Send intermediate update if possible, though ready event should be fast.
|
// Send intermediate update if possible, though ready event should be fast.
|
||||||
// Maybe just run it and report result.
|
|
||||||
const { stdout: dbOut } = await execAsync("bun run db:push:local");
|
const { stdout: dbOut } = await execAsync("bun run db:push:local");
|
||||||
migrationOutput = dbOut;
|
migrationOutput = dbOut;
|
||||||
} catch (dbErr: any) {
|
} catch (dbErr: any) {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { readFileSync, writeFileSync } from 'fs';
|
import { readFileSync, writeFileSync } from 'fs';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { AuroraClient } from '@/lib/BotClient';
|
|
||||||
|
|
||||||
const configPath = join(process.cwd(), 'config', 'config.json');
|
const configPath = join(process.cwd(), 'config', 'config.json');
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { type TextBasedChannel, User, Client } from 'discord.js';
|
import { type TextBasedChannel, User } from 'discord.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a message to a channel using a temporary webhook (imitating the bot or custom persona).
|
* Sends a message to a channel using a temporary webhook (imitating the bot or custom persona).
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { describe, test, expect, spyOn, beforeEach, mock } from "bun:test";
|
import { describe, test, expect, spyOn, beforeEach, mock } from "bun:test";
|
||||||
import { handleItemWizardInteraction, renderWizard } from "./item_wizard";
|
import { handleItemWizardInteraction, renderWizard } from "./item_wizard";
|
||||||
import { DrizzleClient } from "@/lib/DrizzleClient";
|
|
||||||
import { ButtonInteraction, ModalSubmitInteraction, StringSelectMenuInteraction } from "discord.js";
|
import { ButtonInteraction, ModalSubmitInteraction, StringSelectMenuInteraction } from "discord.js";
|
||||||
|
|
||||||
// Mock Setup
|
// Mock Setup
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { describe, it, expect, mock, beforeEach } from "bun:test";
|
import { describe, it, expect, mock, beforeEach } from "bun:test";
|
||||||
import { classService } from "./class.service";
|
import { classService } from "./class.service";
|
||||||
import { classes, users } from "@/db/schema";
|
import { classes, users } from "@/db/schema";
|
||||||
import { eq, sql } from "drizzle-orm";
|
|
||||||
|
|
||||||
// Define mock functions
|
// Define mock functions
|
||||||
const mockFindMany = mock();
|
const mockFindMany = mock();
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { describe, it, expect, mock, beforeEach, afterEach, spyOn } from "bun:test";
|
import { describe, it, expect, mock, beforeEach, afterEach, spyOn } from "bun:test";
|
||||||
import { lootdropService } from "./lootdrop.service";
|
import { lootdropService } from "./lootdrop.service";
|
||||||
import { lootdrops } from "@/db/schema";
|
import { lootdrops } from "@/db/schema";
|
||||||
import { eq, and, isNull } from "drizzle-orm";
|
|
||||||
import { economyService } from "./economy.service";
|
import { economyService } from "./economy.service";
|
||||||
|
|
||||||
// Mock dependencies BEFORE using service functionality
|
// Mock dependencies BEFORE using service functionality
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { describe, it, expect, mock, beforeEach, afterEach, spyOn } from "bun:test";
|
import { describe, it, expect, mock, beforeEach, afterEach, spyOn } from "bun:test";
|
||||||
import { inventoryService } from "./inventory.service";
|
import { inventoryService } from "./inventory.service";
|
||||||
import { inventory, items, userTimers } from "@/db/schema";
|
import { inventory, userTimers } from "@/db/schema";
|
||||||
// Helper to mock resolved value for spyOn
|
// Helper to mock resolved value for spyOn
|
||||||
import { economyService } from "@/modules/economy/economy.service";
|
import { economyService } from "@/modules/economy/economy.service";
|
||||||
import { levelingService } from "@/modules/leveling/leveling.service";
|
import { levelingService } from "@/modules/leveling/leveling.service";
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { describe, it, expect, mock, beforeEach, afterEach, setSystemTime } from "bun:test";
|
import { describe, it, expect, mock, beforeEach, afterEach, setSystemTime } from "bun:test";
|
||||||
import { levelingService } from "./leveling.service";
|
import { levelingService } from "./leveling.service";
|
||||||
import { users, userTimers } from "@/db/schema";
|
import { users, userTimers } from "@/db/schema";
|
||||||
import { eq, and } from "drizzle-orm";
|
|
||||||
|
|
||||||
// Mock dependencies
|
// Mock dependencies
|
||||||
const mockFindFirst = mock();
|
const mockFindFirst = mock();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { quests, userQuests, users } from "@/db/schema";
|
import { userQuests } from "@/db/schema";
|
||||||
import { eq, and, sql } from "drizzle-orm";
|
import { eq, and } from "drizzle-orm";
|
||||||
import { UserError } from "@/lib/errors";
|
import { UserError } from "@/lib/errors";
|
||||||
import { DrizzleClient } from "@/lib/DrizzleClient";
|
import { DrizzleClient } from "@/lib/DrizzleClient";
|
||||||
import { economyService } from "@/modules/economy/economy.service";
|
import { economyService } from "@/modules/economy/economy.service";
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import type { TradeSession, TradeParticipant } from "./trade.types";
|
import type { TradeSession, TradeParticipant } from "./trade.types";
|
||||||
import { DrizzleClient } from "@/lib/DrizzleClient";
|
import { DrizzleClient } from "@/lib/DrizzleClient";
|
||||||
import { withTransaction } from "@/lib/db";
|
|
||||||
import { UserError } from "@/lib/errors";
|
|
||||||
import { economyService } from "@/modules/economy/economy.service";
|
import { economyService } from "@/modules/economy/economy.service";
|
||||||
import { inventoryService } from "@/modules/inventory/inventory.service";
|
import { inventoryService } from "@/modules/inventory/inventory.service";
|
||||||
import { itemTransactions } from "@/db/schema";
|
import { itemTransactions } from "@/db/schema";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
import { describe, it, expect, mock, beforeEach, afterEach } from "bun:test";
|
import { describe, it, expect, mock, beforeEach } from "bun:test";
|
||||||
import { userService } from "./user.service";
|
import { userService } from "./user.service";
|
||||||
|
|
||||||
// Define mock functions outside so we can control them in tests
|
// Define mock functions outside so we can control them in tests
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { users } from "@/db/schema";
|
import { users } from "@/db/schema";
|
||||||
import { eq, sql } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
import { DrizzleClient } from "@/lib/DrizzleClient";
|
import { DrizzleClient } from "@/lib/DrizzleClient";
|
||||||
|
|
||||||
export const userService = {
|
export const userService = {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { userTimers } from "@/db/schema";
|
import { userTimers } from "@/db/schema";
|
||||||
import { eq, and, lt } from "drizzle-orm";
|
import { eq, and } from "drizzle-orm";
|
||||||
import { DrizzleClient } from "@/lib/DrizzleClient";
|
import { DrizzleClient } from "@/lib/DrizzleClient";
|
||||||
|
|
||||||
export type TimerType = 'COOLDOWN' | 'EFFECT' | 'ACCESS';
|
export type TimerType = 'COOLDOWN' | 'EFFECT' | 'ACCESS';
|
||||||
|
|||||||
Reference in New Issue
Block a user