Skip to content

Commit 7c4fea2

Browse files
author
TimeWaster
committed
removed Babel, added possibility to be run from a submodule directory
1 parent 32f7145 commit 7c4fea2

File tree

16 files changed

+136
-3536
lines changed

16 files changed

+136
-3536
lines changed

.babelrc

Lines changed: 0 additions & 5 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Changelog
2+
3+
## 1.1.0 (2021-05-25)
4+
5+
### Release Highlights
6+
7+
Added the possibility to include HomarusBot into an existing GIT project via GIT submodules, follow the instructions in [README.md](README.md).
8+
9+
### Features
10+
11+
- Added support to be run as a GIT submodule
12+
- Removed Babel due to configuration problems, this introduces a breaking change in imports/exports
13+
14+
### Bugfixes
15+
16+
- Removed unused code
17+
18+
## 1.0.0 (2021-05-23)
19+
20+
### Release Highlights
21+
22+
This is the initial release.
23+
24+
### Features
25+
26+
- Pattern matching engine based on the Discord.js "message" and "messageDelete" events
27+
28+
### Bugfixes
29+
30+
-

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,17 @@ cd /home/directory/you/want/HomarusBot
8484
npm update
8585
./start.sh
8686
```
87+
88+
## Including HomarusBot in your own GIT repository
89+
90+
It is possible to add HomarusBot to your GIT project without forking it, in a directory you see fit in your project run:
91+
92+
```bash
93+
git submodule add [email protected]:SebiTimeWaster/HomarusBot.git
94+
```
95+
96+
This adds HomarusBot as a subdirectory with its own .git configuration/namespace.
97+
98+
Now copy the `rules` directory and the `config.js` from the `HomarusBot` directory one directory above and start to change/use it, it is part of your repository.
99+
100+
You still need to run the `npm install` and other commands from the HomarusBot directory itself, but you can easily write scripts to do that for you.

config.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
// General configuration
2-
export default {
1+
const config = {
2+
// General configuration
33
botToken: '', // the discord bot token
44
commandPrefix: '!', // the prefix used for commands defined in the rule files
5-
adminChannelID: '', // the channel where administrative messages (responses.admin) will be sent to
5+
adminChannelID: '', // the channel where administrative messages (responses.admin) will be sent to (Optional)
66
rules: {
77
// which rule files should be loaded on startup. order is important and as a rule of thumb it should be: policing, commands, everything else
88
message: ['policing', 'help', 'various'],
99
messageDelete: [],
1010
},
1111
};
12+
13+
module.exports = config;

package-lock.json

Lines changed: 43 additions & 3497 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "HomarusBot",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "A reaction Bot for Discord Servers running on NodeJS",
55
"author": "TimeWaster",
66
"license": "Unlicense",
@@ -10,18 +10,14 @@
1010
},
1111
"main": "src/server.js",
1212
"scripts": {
13-
"run": "npx babel-node src/server.js",
14-
"run-dev": "nodemon --exec babel-node src/server.js",
15-
"run-dev-test": "nodemon --exec babel-node src/test.js"
13+
"run": "npx src/server.js",
14+
"run-dev": "nodemon --watch ../ src/server.js",
15+
"changelog": "git log --pretty='- %s'"
1616
},
1717
"dependencies": {
1818
"discord.js": "^12.5.3"
1919
},
2020
"devDependencies": {
21-
"@babel/cli": "^7.13.16",
22-
"@babel/core": "^7.14.2",
23-
"@babel/node": "^7.14.2",
24-
"@babel/preset-env": "^7.14.2",
2521
"nodemon": "^2.0.7"
2622
}
2723
}

rules/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ The rules name (In the example above 'daily-quote') must be added to the rules A
1717
A rule file must contain one or more rules in the following format:
1818

1919
```js
20-
export default [{ ruleConfiguration }, { ruleConfiguration }];
20+
module.exports = [{ ruleConfiguration }, { ruleConfiguration }];
2121
```
2222

2323
or
2424

2525
```js
26-
export default { ruleConfiguration };
26+
module.exports = { ruleConfiguration };
2727
```
2828

2929
## Rule configuration
@@ -83,8 +83,8 @@ The rule configuration Object literal can contain the following properties (All
8383
* This behaviour differs from the emojis added as reactions!
8484
* @property {(object|object[])} [error] - Sends a message if the user is not allowed to use the rule due to channel or role restrictions, works exactly the same as the "normal" property
8585
* @property {(object|object[])} [admin] - Sends a message to the admin channel as specified in "adminChannelID" in config.js, works exactly the same as the "normal" property
86-
* @property {boolean} [normalIsPM=false] - If the normal message should be sent as a private message
87-
* @property {boolean} [errorIsPM=false] - If the error message should be sent as a private message
86+
* @property {boolean} [normalIsPM=false] - If the normal message should be sent as a private message instead
87+
* @property {boolean} [errorIsPM=false] - If the error message should be sent as a private message instead
8888
*/
8989
```
9090

rules/message.help.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// shows help to the user
2-
export default {
2+
module.exports = {
33
keywords: ['\\!help'],
44
startsWith: true,
55
responses: {
@@ -16,6 +16,10 @@ export default {
1616
{ name: 'good night', value: 'Answers "Sleep tight!"' },
1717
{ name: 'haha', value: 'Adds an Emoji reaction to the users message' },
1818
{ name: '!avatar', value: 'Responds with the users avatar image' },
19+
{
20+
name: '"keyword1", "keyword2", "keyword3"',
21+
value: 'Responds with a random message',
22+
},
1923
{ name: '!help', value: 'Answers with this message' },
2024
],
2125
},

rules/message.policing.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// police speech example
2-
export default {
2+
module.exports = {
33
keywords: ['testword1', 'testword2', 'testword3'],
44
wordBounds: false,
55
deleteMessage: true,

rules/message.various.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
// various small response examples
2-
export default [
2+
module.exports = [
33
{ keywords: ['ping'], responses: { normal: { content: 'pong' } }, dontStopChecking: true },
44
{ keywords: ['ping pong'], responses: { normal: { content: 'what?' } } },
55
{ keywords: ['good night'], responses: { normal: { content: 'Sleep tight!' } } },
66
{ keywords: ['haha'], reactions: ['😄'] },
77
{ keywords: ['\\!avatar'], startsWith: true, responses: (message) => ({ normal: { content: message.author.displayAvatarURL() } }) },
8+
{
9+
keywords: ['keyword1', 'keyword2', 'keyword3'],
10+
responses: (message) => {
11+
const responses = ['Response1: :smile: %userMention%.', 'Response2: %keyword%? Awesome!', 'Response3: Live is beautiful.'];
12+
const randNum = Math.floor(Math.random() * responses.length);
13+
14+
return { normal: { content: responses[randNum] } };
15+
},
16+
},
817
];

0 commit comments

Comments
 (0)