Skip to content

Commit 5a404fe

Browse files
committed
chore: replace ephemeral: true with flags: MessageFlags.Ephemeral in reply function
lol its deprecated
1 parent 5b553c3 commit 5a404fe

File tree

3 files changed

+48
-61
lines changed

3 files changed

+48
-61
lines changed

src/commands.ts

Lines changed: 46 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import Bun from "bun";
22
import { heapStats } from "bun:jsc";
3-
import { ChannelType, GuildMember, type CommandInteraction } from "discord.js";
3+
import {
4+
ApplicationIntegrationType,
5+
ChannelType,
6+
GuildMember,
7+
InteractionContextType,
8+
MessageFlags,
9+
type CommandInteraction,
10+
} from "discord.js";
411
import { PermissionFlagsBits } from "discord-api-types/v8";
512

613
import checkIfChannelIdIsValid from "./utils/youtube/checkIfChannelIdIsValid";
@@ -28,8 +35,8 @@ interface Command {
2835
options: any[];
2936
name: string;
3037
description: string;
31-
integration_types: number[];
32-
contexts: number[];
38+
integration_types: ApplicationIntegrationType[];
39+
contexts: InteractionContextType[];
3340
};
3441
execute: (interaction: CommandInteraction) => Promise<void>;
3542
}
@@ -70,7 +77,7 @@ const commands: Record<string, Command> = {
7077

7178
await interaction
7279
.reply({
73-
ephemeral: true,
80+
flags: MessageFlags.Ephemeral,
7481
content: `Commands:\n${chat_commands?.join("\n")}`,
7582
})
7683
.catch(console.error);
@@ -87,7 +94,7 @@ const commands: Record<string, Command> = {
8794
execute: async (interaction: CommandInteraction) => {
8895
await interaction
8996
.reply({
90-
ephemeral: true,
97+
flags: MessageFlags.Ephemeral,
9198
content: `[Github repository](https://github.com/GalvinPython/feedr)`,
9299
})
93100
.catch(console.error);
@@ -174,7 +181,7 @@ const commands: Record<string, Command> = {
174181
description:
175182
"Enter the Guild channel to recieve updates in.",
176183
type: 7,
177-
required: true,
184+
required: false,
178185
},
179186
{
180187
name: "role",
@@ -187,22 +194,23 @@ const commands: Record<string, Command> = {
187194
description:
188195
"Track a channel to get notified when they upload a video!",
189196
integration_types: [0, 1],
190-
contexts: [0, 1],
197+
contexts: [0, 1, 2],
191198
},
192199
execute: async (interaction: CommandInteraction) => {
193200
// Get the YouTube Channel ID
194201
const targetPlatform = interaction.options.get("platform")
195202
?.value as string;
196203
const platformUserId = interaction.options.get("user_id")
197204
?.value as string;
198-
const discordChannelId = interaction.options.get("updates_channel")
199-
?.value as string;
205+
const discordChannelId =
206+
(interaction.options.get("updates_channel")?.value as string) ??
207+
interaction.channelId;
200208
const guildId = interaction.guildId;
201209

202210
// Checks if the platform is valid ig
203211
if (targetPlatform != "youtube" && targetPlatform != "twitch") {
204212
await interaction.reply({
205-
ephemeral: true,
213+
flags: MessageFlags.Ephemeral,
206214
content:
207215
"Platform not supported! Please select a platform to track!",
208216
});
@@ -213,7 +221,7 @@ const commands: Record<string, Command> = {
213221
// DMs are currently not supported, so throw back an error
214222
if (!guildId || interaction.channel?.isDMBased()) {
215223
await interaction.reply({
216-
ephemeral: true,
224+
flags: MessageFlags.Ephemeral,
217225
content:
218226
"This command is not supported in DMs currently!\nNot a DM? Then the bot failed to get the guild info",
219227
});
@@ -228,7 +236,7 @@ const commands: Record<string, Command> = {
228236
)
229237
) {
230238
await interaction.reply({
231-
ephemeral: true,
239+
flags: MessageFlags.Ephemeral,
232240
content:
233241
"You do not have the permission to manage channels!",
234242
});
@@ -281,15 +289,15 @@ const commands: Record<string, Command> = {
281289

282290
if (missingPermissions.length > 0) {
283291
await interaction.reply({
284-
ephemeral: true,
292+
flags: MessageFlags.Ephemeral,
285293
content: `The bot does not have the required permissions for the target channel! Missing permissions: ${missingPermissions.join(", ")}`,
286294
});
287295

288296
return;
289297
}
290298
} else {
291299
await interaction.reply({
292-
ephemeral: true,
300+
flags: MessageFlags.Ephemeral,
293301
content: "The target channel is not a text channel!",
294302
});
295303

@@ -304,7 +312,7 @@ const commands: Record<string, Command> = {
304312
!platformUserId.startsWith("UC")
305313
) {
306314
await interaction.reply({
307-
ephemeral: true,
315+
flags: MessageFlags.Ephemeral,
308316
content:
309317
'Invalid YouTube channel ID format! Each channel ID should be 24 characters long and start with "UC". Handles are currently not supported. Need to find the channel ID? We have a guide here: https://github.com/GalvinPython/feedr/wiki/Guide:-How-to-get-the-YouTube-Channel-ID',
310318
});
@@ -315,7 +323,7 @@ const commands: Record<string, Command> = {
315323
// Check if the channel is valid
316324
if (!(await checkIfChannelIdIsValid(platformUserId))) {
317325
await interaction.reply({
318-
ephemeral: true,
326+
flags: MessageFlags.Ephemeral,
319327
content: "That channel doesn't exist!",
320328
});
321329

@@ -330,7 +338,7 @@ const commands: Record<string, Command> = {
330338
)
331339
) {
332340
await interaction.reply({
333-
ephemeral: true,
341+
flags: MessageFlags.Ephemeral,
334342
content: "This channel is already being tracked!",
335343
});
336344

@@ -343,7 +351,7 @@ const commands: Record<string, Command> = {
343351
) {
344352
if (!(await addNewChannelToTrack(platformUserId))) {
345353
await interaction.reply({
346-
ephemeral: true,
354+
flags: MessageFlags.Ephemeral,
347355
content:
348356
"An error occurred while trying to add the channel to track! This is a new channel being tracked globally, please report this error!",
349357
});
@@ -366,12 +374,12 @@ const commands: Record<string, Command> = {
366374
await getChannelDetails(platformUserId);
367375

368376
await interaction.reply({
369-
ephemeral: true,
377+
flags: MessageFlags.Ephemeral,
370378
content: `Started tracking the channel ${youtubeChannelInfo?.channelName ?? platformUserId} in ${targetChannel.name}!`,
371379
});
372380
} else {
373381
await interaction.reply({
374-
ephemeral: true,
382+
flags: MessageFlags.Ephemeral,
375383
content:
376384
"An error occurred while trying to add the guild to track the channel! Please report this error!",
377385
});
@@ -384,7 +392,7 @@ const commands: Record<string, Command> = {
384392

385393
if (!streamerId) {
386394
await interaction.reply({
387-
ephemeral: true,
395+
flags: MessageFlags.Ephemeral,
388396
content: "That streamer doesn't exist!",
389397
});
390398

@@ -399,7 +407,7 @@ const commands: Record<string, Command> = {
399407
)
400408
) {
401409
await interaction.reply({
402-
ephemeral: true,
410+
flags: MessageFlags.Ephemeral,
403411
content: "This streamer is already being tracked!",
404412
});
405413

@@ -421,7 +429,7 @@ const commands: Record<string, Command> = {
421429
))
422430
) {
423431
await interaction.reply({
424-
ephemeral: true,
432+
flags: MessageFlags.Ephemeral,
425433
content:
426434
"An error occurred while trying to add the streamer to track! This is a new streamer being tracked globally, please report this error!",
427435
});
@@ -441,12 +449,12 @@ const commands: Record<string, Command> = {
441449
)
442450
) {
443451
await interaction.reply({
444-
ephemeral: true,
452+
flags: MessageFlags.Ephemeral,
445453
content: `Started tracking the streamer ${platformUserId} (${streamerId}) in ${targetChannel.name}!`,
446454
});
447455
} else {
448456
await interaction.reply({
449-
ephemeral: true,
457+
flags: MessageFlags.Ephemeral,
450458
content:
451459
"An error occurred while trying to add the guild to track the streamer! Please report this error!",
452460
});
@@ -502,7 +510,7 @@ const commands: Record<string, Command> = {
502510
// DMs are currently not supported, so throw back an error
503511
if (!guildId || interaction.channel?.isDMBased()) {
504512
await interaction.reply({
505-
ephemeral: true,
513+
flags: MessageFlags.Ephemeral,
506514
content:
507515
"This command is not supported in DMs currently!\nNot a DM? Then an error has occurred :(",
508516
});
@@ -517,7 +525,7 @@ const commands: Record<string, Command> = {
517525
)
518526
) {
519527
await interaction.reply({
520-
ephemeral: true,
528+
flags: MessageFlags.Ephemeral,
521529
content:
522530
"You do not have the permission to manage channels!",
523531
});
@@ -528,7 +536,7 @@ const commands: Record<string, Command> = {
528536
// Platform check (to shut up TS)
529537
if (platform != "youtube" && platform != "twitch") {
530538
await interaction.reply({
531-
ephemeral: true,
539+
flags: MessageFlags.Ephemeral,
532540
content:
533541
"Platform not supported! Please select a platform to track!",
534542
});
@@ -547,7 +555,7 @@ const commands: Record<string, Command> = {
547555
))
548556
) {
549557
await interaction.reply({
550-
ephemeral: true,
558+
flags: MessageFlags.Ephemeral,
551559
content:
552560
"This channel is not being tracked in this guild!",
553561
});
@@ -561,13 +569,13 @@ const commands: Record<string, Command> = {
561569
)
562570
) {
563571
await interaction.reply({
564-
ephemeral: true,
572+
flags: MessageFlags.Ephemeral,
565573
content:
566574
"Successfully stopped tracking the channel!",
567575
});
568576
} else {
569577
await interaction.reply({
570-
ephemeral: true,
578+
flags: MessageFlags.Ephemeral,
571579
content:
572580
"An error occurred while trying to stop tracking the channel! Please report this error!",
573581
});
@@ -580,7 +588,7 @@ const commands: Record<string, Command> = {
580588

581589
if (!streamerId) {
582590
await interaction.reply({
583-
ephemeral: true,
591+
flags: MessageFlags.Ephemeral,
584592
content:
585593
"An error occurred while trying to get the streamer ID! Please report this error!",
586594
});
@@ -596,7 +604,7 @@ const commands: Record<string, Command> = {
596604
))
597605
) {
598606
await interaction.reply({
599-
ephemeral: true,
607+
flags: MessageFlags.Ephemeral,
600608
content:
601609
"This streamer is not being tracked in this guild!",
602610
});
@@ -611,13 +619,13 @@ const commands: Record<string, Command> = {
611619
)
612620
) {
613621
await interaction.reply({
614-
ephemeral: true,
622+
flags: MessageFlags.Ephemeral,
615623
content:
616624
"Successfully stopped tracking the streamer!",
617625
});
618626
} else {
619627
await interaction.reply({
620-
ephemeral: true,
628+
flags: MessageFlags.Ephemeral,
621629
content:
622630
"An error occurred while trying to stop tracking the streamer! Please report this error!",
623631
});
@@ -644,7 +652,7 @@ const commands: Record<string, Command> = {
644652

645653
if (!guildId || !channelId) {
646654
await interaction.reply({
647-
ephemeral: true,
655+
flags: MessageFlags.Ephemeral,
648656
content:
649657
"You are likely in a DM, this command is not supported in DMs!",
650658
});
@@ -656,7 +664,7 @@ const commands: Record<string, Command> = {
656664

657665
if (trackedChannels.length === 0) {
658666
await interaction.reply({
659-
ephemeral: true,
667+
flags: MessageFlags.Ephemeral,
660668
content: "No channels are being tracked in this guild.",
661669
});
662670

@@ -673,7 +681,7 @@ const commands: Record<string, Command> = {
673681

674682
// idk what is happening here anymore, but this is because eslint and prettier are fighting so i put them to rest by using only one line
675683
await interaction.reply({
676-
ephemeral: true,
684+
flags: MessageFlags.Ephemeral,
677685
content: `
678686
## Tracked channels in this channel (<#${channelId}>):\n${filteredChannels.length ? filteredChannels.map((channel) => `Platform: ${channel.guild_platform} | User ID: ${channel.platform_user_id}`).join("\n") : "No channels are being tracked in this channel."}
679687

src/types/types.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/utils/logging.ts

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
1-
import type { Platforms } from "../types/types";
2-
3-
export async function logMessage(
4-
platform: Platforms,
5-
channelName: string,
6-
channelId: string,
7-
guildName: string,
8-
guildId: string,
9-
) {
10-
const platformEmojis: { [key in Platforms]: string } = {
11-
YouTube: "❤️",
12-
Twitch: "💜",
13-
};
14-
15-
const actionMessages: { [key in Platforms]: string } = {
16-
YouTube: "upload",
17-
Twitch: "live",
18-
};
19-
20-
console.log(
21-
`${platformEmojis[platform]} [${platform}] Sent ${actionMessages[platform]} message to ${guildName} (${guildId}) for channel ${channelName} (${channelId})`,
22-
);
1+
export async function logMessage() {
2+
return null;
233
}

0 commit comments

Comments
 (0)