Skip to content

Commit 16379f3

Browse files
committed
improved readme. graceful shutdown. improved default channel detection
1 parent 43c9bb4 commit 16379f3

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
![In servers](https://badgen.net/https/discord-bot.cryptojobslist.com/badgen/servers?icon=discord) ![Current audience across all servers](https://badgen.net/https/discord-bot.cryptojobslist.com/badgen/members?icon=discord)
22

33
# 💼 Receive latest Crypto & Web3 Jobs in your Discord
4-
> Help your community afford your NFTs by getting them a job! Add [this bot](https://discord.com/oauth2/authorize?client_id=458880791573954570&permissions=2147485696&scope=bot) to your Discord for the best jobs in crypto & web3.
4+
> Help your community afford your NFTs by getting them a job! Add [this bot](https://discord.com/oauth2/authorize?client_id=458880791573954570&permissions=2147485696&scope=bot) to your Discord for latest jobs from the top companies in crypto & web3.
55
66
1. 🤖 [Add to Discord](https://discordapp.com/api/oauth2/authorize?client_id=458880791573954570&permissions=2147485696&scope=bot)
7-
2. 💬 **Give it Messaging Permissions** in one of your channels. ⚠️ It won't work otherwise!
8-
3. 👉 Run `/set-channel #channel-name` to tell the bot which channel it should send jobs to.
9-
4. ✅ Done! Confirmation should look like this:
7+
2. #️⃣ Create a new channel for job notifications. Example: `#crypto-jobs-list`
8+
3. 💬 Give our bot **Messaging Permissions** in your channel. Otherwise the bot won't work! ⚠️
9+
4. 👉 Run `/set-channel #channel-name` to tell the bot which channel it should send jobs to
10+
5. ✅ Done! Confirmation should look like this:
1011

11-
<img width="382" alt="image" src="https://user-images.githubusercontent.com/936436/187341582-1db2b2d1-3bd7-482e-a15b-204e3252f13a.png">
12+
<img width="468" alt="Crypto Jobs List Discord Bot" src="https://user-images.githubusercontent.com/936436/187341582-1db2b2d1-3bd7-482e-a15b-204e3252f13a.png">
1213

13-
<img width="468" alt="image" src="https://user-images.githubusercontent.com/936436/187341614-dfe83f86-b444-495e-a49b-7ad7e8b8a13c.png">
14+
<img width="468" alt="Crypto Jobs List Discord Bot" src="https://user-images.githubusercontent.com/936436/187341614-dfe83f86-b444-495e-a49b-7ad7e8b8a13c.png">
1415

15-
![2022-08-30 11-24-02 2022-08-30 11_27_13](https://user-images.githubusercontent.com/936436/187342403-c1f015b3-ff08-4f22-8b1a-86b8b080cfc2.gif)
16+
## Here is the /set-channel process:
17+
<img width="700" alt="Crypto Jobs List Discord Bot" src="https://user-images.githubusercontent.com/936436/187342403-c1f015b3-ff08-4f22-8b1a-86b8b080cfc2.gif">
1618

1719

18-
## What it looks like:
20+
# What it looks like:
1921

20-
![Screenshot 2022-07-07 at 9 29 26 PM](https://user-images.githubusercontent.com/936436/177785495-e231602e-c4b2-41a1-b5fe-e9de68428576.png)
22+
<img width="800" alt="Crypto Jobs List Discord Bot" src="https://user-images.githubusercontent.com/936436/177785495-e231602e-c4b2-41a1-b5fe-e9de68428576.png">
2123

2224

2325
## Features
@@ -36,8 +38,8 @@
3638

3739
## Security
3840
- This bot can only Send Messages.
39-
- This bot only sends messaged in the format depicted in the screenshot above.
40-
- This bot **can't** do anything else: can't read messaged, can't manage channels, etc. It can't even read it's own messages.
41-
- It's open source. When in doubt — read the code, ask questions, leave comments offer suggestions.
41+
- This bot can only send job notifications and only in the format shown in the screenshot above.
42+
- This bot **can't** do anything else: can't read messages, can't manage channels, can't send spam, etc. It can't even read it's own messages!
43+
- It's open source. If in doubt — read the code, ask questions, leave comments, suggest improvements.
4244

4345
<img width="426" alt="image" src="https://user-images.githubusercontent.com/936436/187343520-7d6374d6-f8b6-4679-a3b7-c4f2498e5cd3.png">

components/getDefaultChannel.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ export default function (guild: Guild): TextChannel {
99
)
1010
.sort((a: any, b: any) => a.rawPosition - b.rawPosition || a.id - b.id)
1111

12+
const guessJobsChannel = ChannelsWithPermissions.find(c => {
13+
return /job|career|work|opportunit/gi.test(c.name)
14+
}) as TextChannel
15+
1216
const generalOrWelcome = ChannelsWithPermissions.find(c => {
13-
return /general|welcome|jobs|job|career|work/gi.test(c.name)
17+
return /general|welcome/gi.test(c.name)
1418
}) as TextChannel
1519

16-
return generalOrWelcome || ChannelsWithPermissions.first()
20+
return guessJobsChannel || generalOrWelcome || ChannelsWithPermissions.first()
1721
}

index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ export default async function main() {
112112
app.all('/channels', async (req, res) => guildsTable(req, res, client))
113113
app.all('/badgen/:type', async (req, res) => badgeN(req, res, client))
114114

115-
app.listen(PORT, () => console.log(`Server started on ${PORT}.`))
115+
const server = app.listen(PORT, () => console.log(`Server started on ${PORT}.`))
116+
117+
const graceFullShutDown = () => server.close(() => console.warn('HTTP server closed'))
118+
process.on('SIGTERM', graceFullShutDown)
119+
process.on('SIGINT', graceFullShutDown)
116120
} catch (err) {
117121
console.error(`Couldn't start`, err)
118122
return undefined

0 commit comments

Comments
 (0)