Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New channel permissions helper #293

Merged
merged 4 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
46 changes: 0 additions & 46 deletions discord-scripts/channel-management.ts
zuuring marked this conversation as resolved.
Outdated
Show resolved Hide resolved

This file was deleted.

28 changes: 28 additions & 0 deletions discord-scripts/role-management.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Client, TextChannel } from "discord.js"
import { Robot } from "hubot"

export default async function manageChannelPermissions(
discordClient: Client,
robot: Robot,
) {
const { application } = discordClient
if (process.env.DEFENSE_CATEGORY_ID) {
if (application) {
Comment on lines +9 to +10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to nest, these can combine into one.

discordClient.on("channelCreate", async (channel) => {
if (
channel.parent &&
channel.parentId === process.env.DEFENSE_CATEGORY_ID
) {
const permissions = channel.parent.permissionOverwrites.cache
await channel.permissionOverwrites.set(permissions)
robot.logger.info("Channel permissions set to base category")
if (channel instanceof TextChannel) {
await channel.send(
"This channel now has the same base permissions as the Defense category.",
)
}
}
})
}
}
}
Loading