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 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
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.",
)
}
}
})
}
}
}
14 changes: 5 additions & 9 deletions infrastructure/kube/thesis-ops/valkyrie-hubot-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
Loading