-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #414 from uwcsc/388-ping-office
DM "Office Ping" users when office is open
- Loading branch information
Showing
9 changed files
with
129 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { User } from 'discord.js'; | ||
import { loadRoleUsers } from '../utils/roles'; | ||
import { vars } from '../config'; | ||
import { sendMessage } from '../utils/dm'; | ||
|
||
const OFFICE_PING_ROLE_ID: string = vars.OFFICE_PING_ROLE_ID; | ||
|
||
/* alertUsers | ||
* loads all the users that have the "Office Ping" role using roles.ts in utils | ||
* and sends them a message using sendMessage from dm.ts | ||
*/ | ||
export const alertUsers = async (): Promise<void> => { | ||
const users: User[] = await loadRoleUsers(OFFICE_PING_ROLE_ID); | ||
|
||
users.forEach(async (user) => { | ||
await sendMessage(user, 'The office is now open!'); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { User } from 'discord.js'; | ||
import { logger } from '../logger/default'; | ||
|
||
export const sendMessage = async (discordUser: User, message: string): Promise<void> => { | ||
try { | ||
await discordUser.send(message); | ||
} catch (err) { | ||
logger.error({ | ||
event: 'client_error', | ||
where: 'dm sendMessage', | ||
}); | ||
logger.error(err); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters