-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add nickname change event for OOO #318
Conversation
### Notes This is the main working PR for building out the nickname changer as setup by a webhook call into Valkyrie. ### To-Do -[] Setup initial flow to map nickname -[] Map userID to matched nickname
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good, a few things we should do in terms of code quality/refactoring but nothing blocking. Let's ship and iterate 🚢
// WIP, output list of all members for matching | ||
guild.members.cache.forEach((member) => { | ||
robot.logger.info(`Username: ${member.user.username}`) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we drop those?
Also wondering if we need to start wrapping stuff in an environment check.
}) | ||
|
||
const matchedMember = guild.members.cache.find((member) => | ||
member.user.username.includes(username), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we be looking for a direct (case-insensitive) match here?
return matchedMember ? matchedMember.user.id : null | ||
} | ||
|
||
async function updateServerNickname( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't just about updating the server nickname since it does all the OOO stuff, right? Let's be very specific about what this function does in the name.
@@ -97,5 +154,37 @@ export default async function webhookDiscord( | |||
}, | |||
) | |||
robot.logger.info("Webhook is now enabled") | |||
|
|||
robot.router.post("/start-date", handleAuth, async (req, res) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should look at scoping this very specifically and making it a little more REST-like. Something like:
robot.router.post(`${webhookUrl}/user/:username/out-of-office`...
robot.router.delete(`${webhookUrl}/user/:username/out-of-office`...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I say this not remembering what webhookUrl
is. We should also probably scope the message poster webhook to /message
or similar.)
Notes
This is the main working PR for building out the nickname changer as setup by a webhook call into Valkyrie. It's hardcoded to have OOO, which we can also alter to pass rather than embed.
To-Do