Skip to content

Commit c77de3c

Browse files
committed
feat(/track): add same errors for twitch
1 parent 522c316 commit c77de3c

File tree

2 files changed

+8
-27
lines changed

2 files changed

+8
-27
lines changed

src/commands.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -413,16 +413,17 @@ const commands: Record<string, Command> = {
413413
return;
414414
}
415415

416-
// Check if the channel is already being tracked in the guild
417-
if (
418-
await twitchCheckIfGuildIsTrackingChannelAlready(
419-
streamerId,
416+
const trackedChannels =
417+
await checkIfGuildIsTrackingChannelAlready(
418+
platformUserId,
420419
guildId,
421-
)
422-
) {
420+
);
421+
422+
// Check if the channel is already being tracked in the guild
423+
if (trackedChannels.length) {
423424
await interaction.reply({
424425
flags: MessageFlags.Ephemeral,
425-
content: "This streamer is already being tracked!",
426+
content: `This channel is already being tracked in ${trackedChannels.map((channel, index) => `${index > 0 && index === trackedChannels.length - 1 ? "and " : ""}<#${channel.guild_channel_id}>`).join(", ")}!`,
426427
});
427428

428429
return;

src/utils/database.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -150,26 +150,6 @@ export async function twitchCheckIfChannelIsAlreadyTracked(channelId: string) {
150150
}
151151
}
152152

153-
export async function twitchCheckIfGuildIsTrackingChannelAlready(
154-
channelId: string,
155-
guild_id: string,
156-
) {
157-
const query = `SELECT * FROM discord WHERE platform_user_id = ? AND guild_id = ?`;
158-
159-
try {
160-
const statement = db.prepare(query);
161-
const result = statement.all(channelId, guild_id);
162-
163-
return result.length > 0;
164-
} catch (err) {
165-
console.error(
166-
"Error checking if guild is tracking Twitch channel already:",
167-
err,
168-
);
169-
throw err;
170-
}
171-
}
172-
173153
export async function twitchAddNewChannelToTrack(
174154
channelId: string,
175155
isLive: boolean,

0 commit comments

Comments
 (0)