generated from nhcarrigan/template
feat: send onboarding message when mentorship role granted
Node.js CI / Lint and Test (push) Successful in 46s
Node.js CI / Lint and Test (push) Successful in 46s
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
export const ids = {
|
||||
channels: {
|
||||
formSubmissions: "1410435042898874471",
|
||||
menteeChat: "1400589073613062204",
|
||||
mentorshipGoalForum: "1400629118110011526",
|
||||
mentorshipProjectForum: "1400616702265266186",
|
||||
naomiDiscussionForum: "1408154690121633917",
|
||||
@@ -17,6 +18,7 @@ export const ids = {
|
||||
nhcarrigan: "1354624415861833870",
|
||||
},
|
||||
roles: {
|
||||
mentorship: "1400588705273745550",
|
||||
nhcarrigan: "1355033209037127771",
|
||||
representing: "1407861842847469598",
|
||||
},
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
postFreeCodeCampNews,
|
||||
postHackerNews,
|
||||
} from "./modules/postNews.js";
|
||||
import { processMentorshipRole } from "./modules/processMentorshipRole.js";
|
||||
import { processUserGuildTag } from "./modules/processUserGuildTag.js";
|
||||
import { respondToDm } from "./modules/respondToDm.js";
|
||||
import { instantiateServer } from "./server/serve.js";
|
||||
@@ -102,5 +103,9 @@ amari.discord.on(Events.UserUpdate, (_oldUser, updatedUser) => {
|
||||
void processUserGuildTag(amari, updatedUser);
|
||||
});
|
||||
|
||||
amari.discord.on(Events.GuildMemberUpdate, (oldMember, updatedMember) => {
|
||||
void processMentorshipRole(amari, oldMember, updatedMember);
|
||||
});
|
||||
|
||||
await amari.discord.login(process.env.BOT_TOKEN);
|
||||
instantiateServer(amari);
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @copyright NHCarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
|
||||
import { ids } from "../config/ids.js";
|
||||
import { logger } from "../utils/logger.js";
|
||||
import type { Amari } from "../interfaces/amari.js";
|
||||
import type { GuildMember, PartialGuildMember } from "discord.js";
|
||||
|
||||
/**
|
||||
* Handles the guild member update. If a member has
|
||||
* been granted the mentorship role, send them an
|
||||
* onboarding message.
|
||||
* @param amari - Amari's instance.
|
||||
* @param oldMember - The cached member record.
|
||||
* @param updatedMember - The updated member payload from Discord.
|
||||
*/
|
||||
export const processMentorshipRole = async(
|
||||
amari: Amari,
|
||||
oldMember: GuildMember | PartialGuildMember,
|
||||
updatedMember: GuildMember,
|
||||
): Promise<void> => {
|
||||
if (oldMember.roles.cache.has(ids.roles.mentorship)
|
||||
|| !updatedMember.roles.cache.has(ids.roles.mentorship)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const channel = amari.discord.channels.cache.get(ids.channels.menteeChat)
|
||||
?? await amari.discord.channels.fetch(ids.channels.menteeChat);
|
||||
|
||||
if (channel?.isSendable() !== true) {
|
||||
await logger.log(
|
||||
"warn",
|
||||
"Mentee Chat channel does not exist or is not sendable.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
await channel.send({
|
||||
content: `Hey <@${updatedMember.id}>~!
|
||||
|
||||
Welcome to our mentorship programme! We are excited to have you here and help you grow and reach success.
|
||||
|
||||
To get started, please make sure you have accepted the GitHub invite for your dedicated repository under the [NHCarrigan Mentorship organsation](<https://github.com/nhcarrigan-mentorship>).
|
||||
|
||||
Once you have done this, your next step is to read our [wiki](<https://nhcarrigan.notion.site/mentorship-wiki>). Then, create your post in <#1400629118110011526> as outlined in the wiki.
|
||||
|
||||
Naomi will follow up with you from there! Best of luck on your journey~! <a:love:1364089736557494353>`,
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user