diff --git a/discord-scripts/role-management.ts b/discord-scripts/role-management.ts new file mode 100644 index 00000000..6b39204f --- /dev/null +++ b/discord-scripts/role-management.ts @@ -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.", + ) + } + } + }) + } + } +} diff --git a/infrastructure/kube/thesis-ops/valkyrie-hubot-deployment.yaml b/infrastructure/kube/thesis-ops/valkyrie-hubot-deployment.yaml index a233cf7c..cf9659f2 100644 --- a/infrastructure/kube/thesis-ops/valkyrie-hubot-deployment.yaml +++ b/infrastructure/kube/thesis-ops/valkyrie-hubot-deployment.yaml @@ -23,15 +23,6 @@ spec: secretKeyRef: name: valkyrie-hubot key: discord_api_token - - name: HUBOT_MATRIX_USER - value: "@valkyrie:thesis.co" - - name: HUBOT_MATRIX_PASSWORD - valueFrom: - secretKeyRef: - name: valkyrie-hubot - key: matrix_valkyrie_password - - name: HUBOT_MATRIX_HOST_SERVER - value: "https://thesisco.ems.host" - name: HUBOT_HOST valueFrom: secretKeyRef: @@ -66,6 +57,11 @@ spec: key: valkyrie_alert_flow - name: REDIS_URL value: $(VALKYRIE_REDIS_SERVICE_PORT) + - name: DEFENSE_CATEGORY_ID + valueFrom: + secretKeyRef: + name: valkyrie-hubot + key: defense_category_id - name: GITHUB_CLIENT_ID valueFrom: secretKeyRef: