Skip to content

Commit

Permalink
Custom auto-tagging (#303)
Browse files Browse the repository at this point in the history
### Notes
This adds the ability to modify the auto-tagging function of Valkyrie
based off of a defined list of `PRIVATE_CHANNELS`. It also will match
the tagging to the role specified, in order to have custom roles tagged
for specific threads started in a channel.

### Handling IDs
Alternatively, we can also modify this to work directly with channel /
role IDs rather than names, but in testing it seems to be working as it
should.
  • Loading branch information
Shadowfiend authored Apr 11, 2024
2 parents 15a23ec + 03a82f5 commit 527f288
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions discord-scripts/thread-management/auto-join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import {
// Quiet tags are achieved by dropping a placeholder message and then editing
// it to mention the right role. Discord's behavior in this scenario is not to
// ping the role, but to add all its members to the thread.

const CUSTOM_CHANNEL_ROLE = [{ channelName: "hiring", roleName: "PeopleOps" }]

async function autoJoinThread(
thread: AnyThreadChannel<boolean>,
): Promise<void> {
Expand All @@ -35,6 +38,21 @@ async function autoJoinThread(

const placeholder = await thread.send("<placeholder>")

// Use this to assign a specific role based on the mapping in CUSTOM_CHANNEL_ROLE, in order to map specific roles/channels
const matchingChannel = CUSTOM_CHANNEL_ROLE.find(
(channel) => containingChannel?.name.endsWith(channel.channelName),
)
if (matchingChannel) {
const channelMatchingRole = server.roles.cache.find(
(role) =>
role.name.toLowerCase() === matchingChannel.roleName.toLowerCase(),
)
if (channelMatchingRole) {
await placeholder.edit(channelMatchingRole.toString())
return
}
}

const matchingRole = server.roles.cache.find(
(role) => role.name.toLowerCase() === containingChannel?.name.toLowerCase(),
)
Expand Down

0 comments on commit 527f288

Please sign in to comment.