Skip to content

Commit b4cf353

Browse files
committed
✨ Added Prettier for consistent formatting
1 parent f56f454 commit b4cf353

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+3359
-1918
lines changed

.github/workflows/jsdoc.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ jobs:
1717
- name: Install node
1818
uses: actions/setup-node@v2
1919
with:
20-
node-version: '14'
21-
20+
node-version: "14"
21+
2222
- name: Compile with Grunt
2323
uses: elstudio/actions-js-build/build@v4
2424

.github/workflows/stale.yml

+8-9
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@ name: Mark stale issues and pull requests
22

33
on:
44
schedule:
5-
- cron: "30 1 * * *"
5+
- cron: "30 1 * * *"
66

77
jobs:
88
stale:
9-
109
runs-on: ubuntu-latest
1110

1211
steps:
13-
- uses: actions/stale@v3
14-
with:
15-
repo-token: ${{ secrets.GITHUB_TOKEN }}
16-
stale-issue-message: 'Stale issue message'
17-
stale-pr-message: 'Stale pull request message'
18-
stale-issue-label: 'no-issue-activity'
19-
stale-pr-label: 'no-pr-activity'
12+
- uses: actions/stale@v3
13+
with:
14+
repo-token: ${{ secrets.GITHUB_TOKEN }}
15+
stale-issue-message: "Stale issue message"
16+
stale-pr-message: "Stale pull request message"
17+
stale-issue-label: "no-issue-activity"
18+
stale-pr-label: "no-pr-activity"

.prettierrc.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

Gruntfile.js

+31-28
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
1-
'use strict'
1+
"use strict";
22
module.exports = function (grunt) {
3-
grunt.initConfig({
4-
jsdoc2md: {
5-
// oneOutputFile: {
6-
// src: '/*.js',
7-
// dest: 'docs/documentation.md'
8-
// },
9-
separateOutputFilePerInput: {
10-
files: [
11-
{ src: 'helpers/fifo-handler.js', dest: 'docs/md/fifo-handler.md' },
12-
{ src: 'helpers/rcon.js', dest: 'docs/md/rcon.md' },
13-
{ src: 'helpers/serverHandler.js', dest: 'docs/md/serverHandler.md' },
14-
{ src: 'helpers/serverUPSHandler.js', dest: 'docs/md/serverUPSHandler.md' },
15-
{ src: 'helpers/functions.js', dest: 'docs/md/functions.md' },
16-
]
17-
},
18-
// withOptions: {
19-
// options: {
20-
// 'no-gfm': false
21-
// },
22-
// src: 'src/wardrobe.js',
23-
// dest: 'api/with-index.md'
24-
// }
25-
}
26-
})
3+
grunt.initConfig({
4+
jsdoc2md: {
5+
// oneOutputFile: {
6+
// src: '/*.js',
7+
// dest: 'docs/documentation.md'
8+
// },
9+
separateOutputFilePerInput: {
10+
files: [
11+
{ src: "helpers/fifo-handler.js", dest: "docs/md/fifo-handler.md" },
12+
{ src: "helpers/rcon.js", dest: "docs/md/rcon.md" },
13+
{ src: "helpers/serverHandler.js", dest: "docs/md/serverHandler.md" },
14+
{
15+
src: "helpers/serverUPSHandler.js",
16+
dest: "docs/md/serverUPSHandler.md",
17+
},
18+
{ src: "helpers/functions.js", dest: "docs/md/functions.md" },
19+
],
20+
},
21+
// withOptions: {
22+
// options: {
23+
// 'no-gfm': false
24+
// },
25+
// src: 'src/wardrobe.js',
26+
// dest: 'api/with-index.md'
27+
// }
28+
},
29+
});
2730

28-
grunt.loadNpmTasks('grunt-jsdoc-to-markdown')
29-
grunt.registerTask('default', 'jsdoc2md')
30-
}
31+
grunt.loadNpmTasks("grunt-jsdoc-to-markdown");
32+
grunt.registerTask("default", "jsdoc2md");
33+
};

