Skip to content

Commit

Permalink
Resolve review comments
Browse files Browse the repository at this point in the history
- Removes list of permissions sent to channel
- Changes defense to load from specific channel id. You must setup env `DEFENSE_CATEGORY_ID` to have it function correctly.
- Merges into one function
  • Loading branch information
zuuring committed Mar 11, 2024
1 parent 25d0059 commit c159b92
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 46 deletions.
46 changes: 0 additions & 46 deletions discord-scripts/channel-management.ts

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) {
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.",
)
}
}
})
}
}
}

0 comments on commit c159b92

Please sign in to comment.