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

Commando rewrite #8

Merged
merged 109 commits into from
Sep 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
4114c26
deps: Add discord.js-commando.
sustained Sep 1, 2019
dd191e2
refactor: Reorganise commands into directories.
sustained Sep 1, 2019
f80e1a4
refactor: Remove help command.
sustained Sep 1, 2019
b475668
refactor: Remove templates since they are no longer accurate.
sustained Sep 1, 2019
81c88b8
refactor: Set up new Commando-based client.
sustained Sep 1, 2019
e1fb0c6
refactor: Add missing ready event; adjust wording slightly.
sustained Sep 1, 2019
403e92f
refactor: Remove defunct code; switch to ES6 imports.
sustained Sep 1, 2019
fa847d1
feat: Allow specifying/overriding command prefix.
sustained Sep 1, 2019
34e4941
other: Add example .env file.
sustained Sep 1, 2019
0a865f6
fix: OWNER -> OWNERS_IDS.
sustained Sep 1, 2019
1bb13d2
refactor: Remove defunct initialisation.
sustained Sep 1, 2019
24ec0d5
other: Error handling.
sustained Sep 1, 2019
1fa950a
refactor: Update utils.
sustained Sep 1, 2019
b6fc44a
refactor: Update ban words service.
sustained Sep 1, 2019
9d273be
refactor: Commando-ise !code command.
sustained Sep 1, 2019
72236e4
refactor: Commando-ise !add-ban-word command.
sustained Sep 1, 2019
af44101
fix: Add missing prompt.
sustained Sep 1, 2019
950566c
refactor: Commando-ise !list-ban-words command.
sustained Sep 1, 2019
4036ccb
refactor: Commando-ise !remove-ban-word command.
sustained Sep 1, 2019
032f6c9
fix: Make guild-only.
sustained Sep 1, 2019
d9329c6
fix: Move jobs back to a jobs/ directory.
sustained Sep 1, 2019
3619cd9
refactor: Commando-ise !docs command.
sustained Sep 1, 2019
3d6e291
refactor: Remove defunct !status command.
sustained Sep 1, 2019
310f848
refactor: Remove defunct !args-info command.
sustained Sep 1, 2019
7d3992b
fix: Move ban words list to new home in data/.
sustained Sep 1, 2019
6060fe3
other: Add todo.
sustained Sep 1, 2019
224a042
fix: Message references.
sustained Sep 1, 2019
71718ae
other: Add some more todos.
sustained Sep 1, 2019
db80b14
fix: Use resolve.
sustained Sep 1, 2019
e9302be
deps: Add esm (ES6 module support sans Babel config).
sustained Sep 1, 2019
89ab1ff
fix: Update script; update author; add contributors.
sustained Sep 1, 2019
c656dbb
deps: Add dotenv (load .env into process.env).
sustained Sep 1, 2019
5484235
fix: Command + file name.
sustained Sep 1, 2019
6ae0a11
fix: Re-add "jobs" system.
sustained Sep 1, 2019
cf1eb5c
refactor: Initial ES6 module/renaming pass.
sustained Sep 1, 2019
9218476
feat: Add constants utility.
sustained Sep 1, 2019
f6db1b8
feat: Permission checks for moderation commands.
sustained Sep 1, 2019
6856649
refactor: Move docs data.
sustained Sep 1, 2019
27c2b93
feat: Jobs as classes.
sustained Sep 2, 2019
7b2a5bf
refactor: Use Job class.
sustained Sep 2, 2019
1ee4078
feat: Setup ESLint and Prettier.
sustained Sep 2, 2019
069d3c2
refactor: Run ESLint/Prettier.
sustained Sep 2, 2019
38915bb
fix: Update references to users/roles.
sustained Sep 2, 2019
01da999
feat: Add message utils.
sustained Sep 2, 2019
0e02c58
other: Update utils/index exports.
sustained Sep 2, 2019
132c7d8
fix: message -> msg.
sustained Sep 2, 2019
76628b6
fix: Unused var [eslint].
sustained Sep 2, 2019
6348ef5
feat: Jobs as classes.
sustained Sep 2, 2019
fa86112
feat: Job shouldExecute + ignored roles.
sustained Sep 2, 2019
f872aae
fix: Don't process own messages for jobs.
sustained Sep 2, 2019
c2152c9
feat: Job config.
sustained Sep 2, 2019
ee38378
feat: Runtime enabling/disabling of jobs.
sustained Sep 2, 2019
195c6a2
fix: Missing spread.
sustained Sep 2, 2019
c1de457
fix: Overlapping aliases.
sustained Sep 2, 2019
d1aea44
other: Register jobs command group.
sustained Sep 2, 2019
256b7cf
fix: Incorrect command groups.
sustained Sep 2, 2019
163320b
fix: Typo.
sustained Sep 2, 2019
1ead4cd
fix: Member names.
sustained Sep 2, 2019
24f693a
feat: Job list command.
sustained Sep 2, 2019
41a7753
other: Freeze ids/roles to ensure they can't change at runtime.
sustained Sep 2, 2019
284daf3
feat: Better env-specific constants.
sustained Sep 2, 2019
2b44311
other: Update role IDs for dev server.
sustained Sep 2, 2019
e207fb2
fix: jobDefinition is not a constructor.
sustained Sep 2, 2019
fa07b4b
fix: Job imports + error handling.
sustained Sep 2, 2019
485b989
workaround: Must temporarily use module.exports.
sustained Sep 2, 2019
fbe5a82
fix: Constants exports.
sustained Sep 2, 2019
da87890
fix: Add config to instance.
sustained Sep 2, 2019
8abab3d
refactor: Run ESLint.
sustained Sep 2, 2019
0ac853e
fix: Use module.exports because Commando hates ES6.
sustained Sep 2, 2019
21da3af
other: Correct role IDs.
sustained Sep 2, 2019
e40e8f2
fix: Ban word separator.
sustained Sep 2, 2019
36293c2
other: If no ignored roles, then by default execute.
sustained Sep 2, 2019
fbbb7ec
fix: Typo.
sustained Sep 2, 2019
a5d2ded
other: Only run warn job if ban words matched.
sustained Sep 2, 2019
ec16054
other: Update config.
sustained Sep 2, 2019
153fcd7
other: Add test job.
sustained Sep 2, 2019
0a3edce
fix: Missing args.
sustained Sep 2, 2019
4bf951b
fix: Allowed users/roles checking.
sustained Sep 2, 2019
2efc35f
fix: Typo.
sustained Sep 2, 2019
dc8b54e
fix: Groups / member names.
sustained Sep 2, 2019
35ebcb7
feat: Add job-info command.
sustained Sep 2, 2019
3a9237e
other: Update group names to reflect changes.
sustained Sep 2, 2019
2b27737
other: Improve description.
sustained Sep 2, 2019
cc5114f
fix: Add missing import.
sustained Sep 2, 2019
917abb5
fix: Various improvements.
sustained Sep 2, 2019
53732dc
deps: Update to latest discord.js.
sustained Sep 2, 2019
f76dac7
fix: Quotes.
sustained Sep 2, 2019
8c84b00
fix: Enabling/disabling jobs.
sustained Sep 2, 2019
d964ba6
other: Log instead so as to not spam server.
sustained Sep 2, 2019
d058d30
fix: Disabled by default not working.
sustained Sep 2, 2019
93de8c4
other: Improve logs; extract log method; add debug mode.
sustained Sep 2, 2019
b124834
refactor: Always use curly braces.
sustained Sep 3, 2019
97c93c4
fix: Pass client to jobs.
sustained Sep 3, 2019
6d97d47
feat: trySend - Attempt to send a message to a "ChannelResolvable".
sustained Sep 3, 2019
6a0ace3
other: Adjust toString output.
sustained Sep 3, 2019
c4a9954
feat: Events.
sustained Sep 3, 2019
7b66800
fix: Make duplicate job names be an error.
sustained Sep 3, 2019
0756238
fix: Remove ignored categories (is not possible to implement afaict).
sustained Sep 3, 2019
9802f73
fix: Add missing description.
sustained Sep 3, 2019
b17c9ed
fix: Should return false.
sustained Sep 3, 2019
f022940
fix: Default guildOnly.
sustained Sep 3, 2019
fe15127
feat: Ignored channels and ignored users.
sustained Sep 3, 2019
a466b5b
other: Add default/fallback run method.
sustained Sep 3, 2019
d8f9886
fix: API change, setEnabled -> enabled (setter).
sustained Sep 3, 2019
3ca988a
docs: Document entire Job class.
sustained Sep 3, 2019
87e0ebe
feat: Add LogJob to showcase event-only jobs.
sustained Sep 4, 2019
6b089f1
fix: Missing event.
sustained Sep 4, 2019
8852750
docs: Update README!
sustained Sep 4, 2019
9a40e74
fix: Small typo near end of new README.
sustained Sep 4, 2019
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
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BOT_TOKEN=
CLIENT_ID=
OWNERS_IDS=
COMMAND_PREFIX=!
18 changes: 18 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
env: {
node: true,
es6: true,
},
extends: ['prettier', 'plugin:vue/essential', '@vue/prettier'],
rules: {
'prettier/prettier': 'error',
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'func-call-spacing': 'error',
'curly': 'error'
},
parserOptions: {
parser: 'babel-eslint',
},
}
8 changes: 8 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
semi: false,
tabs: false,
tabWidth: 2,
singleQuote: true,
trailingComma: 'es5',
bracketSpacing: true,
}
113 changes: 95 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,115 @@
# **vue-land-bot**

