Skip to content

Commit 72b01ba

Browse files
authored
Merge pull request #15 from clairefro/discord-spam-block
Add Discord spam link protection
2 parents ecea5a6 + b4a9a2a commit 72b01ba

19 files changed

+1255
-458
lines changed

.github/workflows/docker-image.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
name: Docker Image CI
22

33
on:
4-
push:
5-
branches: [ main ]
6-
pull_request:
7-
branches: [ main ]
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
88

99
jobs:
10+
build:
11+
runs-on: ubuntu-latest
1012

11-
build:
12-
13-
runs-on: ubuntu-latest
14-
15-
steps:
16-
- uses: actions/checkout@v2
17-
- name: Build the Docker image
18-
run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Build the Docker image
16+
run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
node_modules
22
.env
33
dist
4-
src/commands/bing-translate-api
4+
*.log

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

.prettierrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"trailingComma": "none",
3+
"tabWidth": 4,
4+
"semi": true,
5+
"singleQuote": false
6+
}

README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
<p align="center">
55
<b>This is the main repository of the Postman Student Helper Discord Bot. </b>
66
</p>
7-
</p>
7+
</p>
88

99
## About :
1010

1111
Postman Student Helper is a Discord Bot developed by Postman Student Leaders. It's main aims are to help make the Postman Student Community Discord a better place by using moderation and fun commands !
1212

1313
## Note to all developers
14+
1415
Be sure to not commit directly to the main. Happy coding !
1516

1617
## Prerequisites
@@ -39,23 +40,24 @@ Be sure to not commit directly to the main. Happy coding !
3940
### Setting Up The Application
4041

