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

Custom auto-tagging #303

Merged
merged 2 commits into from
Apr 11, 2024
Merged
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
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(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const matchingChannel = CUSTOM_CHANNEL_ROLE.find(
const matchingChannelOverride = 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
Loading