Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ Random refactoring #102

Merged
merged 28 commits into from
May 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
07e8619
🐛 Created .eslintignore
n1ckoates Mar 6, 2022
a111892
🐛 Exit process instead of return
n1ckoates Mar 6, 2022
0bf1f1e
📄 Use multiline comment for copyright notice
n1ckoates Mar 6, 2022
d2d9e0e
🎨 Setup Prettier
n1ckoates Mar 6, 2022
bb1ff22
🚨 Lint with Prettier
n1ckoates Mar 6, 2022
0a8c164
🔨 Added lint npm script
n1ckoates Mar 6, 2022
eb5c5d2
✏️ Removed an extra space that bothered me
n1ckoates Mar 6, 2022
bc6a2b9
📝 Add Docker section to self-hosting
n1ckoates Mar 6, 2022
a361c30
✏️ Fixed markdown checklist
n1ckoates Mar 6, 2022
71c47c1
Merge branch 'main' into refactor
MarcusOtter Mar 6, 2022
38cbaea
🎨 Allow one-line blocks
n1ckoates Mar 6, 2022
8ce0874
🎨 Allow comma dangling
n1ckoates Mar 6, 2022
e77302c
🎨 Sensible curly braces
n1ckoates Mar 6, 2022
2514f88
💩 Add back extra space
n1ckoates Mar 10, 2022
c12f490
🎨 Avoid arrow parens
n1ckoates Mar 13, 2022
bc8f9e9
Merge branch 'main' into refactor
n1ckoates Mar 14, 2022
8211f3e
🔀 Git conflict stuff
n1ckoates Mar 14, 2022
b26a2c0
🔧 Max line width of 120 instead of 80
n1ckoates Mar 31, 2022
237d4af
Merge branch 'main' into refactor
n1ckoates Mar 31, 2022
ef6f6bf
🔥 Remove unnecessary console.log()
n1ckoates Mar 31, 2022
40e4ffb
Merge branch 'main' into refactor
n1ckoates May 6, 2022
6f051e5
Fix some minor style issues
MarcusOtter May 15, 2022
098f0d1
Fix merge conflicts
MarcusOtter May 15, 2022
f0eba77
Fix typo
MarcusOtter May 15, 2022
47e41e0
Forgot one if-statement
MarcusOtter May 15, 2022
5d258d0
✏️ Remove equals sign
n1ckoates May 15, 2022
91d311b
🐛 Fix incorrect git merge
n1ckoates May 15, 2022
242b0a1
🔥 Remove vscode settings file
n1ckoates May 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
dist/
configs/
42 changes: 16 additions & 26 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],
"env": {
"node": true,
"es6": true,
Expand All @@ -11,40 +11,30 @@
},
"plugins": ["@typescript-eslint"],
"rules": {
"brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
"comma-dangle": ["error", "always-multiline"],
"comma-spacing": "error",
"comma-style": "error",
"curly": ["error", "multi-line", "consistent"],
"dot-location": ["error", "property"],
"eqeqeq": "error",
"handle-callback-err": "off",
"indent": ["error", "tab"],
"max-nested-callbacks": ["error", { "max": 4 }],
"max-statements-per-line": ["error", { "max": 2 }],
"no-console": "off",
"no-empty-function": "error",
"no-floating-decimal": "error",
"no-lonely-if": "error",
"no-multi-spaces": "error",
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }],
"no-shadow": "off",
"@typescript-eslint/no-shadow": ["error"],
"no-trailing-spaces": ["error"],
"no-var": "error",
"object-curly-spacing": ["error", "always"],
"prefer-const": "error",
"quotes": ["error", "double"],
"semi": ["error", "always"],
"space-before-blocks": "error",
"space-before-function-paren": ["error", {
"anonymous": "never",
"named": "never",
"asyncArrow": "always"
}],
"space-in-parens": "error",
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": "error",
"yoda": "error"
"quotes": ["error", "double", { "avoidEscape": true }],
"spaced-comment": ["error", "always"],
"yoda": "error",
"curly": ["error", "multi-line", "consistent"],
"comma-dangle": [
"error",
{
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "never"
}
]
}
}
12 changes: 6 additions & 6 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: 🐇 Discord Chat
url: https://needle.gg/chat
about: Join the Discord server to get answers to your questions ASAP
- name: 🐌 GitHub Discussions
url: https://github.com/MarcusOtter/discord-needle/discussions
about: If you prefer, you can also open a discussion here on GitHub with questions
- name: 🐇 Discord Chat
url: https://needle.gg/chat
about: Join the Discord server to get answers to your questions ASAP
- name: 🐌 GitHub Discussions
url: https://github.com/MarcusOtter/discord-needle/discussions
about: If you prefer, you can also open a discussion here on GitHub with questions
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/improvement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ body:
- type: textarea
id: fixes
attributes:
label: Problems this improvement solves
description: Is this improvement related to a problem? How does it solve that?
label: Problems this improvement solves
description: Is this improvement related to a problem? How does it solve that?
- type: textarea
id: alternatives
attributes:
Expand Down
8 changes: 4 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
dist/
configs/
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"useTabs": true,
"tabWidth": 4,
"arrowParens": "avoid",
"printWidth": 120
}
22 changes: 14 additions & 8 deletions PRIVACY_POLICY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,35 @@

Needle has never and will never collect any personal data. This includes message content, names, IP-adresses, time stamps, member information, etc.


## What we collect

We do not collect any data automatically. The only data we collect is user-provided guild configuration data for Needle. When this is provided (by invoking configuration commands), we may collect:
- Guild IDs
- Channel IDs
- Custom responses
- Which features are enabled or disabled

- Guild IDs
- Channel IDs
- Custom responses
- Which features are enabled or disabled