4142
1. Clone the project with `git clone` and `cd` into it
42-
2. change the name of `.sampledotenv` to `.env`
43-
3. Get your secret key from [Discord Developer Portal](https://discord.com/developers/applications) and put it in the `.env`
44-
4. Run `yarn install` or `npm install`
45-
5. At `node_modules\bing-translate-api\src\index.js (line 128)` add `.toString().`before the `.trim().`
46-
6. You are good to go! Now you can start the project by typing `yarn start` or `npm start` to your command line
43+
1. Copy the env vars: `cp .sampledotenv .env`
44+
1. Get your secret key from [Discord Developer Portal](https://discord.com/developers/applications) (make a bot for your app) and put it in the `.env` file as the value for `DISCORD_TOKEN`
45+
1. Run `yarn install`
46+
1. You are good to go! Now you can start the project by typing `yarn dev`
4747

4848
## Commands
4949

5050
#### Active Commands
51-
- `!p translate <text>` -> Translate a message from another language to English
52-
- `!p help`-> Displays all commands
53-
- `!p programs` -> List all programs
54-
- `!p meme` -> Send a coding meme from Reddit
51+
52+
- `!p translate <text>` -> Translate a message from another language to English
53+
- `!p help`-> Displays all commands
54+
- `!p programs` -> List all programs
55+
- `!p meme` -> Send a coding meme from Reddit
5556

5657
#### Silent Commands
57-
- `Scam Detection` -> Every message is scanned for scams
58-
- `Non Gender Netural Words Detection` -> Every message is scanned for words like 'guys', 'dude', 'bro', etc..
58+
59+
- `Scam Detection` -> Every message is scanned for scams
60+
- `Non Gender Netural Words Detection` -> Every message is scanned for words like 'guys', 'dude', 'bro', etc..
5961

6062
## Contributors :
6163

docker-compose.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
version: "3"
2-
services:
3-
psh-service:
4-
build: .
5-
restart: on-failure
2+
services:
3+
psh-service:
4+
build: .
5+
restart: on-failure

nodemon.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"watch": ["src"],
3+
"ext": "ts,json",
4+
"ignore": ["src/**/*.spec.ts"],
5+
"exec": "ts-node ./src/server.ts"
6+
}

package.json

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
{
2-
"name": "postman-student-helper",
3-
"version": "1.0.0",
4-
"description": "",
5-
"main": "src/server.ts",
6-
"scripts": {
7-
"start": "tsc -p tsconfig.json && ts-node src/server.ts",
8-
"build": "tsc -p tsconfig.json"
9-
},
10-
"keywords": [],
11-
"author": "Çetin Kaan Taşkıngenç",
12-
"license": "ISC",
13-
"dependencies": {
14-
"bing-translate-api": "^2.2.1",
15-
"discord.js": "^12.5.3",
16-
"dotenv": "^10.0.0",
17-
"memejs": "^1.2.3"
18-
},
19-
"devDependencies": {
20-
"@types/node": "^16.11.4",
21-
"ts-node": "^10.3.0",
22-
"typescript": "^4.4.4"
23-
}
2+
"name": "postman-student-helper",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "src/server.ts",
6+
"scripts": {
7+
"dev": "nodemon",
8+
"start": "ts-node src/server.ts",
9+
"build": "tsc",
10+
"format": "prettier --write ."
11+
},
12+
"keywords": [],
13+
"author": "Çetin Kaan Taşkıngenç",
14+
"license": "ISC",
15+
"dependencies": {
16+
"bing-translate-api": "^2.2.1",
17+
"discord.js": "^12.5.3",
18+
"dotenv": "^10.0.0",
19+
"fastest-levenshtein": "^1.0.12",
20+
"memejs": "^1.2.3"
21+
},
22+
"devDependencies": {
23+
"@types/node": "^16.11.4",
24+
"nodemon": "^2.0.15",
25+
"prettier": "^2.5.1",
26+
"ts-node": "^10.3.0",
27+
"typescript": "^4.4.4"
28+
}
2429
}

src/commands/GenderNeutralTerms.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
module.exports = {
1+
export = {
22
name: "GenderNeutralTerms",
33
description: "Warns users to use gender netural terms",
4-
run: (message :any, Discord :any) => {
5-
4+
run: (message: any, Discord: any) => {
65
const currMsg = message.content.toLowerCase().split(" ");
7-
8-
if (currMsg.includes("guys") || currMsg.includes("bro") || currMsg.includes("dude")) {
96

7+
if (
8+
currMsg.includes("guys") ||
9+
currMsg.includes("bro") ||
10+
currMsg.includes("dude")
11+
) {
1012
const msg = new Discord.MessageEmbed()
11-
.setColor('#c7651a')
12-
.setTitle('Please Try To Use Gender Neutral Terms ☺️')
13-
.setURL('https://github.com/ctnkaan/Postman-Student-Helper')
14-
.setAuthor(
15-
'Postman Student Helper',
16-
'https://i.imgur.com/ElCDWZb.png',
17-
'https://github.com/ctnkaan/Postman-Student-Helper'
18-
)
19-
.addFields(
20-
{
13+
.setColor("#c7651a")
14+
.setTitle("Please Try To Use Gender Neutral Terms ☺️")
15+
.setURL("https://github.com/ctnkaan/Postman-Student-Helper")
16+
.setAuthor(
17+
"Postman Student Helper",
18+
"https://i.imgur.com/ElCDWZb.png",
19+
"https://github.com/ctnkaan/Postman-Student-Helper"
20+
)
21+
.addFields({
2122
name: "Hi there! Please try to use gender netural terms :)",
2223
value: "You can use words such as 'person', 'friend', 'pal', 'folks', 'individual' insted of of words like 'guys', 'bro', 'dude', etc..."
23-
}
24-
)
25-
.setTimestamp()
26-
.setFooter(
27-
'type "!p help" for more info!',
28-
'https://i.imgur.com/ElCDWZb.png'
29-
);
30-
message.author.send(msg)
24+
})
25+
.setTimestamp()
26+
.setFooter(
27+
'type "!p help" for more info!',
28+
"https://i.imgur.com/ElCDWZb.png"
29+
);
30+
message.author.send(msg);
3131
}
3232
}
33-
}
33+
};

src/commands/help.ts

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,39 @@
1-
const Programs = require('./programs');
2-
const Translate = require('./translate');
3-
const Meme = require('./meme');
1+
import Programs from "./programs";
2+
import Translate from "./translate";
3+
import Meme from "./meme";
44

5-
module.exports = {
5+
export = {
66
name: "help",
77
description: "Displays all commands",
8-
run(message :any, Discord :any) {
9-
8+
run(message: any, Discord: any) {
109
const msg = new Discord.MessageEmbed()
11-
.setColor('#c7651a')
12-
.setTitle('Commands')
13-
.setURL('https://github.com/ctnkaan/Postman-Student-Helper')
14-
.setAuthor(
15-
'Postman Student Helper',
16-
'https://i.imgur.com/ElCDWZb.png',
17-
'https://github.com/ctnkaan/Postman-Student-Helper'
18-
)
19-
.addFields(
20-
{
21-
name: "!p " + Programs.name,
22-
value: Programs.description,
23-
},
24-
{
25-
name: "!p " + Translate.name + " <text>",
26-
value: Translate.description,
27-
},
28-
{
29-
name: "!p " + Meme.name,
30-
value: Meme.description,
31-
}
32-
)
33-
.setTimestamp()
34-
.setFooter(
35-
'type "!p help" for more info!',
36-
'https://i.imgur.com/ElCDWZb.png'
37-
);
38-
message.channel.send(msg)
10+
.setColor("#c7651a")
11+
.setTitle("Commands")
12+
.setURL("https://github.com/ctnkaan/Postman-Student-Helper")
13+
.setAuthor(
14+
"Postman Student Helper",
15+
"https://i.imgur.com/ElCDWZb.png",
16+
"https://github.com/ctnkaan/Postman-Student-Helper"
17+
)
18+
.addFields(
19+
{
20+
name: "!p " + Programs.name,
21+
value: Programs.description
22+
},
23+
{
24+
name: "!p " + Translate.name + " <text>",
25+
value: Translate.description
26+
},
27+
{
28+
name: "!p " + Meme.name,
29+
value: Meme.description
30+
}
31+
)
32+
.setTimestamp()
33+
.setFooter(
34+
'type "!p help" for more info!',
35+
"https://i.imgur.com/ElCDWZb.png"
36+
);
37+
message.channel.send(msg);
3938
}
40-
}
39+
};

0 commit comments

Comments
 (0)