Skip to content

Commit

Permalink
feat: allow private channels to be shown
Browse files Browse the repository at this point in the history
  • Loading branch information
ImLunaHey committed May 4, 2023
1 parent fa2f613 commit 569dd07
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/features/stats/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ export class Feature {
})
async stats(
@SlashOption({
name: 'private',
name: 'ephemeral',
description: 'Reply with a private message?',
required: false,
type: ApplicationCommandOptionType.Boolean,
Expand All @@ -379,6 +379,12 @@ export class Feature {
required: false,
type: ApplicationCommandOptionType.Boolean,
}) showOldestMembers = false,
@SlashOption({
name: 'private-channels',
description: 'Show non-public channels?',
required: false,
type: ApplicationCommandOptionType.Boolean,
}) privateChannels = false,
interaction: CommandInteraction,
) {
// Only run in guilds
Expand All @@ -399,8 +405,15 @@ export class Feature {
.where('guildId', '=', interaction.guild.id)
.groupBy('channelId')
.orderBy('totalCount', 'desc')
.limit(10)
.execute()
.then(channels => {
// Show all channels
// Official client: Users will only see the names of channels they have access to
// Unofficial client: Anyone will see the names of the channels 👀
// NOTE: Because of this, we do not consider these IDs to be private information
if (privateChannels) return channels;

// Only show public channels
return channels.filter(channel => {
const isPublic = interaction.guild?.channels.resolve(channel.channelId)?.permissionsFor(interaction.guild.id)?.has('ViewChannel');
Expand All @@ -425,6 +438,7 @@ export class Feature {
.where('guildId', '=', interaction.guild.id)
.groupBy('memberId')
.orderBy('totalCount', 'desc')
.limit(10)
.execute();

embeds.push({
Expand Down

0 comments on commit 569dd07

Please sign in to comment.