Skip to content

Commit 8f7caaa

Browse files
committed
fix: /untrack crashing
1 parent 046467d commit 8f7caaa

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

src/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { heapStats } from 'bun:jsc';
22
import client from '.';
33
import { ChannelType, GuildMember, type CommandInteraction } from 'discord.js';
44
import checkIfChannelIdIsValid from './utils/youtube/checkIfChannelIdIsValid';
5-
import { addNewChannelToTrack, addNewGuildToTrackChannel, checkIfChannelIsAlreadyTracked, checkIfGuildIsTrackingChannelAlready, stopGuildTrackingChannel, twitchAddNewChannelToTrack, twitchAddNewGuildToTrackChannel, twitchCheckIfChannelIsAlreadyTracked, twitchCheckIfGuildIsTrackingChannelAlready, twitchStopGuildTrackingChannel } from './database';
5+
import { addNewChannelToTrack, addNewGuildToTrackChannel, checkIfChannelIsAlreadyTracked, checkIfGuildIsTrackingChannelAlready, stopGuildTrackingChannel, twitchAddNewChannelToTrack, twitchAddNewGuildToTrackChannel, twitchCheckIfChannelIsAlreadyTracked, twitchCheckIfGuildIsTrackingChannelAlready, twitchStopGuildTrackingChannel } from './utils/database';
66
import getChannelDetails from './utils/youtube/getChannelDetails';
77
import { PermissionFlagsBits } from 'discord-api-types/v8';
88
import { getStreamerId } from './utils/twitch/getStreamerId';

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import { Client, GatewayIntentBits, REST, Routes, type APIApplicationCommand } f
4242
import commandsMap from './commands.ts';
4343
import fs from 'fs/promises';
4444
import path from 'path';
45-
import { initTables } from './database.ts';
45+
import { initTables } from './utils/database.ts';
4646
import { getTwitchToken } from './utils/twitch/auth.ts';
4747

4848
const client = new Client({

src/database.ts renamed to src/utils/database.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import mysql from 'mysql2';
2-
import type { dbYouTube } from './types/database';
2+
import type { dbYouTube } from '../types/database';
33

44
const pool = mysql.createPool({
55
host: process.env.MYSQL_ADDRESS as string,
@@ -177,7 +177,7 @@ export async function updateVideoId(channelId: string, videoId: string) {
177177
}
178178

179179
export async function stopGuildTrackingChannel(guild_id: string, channelId: string) {
180-
const query = `DELETE FROM discord WHERE guild_id = ? AND discord_youtube_channel_id = ?`;
180+
const query = `DELETE FROM discord WHERE guild_id = ? AND platform_user_id = ?`;
181181
return new Promise<boolean>((resolve, reject) =>
182182
pool.query(query, [guild_id, channelId], (err) => {
183183
if (err) {

src/utils/twitch/checkIfStreamerIsLive.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { twitchToken } from "./auth";
22
import { env } from "../../config";
3-
import { twitchGetAllChannelsToTrack, twitchGetGuildsTrackingChannel, twitchUpdateIsLive } from "../../database";
3+
import { twitchGetAllChannelsToTrack, twitchGetGuildsTrackingChannel, twitchUpdateIsLive } from "../database";
44
import type { dbTwitch } from "../../types/database";
55
import client from "../..";
66
import type { TextChannel } from "discord.js";
@@ -71,11 +71,11 @@ export async function checkIfStreamersAreLive(): Promise<void> {
7171
// Update the database
7272
console.log(`Updating ${streamerId.twitch_channel_id} to be ${isLive ? "live" : "offline"}`);
7373
await twitchUpdateIsLive(streamerId.twitch_channel_id, isLive);
74-
74+
7575
if (isLive) {
7676
// Get the streamer's name
7777
const streamerName = await getStreamerName(streamerId.twitch_channel_id);
78-
78+
7979
// Get all guilds that are tracking this streamer
8080
const guildsTrackingStreamer = await twitchGetGuildsTrackingChannel(streamerId.twitch_channel_id)
8181
for (const guild of guildsTrackingStreamer) {

src/utils/youtube/fetchLatestUploads.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { env } from "../../config";
2-
import { getAllChannelsToTrack, getGuildsTrackingChannel, updateVideoId } from "../../database";
2+
import { getAllChannelsToTrack, getGuildsTrackingChannel, updateVideoId } from "../database";
33
import { ChannelType, TextChannel } from "discord.js";
44
import client from "../..";
55
import getChannelDetails from "./getChannelDetails";

0 commit comments

Comments
 (0)