## Data retention

The data is deleted from the main disk when one of the following occurs:
- Needle is removed from the guild
- A user successfully invokes the `/configure default` command
- A user indicates to us by other means that they want their data deleted

- Needle is removed from the guild
- A user successfully invokes the `/configure default` command
- A user indicates to us by other means that they want their data deleted

The data may persist in full-disk copies made for backup-purposes for up to 7 days after it was originally deleted.

## Where information is processed

Needle is hosted on a data center in Helsinki, Finland by [Hetzner Online GmbH](https://www.hetzner.com/legal/privacy-policy). The bot communicates with [Discord](https://discord.com/privacy)'s API to interact with users.

## Changes to this privacy policy

We reserve the right to update this privacy policy at any time, with at least 24 hours prior notice in the [Discord support server](https://needle.gg/chat). Your continued use of Needle after the changes have been applied indicates that you agree with the revised privacy policy.

## Contact

Feel free to contact us at [privacy@needle.gg](mailto:privacy@needle.gg) if you have any questions about this privacy policy.

<sub>Last updated and effective: February 3, 2022 - <a href="https://github.com/MarcusOtter/discord-needle/commits/main/PRIVACY_POLICY.md">see update history</a></sub>
68 changes: 49 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,69 @@
<a href="https://needle.gg">Website ✨</a> &emsp; <a href="https://needle.gg/invite">Invite Needle 🪡</a> &emsp; <a href="https://needle.gg/chat">Get support 💬</a>
</div>

## Self-hosting
## 👋 Getting started

This step-by-step guide assumes you have [NodeJS](https://nodejs.org/en/) version `16.9.0` or higher installed and that you have a Discord Bot user set up at [Discord's developer page](https://discord.com/developers/applications) that has been invited to your server with the scopes `applications.commands` and `bot`.
The easiest way to start using Needle in your server is to use the hosted instance. [Click here to invite Needle to your Discord server](https://needle.gg/invite)!

1. Fork and clone the repository
2. Copy `.env.example` to `.env` and insert your bot's Discord API token and Application ID.
3. Run `npm install`
4. Run `npm run deploy`. This will make the slash commands show up in the servers the bot are in, but **it can take up to _ONE HOUR_ before they show up**.
5. Make sure the bot has the required permissions in Discord:
- [x] View channels
- [x] Send messages
- [x] Send messages in threads
- [x] Create public threads
- [x] Read message history
6. Run `npm start`
7. Deploy! :tada:
## 🛠️ Self-hosting (advanced)

## Contributing
The hosted instance of Needle is customizeable and should be enough for most users. However, if you have special requirements and want to modify the functionality of Needle, you will have to fork the repository and self-host your own instance. This requires programming knowledge and is only for advanced users - support for this will be limited.

Coming soon :tm:
Needle requires an environment with Node.js version `16.9.0` or higher, along with persistent storage for per-server config files - shared hosts (like Replit and Heroku) will not work.

1. Download the [latest release](https://github.com/MarcusOtter/discord-needle/releases/latest) of Needle and extract the archive.
2. Copy `.env.example` to `.env` and fill in your bot's token and application ID.
3. Run `npm install` to install Needle's dependencies.
4. Run `npm run build` to compile Needle's code.
5. Run `npm run deploy` to setup slash commands.
- Slash commands can take **up to one hour** to show up in all servers.
6. Run `npm start` to start Needle :tada:

Needle requires the following permissions to function, along with the `applications.commands` and `bot` scopes.

- [x] View channels
- [x] Send messages
- [x] Send messages in threads
- [x] Create public threads
- [x] Read message history

You can use this link to invite your self-hosted version of Needle, replacing `<APP ID>` with your bot's application ID: `https://discord.com/oauth2/authorize?client_id=<APP ID>&permissions=309237713920&scope=bot%20applications.commands`

### 🐳 Docker

Needle has an [official Docker image](https://github.com/MarcusOtter/discord-needle/pkgs/container/discord-needle). Releases are tagged by their minor & patch version (e.g. `2.0.0` & `2.0`), with the latest release tagged `latest`. Branches are tagged by their name. To run the image, write the following command, replacing `token` with your bot's token:

```sh
docker run -d --name Needle --env DISCORD_API_TOKEN=token discord-needle ghcr.io/MarcusOtter/discord-needle:latest
```

By default, this will create an anonymous volume for `/configs`. To change the location, add `-v /path/to/configs:/configs` to the command.

There is also an [example `docker-compose.yml` file](https://github.com/MarcusOtter/discord-needle/blob/main/docker-compose.yml).

You'll still need to deploy Needle's slash commands - follow the regular self-hosting instructions apart from step 6.

## 🤝 Contributing

Contribution guidelines coming soon :tm:

[Join the Discord](https://needle.gg/chat) if interested!

## License
If you want to support Needle in other ways, consider [sponsoring](https://needle.gg/sponsor) the development of Needle.

You can also [vote for and review the bot on top.gg](https://needle.gg/vote).

## 📜 License

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
22 changes: 11 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
services:
needle:
image: ghcr.io/marcusotter/discord-needle:stable
restart: unless-stopped
environment:
- DISCORD_API_TOKEN=
needle:
image: ghcr.io/MarcusOtter/discord-needle:stable
restart: unless-stopped
environment:
- DISCORD_API_TOKEN=

# OPTIONAL: Pass in a .env file rather than specifying it here
# env_file:
# - .env
# OPTIONAL: Pass in a .env file rather than specifying it here
# env_file:
# - .env

# OPTIONAL: Use a named volume instead of an anonymous one
# volumes:
# - /some/configs/directory:/configs
# OPTIONAL: Use a named volume instead of an anonymous one
# volumes:
# - /some/configs/directory:/configs
Loading