Skip to content

Commit 4686ad1

Browse files
authored
fix: add current repel channel (#966)
* fix: add current repel channel * Update index.ts
1 parent 518e9d6 commit 4686ad1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/v2/commands/repel/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,17 @@ const getTargetFromInteraction = async (
9898
return target;
9999
};
100100

101-
const getTextChannels = (guild: Guild) => {
102-
return guild.channels.cache
101+
const getTextChannels = (interaction: ChatInputCommandInteraction) => {
102+
const channels = interaction.guild.channels.cache
103103
.filter(
104104
(ch): ch is TextChannel =>
105105
!IGNORED_CHANNEL_CATEGORIES.includes(ch.parentId) &&
106106
ch.type === ChannelType.GuildText &&
107+
interaction.channelId !== ch.id &&
107108
Boolean(ch.lastMessageId),
108109
)
109110
.values();
111+
return [interaction.channel as TextChannel, ...channels];
110112
};
111113

112114
const checkPermission = async ({
@@ -465,7 +467,7 @@ export const repelInteraction: CommandDataWithHandler = {
465467
RepelCommandOptions.DELETE_COUNT,
466468
false,
467469
) ?? REPEL_DEFAULT_DELETE_COUNT;
468-
const channels = getTextChannels(interaction.guild);
470+
const channels = getTextChannels(interaction);
469471
const deleted = await handleDeleteMessages({
470472
channels,
471473
count,

0 commit comments

Comments
 (0)