Skip to content

Commit afbeedc

Browse files
committed
chore(database): clean up errors
1 parent fc86ebe commit afbeedc

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

src/commands.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ import { PermissionFlagsBits } from "discord-api-types/v8";
1616
import hfksdjfskfhsjdfhkasfdhksf from "hfksdjfskfhsjdfhkasfdhksf";
1717

1818
import checkIfChannelIdIsValid from "./utils/youtube/checkIfChannelIdIsValid";
19-
import {
20-
getAllTrackedInGuild,
21-
stopGuildTrackingChannel,
22-
twitchStopGuildTrackingChannel,
23-
} from "./utils/database";
2419
import getChannelDetails from "./utils/youtube/getChannelDetails";
2520
import { checkIfStreamerIsLive } from "./utils/twitch/checkIfStreamerIsLive";
2621
import {

src/db/discord.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { eq, and } from "drizzle-orm";
22

3-
import { Platform } from "../types/types";
3+
import { Platform } from "../types/types.d";
44

55
import { db } from "./db";
66
import {

src/db/schema.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,18 @@ export const dbAuditLogsTable = pgTable("audit_logs", {
136136
data: jsonb("data"),
137137
occurredAt: timestamp("occurred_at").defaultNow(),
138138
});
139+
140+
export default {
141+
dbDiscordTable,
142+
dbBlueskyTable,
143+
dbYouTubeTable,
144+
dbTwitchTable,
145+
dbGuildBlueskySubscriptionsTable,
146+
dbGuildYouTubeSubscriptionsTable,
147+
dbGuildTwitchSubscriptionsTable,
148+
dbBotInfoTable,
149+
dbBotInfoNotificationsTable,
150+
dbAuditLogsEventTypeEnum,
151+
dbAuditLogsSuccessTypeEnum,
152+
dbAuditLogsTable,
153+
};

src/index.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313

1414
import { env } from "./config.ts";
1515
import commandsMap from "./commands.ts";
16-
import initTables from "./db/schema.ts";
1716
import { getTwitchToken } from "./utils/twitch/auth.ts";
1817

1918
if (!env.discordToken || env.discordToken === "YOUR_DISCORD_TOKEN") {
@@ -57,11 +56,6 @@ const data = (await rest.put(Routes.applicationCommands(getAppId.id), {
5756

5857
console.log(`Successfully reloaded ${data.length} application (/) commands.`);
5958

60-
// Check if Postgres is set up properly and its working
61-
if (!(await initTables())) {
62-
// throw new Error("Error initializing tables");
63-
}
64-
6559
// Get Twitch token
6660
if (!(await getTwitchToken())) {
6761
throw new Error("Error getting Twitch token");

src/utils/twitch/checkIfStreamerIsLive.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
import type { dbTwitch } from "../../types/database";
21
import type { TextChannel } from "discord.js";
32

43
import { env } from "../../config";
5-
import {
6-
twitchGetAllChannelsToTrack,
7-
twitchGetGuildsTrackingChannel,
8-
twitchUpdateIsLive,
9-
} from "../database";
104
import client from "../..";
115

126
import { twitchToken } from "./auth";

src/utils/youtube/fetchLatestUploads.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import type { dbGuildYouTubeSubscriptionsTable } from "../../db/schema";
1+
import type { Platform } from "../../types/types.d.ts";
22

3+
import {
4+
dbGuildYouTubeSubscriptionsTable,
5+
dbYouTubeTable,
6+
} from "../../db/schema";
37
import { env } from "../../config";
4-
import { updateVideoId } from "../database";
58
import { dbYouTubeGetAllChannelsToTrack } from "../../db/youtube";
69
import { discordGetAllGuildsTrackingChannel } from "../../db/discord";
7-
import { Platform } from "../../types/types";
810

911
import getChannelDetails from "./getChannelDetails";
1012

@@ -20,7 +22,7 @@ export default async function fetchLatestUploads() {
2022
console.log("Fetching latest uploads...");
2123

2224
const channels = await dbYouTubeGetAllChannelsToTrack();
23-
const channelDict: Record<string, string> = {};
25+
const channelDict: Record<string, typeof dbYouTubeTable.$inferSelect> = {};
2426

2527
if (!channels || !channels.success || channels.data.length === 0) {
2628
console.log("No channels to track.");
@@ -29,14 +31,14 @@ export default async function fetchLatestUploads() {
2931
}
3032

3133
channels.data.forEach((channel) => {
32-
if (!channel.youtube_channel_id || !channel.latest_video_id) {
34+
if (!channel.youtubeChannelId || !channel.latestAllId) {
3335
console.error(
3436
"Channel ID or latest video ID is missing in fetchLatestUploads",
3537
);
3638

3739
return;
3840
}
39-
channelDict[channel.youtube_channel_id] = channel.latest_video_id;
41+
channelDict[channel.youtubeChannelId] = channel;
4042
});
4143

4244
const chunkSize = 50;

0 commit comments

Comments
 (0)