Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions src/v2/commands/repel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ export const repelInteraction: CommandDataWithHandler = {
RepelCommandOptions.TARGET,
false,
)?.user as User;
console.log('Target User:', targetUser);

let targetGuildMember: GuildMember | null = null;
let userNotInServer = false;
Expand Down Expand Up @@ -236,11 +235,22 @@ export const repelInteraction: CommandDataWithHandler = {
false,
) ?? REPEL_DEFAULT_DELETE_COUNT;
let deletedCount = 0;
const textChannels = interaction.guild.channels.cache.filter(
ch => ch.type === ChannelType.GuildText,
);
const textChannels = interaction.guild.channels.cache
.filter(
(ch): ch is TextChannel =>
(ch.type === ChannelType.GuildText ||
ch.type === ChannelType.GuildVoice) &&
ch.id !== interaction.channelId &&
Boolean(ch.lastMessageId),
)
.sort((a, b) => {
const aLastMessage = a.lastMessageId ? BigInt(a.lastMessageId) : 0n;
const bLastMessage = b.lastMessageId ? BigInt(b.lastMessageId) : 0n;
return Number(bLastMessage - aLastMessage);
})
.first(50);

for (const [, channel] of textChannels) {
for (const channel of [interaction.channel, ...textChannels]) {
if (deletedCount >= messagesToDelete) break;

try {
Expand Down Expand Up @@ -289,10 +299,15 @@ export const repelInteraction: CommandDataWithHandler = {
});
}

const channelInfo =
interaction.channel?.type === ChannelType.GuildVoice
? `**${interaction.channel.name}** voice chat`
: `<#${interaction.channelId}>`;

const embed = new EmbedBuilder()
.setTitle('Repel Action')
.setDescription(
`<@${targetId}> has been repelled by <@${member.id}> in <#${interaction.channelId}>.`,
`<@${targetId}> has been repelled by <@${member.id}> in ${channelInfo}.`,
)
.addFields(
{
Expand Down
Loading