**UPDATE 02/09/2019:** Aimed to be rewritten using [Commando.js](https://discord.js.org/#/docs/commando/master/general/welcome) for easiness of maintainability.
This is the official bot for the Vue Land Discord server.

API Doc: https://discord.js.org
It's written in JS and built on [Discord.js](https://github.com/discordjs/discord.js/) and [Commando](https://github.com/discordjs/Commando).

Based on guide: https://discordjs.guide/
## Table of Contents

Not implemented:

- [Setting a command as guild-only](https://discordjs.guide/commando/guild-only.html#setting-a-command-as-guild-only)
- [Cooldowns](https://discordjs.guide/command-handling/adding-features.html#cooldowns)
- [Command aliases](https://discordjs.guide/command-handling/adding-features.html#command-aliases)
- [Set up the bot](#setup)
- [Necessary steps](#necessary-steps)
- [Install dependencies](#install-dependencies)
- [Create Discord app and bot](#create-discord-application-and-bot-user)
- [Create the `.env` file](#create-the-.env-file)
- [Add Discord token to `.env` file](#add-discord-token-to-.env-file)
- [Optional steps](#optional-steps)
- [Configure role and user IDs](#configure-role-and-user-ids)
- [Run the bot](#running)
- [FAQ](#faq)
- [Contributors](#contributors)

# Setup

To make this code work, you'll need to setup your own bot with its own token.
To do so, follow [this steps](https://discordjs.guide/preparations/setting-up-a-bot-application.html).
## Necessary steps

### Install dependencies

# How to run?
As always:

```sh
# Install dependencies
```bash
npm install
```

### Create Discord application and bot user

Before you can run vue-land-bot, you'll need to setup a Discord Application and attach a bot user to it.

Once you're done, copy the bot token to your clipboard.

If you're not sure what to do you can [follow this guide](https://discordjs.guide/preparations/setting-up-a-bot-application.html).

### Create the `.env` file

You'll need to copy `.env.example` to `.env`.

On \*nix/bsd you can run this command:

```bash
cp .env.example .env
```

### Add Discord token to `.env` file

Next you need to add the bot token to the `.env` file (as `DISCORD_TOKEN`).

> **IMPORTANT:** You should treate the Discord bot token like a password - keep it safe! Especially if you plan on giving it permissions like `ADMINISTRATOR`!

[Back to top](#vue-land-bot)

## Optional steps

# Start bot
<!--
### Create Github personal access token

If you want the RFCs command group to work then you'll need to create a [Github personal access token](https://github.com/settings/tokens) and add it to the `.env` file (as `GITHUB_TOKEN`).

You don't _need_ to give it any scopes.

> **IMPORTANT:** You should treate the Github personal access token like a password - keep it safe! Especially if you add any scopes!
-->

### Configure role and user IDs

While not necessary per se, it's recommended to check out `src/constants/development.js` and `src/constants/production.js`.

The relevant file is included based on the `NODE_ENV` environmental variable.

These files contain various [Snowflakes](https://discordapp.com/developers/docs/reference#snowflakes) (basically IDs) for users and roles.

[Back to top](#vue-land-bot)

# Running

To run the bot simply run:

```bash
npm run serve
```

[Back to top](#vue-land-bot)

# FAQ

### When I run `npm run serve`, I get: `UnhandledPromiseRejectionWarning: Error: Incorrect login details were provided`
## When I run `npm run serve` I get an error

### "The environmental variable BOT_TOKEN is required but was not present!"

Please read the [necessary steps](#necessary-steps) section of the README.

### Error: Incorrect login details were provided.

Ensure you copy-pasted the token correctly. Perhaps you accidentally added a space, for instance?

[Back to top](#vue-land-bot)

Make sure you have a `./src/config.json` file with your token properly filled.
# Contributors

To get a default `config.json`, run `npm run init`.
- Lead Developer / Maintainer
- [Elfayer](https://github.com/elfayer/), Hong Kong
- Contributors
- [sustained](https://github.com/sustained/), United Kingdom
- Ideas, Feedback & Testing
- [gusto](https://github.com/gustojs/), Poland
- [laquasicinque](https://github.com/laquasicinque) United Kingdom

To setup your token, see the [Setup](#Setup) section.
[Back to top](#vue-land-bot)
File renamed without changes.
102 changes: 102 additions & 0 deletions data/documentation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
export default [
{
name: 'vue',
aliases: ['home', 'vuejs'],
value: 'https://vuejs.org/',
},
{
name: 'get-started',
aliases: ['start', 'intro', 'introduction'],
value: 'https://vuejs.org/v2/guide/',
},
{
name: 'installation',
value: 'https://vuejs.org/v2/guide/installation.html',
},
{
name: 'class',
aliases: ['classes'],
value:
'https://vuejs.org/v2/guide/class-and-style.html#Binding-HTML-Classes',
},
{
name: 'style',
aliases: ['styles'],
value:
'https://vuejs.org/v2/guide/class-and-style.html#Binding-Inline-Styles',
},
{
name: 'component',
aliases: ['components'],
value: 'https://vuejs.org/v2/guide/components.html',
},
{
name: 'slot',
aliases: ['slots'],
value: 'https://vuejs.org/v2/guide/components-slots.html',
},
{
name: 'prop',
aliases: ['props'],
value: 'https://vuejs.org/v2/guide/components-props.html',
},
{
name: 'event',
aliases: ['events'],
value: 'https://vuejs.org/v2/guide/components-custom-events.html',
},
{
name: 'registration',
value: 'https://vuejs.org/v2/guide/components-registration.html',
},
{
name: 'transition',
aliases: ['transitions'],
value: 'https://vuejs.org/v2/guide/transitions.html',
},
{
name: 'mixin',
aliases: ['mixins'],
value: 'https://vuejs.org/v2/guide/mixins.html',
},
{
name: 'directive',
aliases: ['directives', 'custom-directive', 'custom-directives'],
value: 'https://vuejs.org/v2/guide/custom-directive.html',
},
{
name: 'render',
aliases: ['render-function', 'render-functions'],
value: 'https://vuejs.org/v2/guide/render-function.html',
},
{
name: 'lifecycle',
aliases: ['cycle', 'lifecycles', 'lifecycle-hooks'],
value: 'https://vuejs.org/v2/api/#Options-Lifecycle-Hooks',
},
{
name: 'lifecycle-diagram',
aliases: ['cycle-diag', 'cycle-diagram', 'life-cycle-diagram'],
value: 'https://vuejs.org/v2/guide/instance.html#Lifecycle-Diagram',
},
{
name: 'cookbook',
aliases: ['cook'],
value: 'https://vuejs.org/v2/cookbook/',
},
{
name: 'style-guide',
aliases: ['guide'],
value: 'https://vuejs.org/v2/style-guide/',
},
{
name: 'example',
aliases: ['examples'],
value: 'https://vuejs.org/v2/examples/',
},
{
name: 'prop-event',
aliases: ['props-events'],
value: 'https://vuejs.org/images/props-events.png',
},
]
Loading