INSTALLATION.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
# Installation Guide
22

33
## Prerequisites
4+
45
- A MongoDB instance. You can either create your own or get a free instance of Atlas (hosted on AWS/Google Cloud) [here](https://docs.atlas.mongodb.com/getting-started/). The free instance is probably better than required for this project, haven't had any issues with that
56
- A Discord application. Create one [here](https://discord.com/developers/applications). [This guide](https://www.freecodecamp.org/news/create-a-discord-bot-with-javascript-nodejs/) also seems pretty fine, follow it only until you have the bot invited. Make sure you copy the bot token for later use
67
- At least one Factorio server. If you have multiple, make sure that they are **in the same directory**
78
- Node v14
89
- Factorio servers to have [factorio-init](https://github.com/Bisa/factorio-init) installed
910

1011
### How to install factorio-init
12+
1113
1. Clone https://github.com/Bisa/factorio-init to any directory that you wish
1214
2. Make a directory where all of your Factorio servers will be located, such as `/opt/factorio/servers/`
1315
3. Go to the directory where you cloned factorio-init into and copy `config.example` to `config`
1416
4. Set the config up
15-
1. Make sure to set `SERVICE_NAME` to whatever you will recognize in the future, for example `Factorio-AWF-Regular`
16-
2. Make sure the `USERNAME` and `USERGROUP` are properly configured to the user profile that is able to start, stop Factorio servers and is the same as the one that Jammy will use
17-
3. Set `FACTORIO_PATH` to a folder in the directory you created for your Factorio servers, such as `/opt/factorio/servers/awf-regular`. Make sure you create this directory. This must be new and not the directory of an old server. You can copy savefiles, mods etc. later
18-
4. Set `INSTALL_CACHE_DIR=/tmp` to wherever downloads of Factorio server tarballs can be cached, or disable by toggling `INSTALL_CACHE_TAR`
19-
5. Download the [factorio-updater](https://github.com/narc0tiq/factorio-updater) script to a place that you will remember. It can be common for multiple servers. Then set the `UPDATE_SCRIPT` to the location of the python script
20-
6. Set `RCON_PORT` and `RCON_PASSWORD` (you will need to manually type those in) to whatever you will have in Jammy. Make the password consistent for all servers.
21-
7. Add `--rcon-port ${RCON_PORT} --rcon-password ${RCON_PASSWORD}` to the `EXTRA_BINARGS` field
17+
1. Make sure to set `SERVICE_NAME` to whatever you will recognize in the future, for example `Factorio-AWF-Regular`
18+
2. Make sure the `USERNAME` and `USERGROUP` are properly configured to the user profile that is able to start, stop Factorio servers and is the same as the one that Jammy will use
19+
3. Set `FACTORIO_PATH` to a folder in the directory you created for your Factorio servers, such as `/opt/factorio/servers/awf-regular`. Make sure you create this directory. This must be new and not the directory of an old server. You can copy savefiles, mods etc. later
20+
4. Set `INSTALL_CACHE_DIR=/tmp` to wherever downloads of Factorio server tarballs can be cached, or disable by toggling `INSTALL_CACHE_TAR`
21+
5. Download the [factorio-updater](https://github.com/narc0tiq/factorio-updater) script to a place that you will remember. It can be common for multiple servers. Then set the `UPDATE_SCRIPT` to the location of the python script
22+
6. Set `RCON_PORT` and `RCON_PASSWORD` (you will need to manually type those in) to whatever you will have in Jammy. Make the password consistent for all servers.
23+
7. Add `--rcon-port ${RCON_PORT} --rcon-password ${RCON_PASSWORD}` to the `EXTRA_BINARGS` field
2224
5. Run `./factorio install` and factorio-init will install Factorio to the directory that you specified previously.
2325
6. Copy the whole cloned `factorio-init` directory to the Factorio server's directory, i.e. `/opt/factorio/servers/awf-regular/factorio-init`
2426
7. Move to the server's directory and either copy in files from your old server, or set the Factorio server up freshly. Make sure you set your token/password in the `server-settings.json` file
2527
8. Run `./factorio-init/factorio start` to start the server. Refer to [the factorio-init docs](https://github.com/Bisa/factorio-init) for reference about further usage, however some parts are managed by Jammy.
2628

2729
## Bot Installation
30+
2831
1. Clone the repository and install dependencies with `git clone https://github.com/DistroByte/AwF-Bot && cd AwF-Bot && npm i`
2932
2. Populate your `config.js` file from the example (`config.example.js`)
3033
3. Populate your `servers.js` file from the example (`servers.example.js`)

base/Command.js

+37-20
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,43 @@
1-
const path = require('path');
1+
const path = require("path");
22

33
module.exports = class Command {
4-
constructor(client, {
5-
name = null,
6-
description = false,
7-
usage = false,
8-
examples = false,
9-
dirname = false,
10-
enabled = true,
11-
guildOnly = false,
12-
aliases = new Array(),
13-
botPermissions = new Array(),
14-
memberPermissions = new Array(),
15-
customPermissions = new Array(),
16-
nsfw = false,
17-
ownerOnly = false,
18-
args = false,
19-
cooldown = 3000
20-
}) {
21-
const category = (dirname ? dirname.split(path.sep)[parseInt(dirname.split(path.sep).length - 1, 10)] : 'Other');
4+
constructor(
5+
client,
6+
{
7+
name = null,
8+
description = false,
9+
usage = false,
10+
examples = false,
11+
dirname = false,
12+
enabled = true,
13+
guildOnly = false,
14+
aliases = new Array(),
15+
botPermissions = new Array(),
16+
memberPermissions = new Array(),
17+
customPermissions = new Array(),
18+
nsfw = false,
19+
ownerOnly = false,
20+
args = false,
21+
cooldown = 3000,
22+
}
23+
) {
24+
const category = dirname
25+
? dirname.split(path.sep)[
26+
parseInt(dirname.split(path.sep).length - 1, 10)
27+
]
28+
: "Other";
2229
this.client = client;
23-
this.conf = { enabled, guildOnly, memberPermissions, botPermissions, customPermissions, nsfw, ownerOnly, cooldown, args };
30+
this.conf = {
31+
enabled,
32+
guildOnly,
33+
memberPermissions,
34+
botPermissions,
35+
customPermissions,
36+
nsfw,
37+
ownerOnly,
38+
cooldown,
39+
args,
40+
};
2441
this.help = { name, category, aliases, description, usage, examples };
2542
}
2643
};

base/Guild.js

+60-55
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,66 @@
1-
const mongoose = require('mongoose'),
1+
const mongoose = require("mongoose"),
22
Schema = mongoose.Schema,
3-
config = require('../config.js');
3+
config = require("../config.js");
44

5-
module.exports = mongoose.model('Guild', new Schema({
5+
module.exports = mongoose.model(
6+
"Guild",
7+
new Schema({
8+
id: { type: String },
69

7-
id: { type: String },
10+
membersData: { type: Object, default: {} },
11+
members: [{ type: Schema.Types.ObjectId, ref: "Member" }],
812

9-
membersData: { type: Object, default: {} },
10-
members: [{ type: Schema.Types.ObjectId, ref: 'Member' }],
11-
12-
prefix: { type: String, default: config.prefix },
13-
plugins: {
14-
type: Object, default: {
15-
welcome: {
16-
enabled: false, // Whether the welcome messages are enabled
17-
message: null, // The welcome message
18-
channel: null, // The channel to send the welcome messages
19-
},
20-
goodbye: {
21-
enabled: false, // Whether the goodbye messages are enabled
22-
message: null, // The goodbye message
23-
channel: null, // The channel to send the goodbye messages
24-
},
25-
autorole: {
26-
enabled: false, // Whether the autorole is enabled
27-
role: null // The role to add when a member join the server
28-
},
29-
automod: {
30-
enabled: false, // Whether the auto moderation is enabled
31-
ignored: [] // The channels in which the auto moderation is disabled
13+
prefix: { type: String, default: config.prefix },
14+
plugins: {
15+
type: Object,
16+
default: {
17+
welcome: {
18+
enabled: false, // Whether the welcome messages are enabled
19+
message: null, // The welcome message
20+
channel: null, // The channel to send the welcome messages
21+
},
22+
goodbye: {
23+
enabled: false, // Whether the goodbye messages are enabled
24+
message: null, // The goodbye message
25+
channel: null, // The channel to send the goodbye messages
26+
},
27+
autorole: {
28+
enabled: false, // Whether the autorole is enabled
29+
role: null, // The role to add when a member join the server
30+
},
31+
automod: {
32+
enabled: false, // Whether the auto moderation is enabled
33+
ignored: [], // The channels in which the auto moderation is disabled
34+
},
35+
warnsSanctions: {
36+
kick: false, // The number of warns required to kick the user
37+
ban: false, // The number of warns required to ban the user
38+
},
39+
tickets: {
40+
enabled: false, // Whether the tickets system is enabled
41+
category: null, // The category for the tickets system
42+
},
43+
lockdown: false,
44+
suggestions: false,
45+
modlogs: false, // the channel in which the moderation logs (mute, kick, ban, etc...) will be sent
46+
reports: false,
47+
logs: false, // the channel in which the logs (message deleted, etc...) will be sent
3248
},
33-
warnsSanctions: {
34-
kick: false, // The number of warns required to kick the user
35-
ban: false // The number of warns required to ban the user
36-
},
37-
tickets: {
38-
enabled: false, // Whether the tickets system is enabled
39-
category: null // The category for the tickets system
40-
},
41-
lockdown: false,
42-
suggestions: false,
43-
modlogs: false, // the channel in which the moderation logs (mute, kick, ban, etc...) will be sent
44-
reports: false,
45-
logs: false // the channel in which the logs (message deleted, etc...) will be sent
46-
}
47-
},
49+
},
4850

49-
slowmode: {
50-
type: Object, default: { // Servers slowmode
51-
users: [],
52-
channels: []
53-
}
54-
},
55-
casesCount: { type: Number, default: 0 },
56-
ignoredChannels: { type: Array, default: [] },
57-
customCommands: { type: Array, default: [] },
58-
commands: { type: Array, default: [] },
59-
autoDeleteModCommands: { type: Boolean, default: false },
60-
disabledCategories: { type: Array, default: [] }
61-
}))
51+
slowmode: {
52+
type: Object,
53+
default: {
54+
// Servers slowmode
55+
users: [],
56+
channels: [],
57+
},
58+
},
59+
casesCount: { type: Number, default: 0 },
60+
ignoredChannels: { type: Array, default: [] },
61+
customCommands: { type: Array, default: [] },
62+
commands: { type: Array, default: [] },
63+
autoDeleteModCommands: { type: Boolean, default: false },
64+
disabledCategories: { type: Array, default: [] },
65+
})
66+
);

base/Log.js

+23-20
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
const mongoose = require('mongoose');
1+
const mongoose = require("mongoose");
22

3-
module.exports = mongoose.model('Log', new mongoose.Schema({
4-
5-
commandName: { type: String, default: 'unknown' },
6-
date: { type: Number, default: Date.now() },
7-
author: {
8-
type: Object, default: {
9-
username: 'Unknown',
10-
discrminator: '0000',
11-
id: null
12-
}
13-
},
14-
guild: {
15-
type: Object, default: {
16-
name: 'Unknown',
17-
id: null
18-
}
19-
}
20-
21-
}));
3+
module.exports = mongoose.model(
4+
"Log",
5+
new mongoose.Schema({
6+
commandName: { type: String, default: "unknown" },
7+
date: { type: Number, default: Date.now() },
8+
author: {
9+
type: Object,
10+
default: {
11+
username: "Unknown",
12+
discrminator: "0000",
13+
id: null,
14+
},
15+
},
16+
guild: {
17+
type: Object,
18+
default: {
19+
name: "Unknown",
20+
id: null,
21+
},
22+
},
23+
})
24+
);

0 commit comments

Comments
 (0)