Skip to content

Commit

Permalink
Merge pull request #76 from EddieJaoudeCommunity/eddiejaoude-issue-60
Browse files Browse the repository at this point in the history
feat(bio): save/read user bio + socials #60
  • Loading branch information
eddiejaoude committed Jun 23, 2020
2 parents de76d57 + cf61951 commit 141a815
Show file tree
Hide file tree
Showing 9 changed files with 1,595 additions and 21 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/master.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Deploy to production

on:
Expand Down Expand Up @@ -34,7 +31,7 @@ jobs:
- uses: azure/appservice-settings@v1
with:
app-name: ${{ env.APP_NAME }}
app-settings-json: '[{ "name": "DISCORD_TOKEN", "value": "${{ secrets.DISCORD_TOKEN }}"},{ "name": "DISCORD_SERVER_ID", "value": "${{ secrets.DISCORD_SERVER_ID }}"},{ "name": "DISCORD_BOT_CHANNEL_ID", "value": "${{ secrets.DISCORD_BOT_CHANNEL_ID }}"}]'
app-settings-json: '[{ "name": "DISCORD_TOKEN", "value": "${{ secrets.DISCORD_TOKEN }}"},{ "name": "DISCORD_SERVER_ID", "value": "${{ secrets.DISCORD_SERVER_ID }}"},{ "name": "DISCORD_BOT_CHANNEL_ID", "value": "${{ secrets.DISCORD_BOT_CHANNEL_ID }}"},{ "name": "FIREBASE_KEY", "value": "${{ secrets.FIREBASE_KEY }}"}]'
id: settings
- run: az logout

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
dist/
*.tmp.*
*.key
44 changes: 31 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,27 @@ Discord bot for Eddie Jaoude's Discord server
2. Install dependencies by running the command `npm install`

### Run the project locally on Mac and Linux using below command
1. `DISCORD_TOKEN=<GET YOUR DISCORD TOKEN> GENERAL_CHANNEL_ID=<GET YOUR GENERAL CHANNEL ID> DISCORD_SERVER_ID=<YOUR SERVER_ID> DISCORD_BOT_CHANNEL_ID=<ID> npm run start:local`
1. `DISCORD_TOKEN=<GET YOUR DISCORD TOKEN> GENERAL_CHANNEL_ID=<GET YOUR GENERAL CHANNEL ID> DISCORD_SERVER_ID=<YOUR SERVER_ID> DISCORD_BOT_CHANNEL_ID=<ID> COMMAND_PREFIX=<PREFIX> FIREBASE_KEY=<FIREBASE_KEY> npm run start:local`

or you can the envars in a file `envars.tmp.sh` and run the command `source envars.tmp.sh && npm run start:local`

Example `envars.tmp.sh` file

```bash
export DISCORD_TOKEN=<DISCORD_TOKEN>
export COMMAND_PREFIX='^'
export DISCORD_SERVER_ID=<DISCORD_SERVER_ID>
export DISCORD_BOT_CHANNEL_ID=<DISCORD_BOT_CHANNEL_ID>
export FIREBASE_KEY=<FIREBASE_KEY>
```

### Run on Windows using below commands
1. `set DISCORD_TOKEN=<GET YOUR DISCORD TOKEN>`
2. `set GENERAL_CHANNEL_ID=<GET YOUR GENERAL CHANNEL ID>`
2. `set DISCORD_SERVER_ID=<YOUR SERVER_ID>`
2. `set DISCORD_BOT_CHANNEL_ID=<ID>`
3. `npm run start:local`
3. `set DISCORD_SERVER_ID=<YOUR SERVER_ID>`
4. `set DISCORD_BOT_CHANNEL_ID=<ID>`
5. `set COMMAND_PREFIX=<PREFIX>`
6. `npm run start:local`

### Logging

Expand Down Expand Up @@ -88,23 +101,28 @@ Join our discord community [here](https://discord.gg/jZQs6Wu)
---

## How to add a new command to the bot
All the commands are located in the folder `src/commandHandlers` so that each command has its own file. They are then executed in `src/commands.ts` when a user types a command with the configured command prefix in [config.ts](https://github.com/EddieJaoudeCommunity/EddieBot/blob/develop/src/config.ts#L4). To **create a new command**, follow these steps:

All the commands are located in the folder `src/commandHandlers` so that each command has its own file. They are then executed in `src/commands.ts` when a user types a command with the configured command prefix in [config.ts](https://github.com/EddieJaoudeCommunity/EddieBot/blob/develop/src/config.ts#L4).

To **create a new command**, follow these steps:

1. **Create a new file** on the `/commandHandlers` folder with the name of the new command.
_Note: If you need to, use **camel case** for the file name, like_ `codeOfConduct.ts`
_Note: If you need to, use **camel case** for the file name, like_ `codeOfConduct.ts`
2. On this file you must **export a function** and **three variables**:
- `command` - the function that executes the command. The **signature** of this function is the following:
```ts
- `command` - the function that executes the command. The **signature** of this function is the following:
```ts
(arg: string, embed: MessageEmbed, message: Message): Promise<MessageEmbed>
```
```
The **arg** parameter contains the arguments given to the command in a string.
The **embed** parameter is a [MessageEmbed](https://discord.js.org/#/docs/main/stable/class/MessageEmbed) instance, and it represents the message that is returned by the bot, in response to the user. **The command should return this parameter or a new instance** with an appropriate message to the user.
The **message** parameter is a [Message](https://discord.js.org/#/docs/main/stable/class/Message) instance that represents the message inputted by the user to execute a given command.
- `description` - a string with a more detailed description of the command. Used for example by the [help command](https://github.com/EddieJaoudeCommunity/EddieBot/blob/develop/src/commandHandlers/help.ts)
- `triggers` - a string array with the values that trigger this command. If the user types the configured command prefix followed by one of these values, the command **should be executed**
- `usage` - a string explaining how the command is used (e.g. specifying the number of arguments and their separator)
- `description` - a string with a more detailed description of the command. Used for example by the [help command](https://github.com/EddieJaoudeCommunity/EddieBot/blob/develop/src/commandHandlers/help.ts)
- `triggers` - a string array with the values that trigger this command. If the user types the configured command prefix followed by one of these values, the command **should be executed**
- `usage` - a string explaining how the command is used (e.g. specifying the number of arguments and their separator)
3. After creating that file, you have to import it and add it to the exported list of commands on the [index.ts](https://github.com/EddieJaoudeCommunity/EddieBot/blob/develop/src/commandHandlers/index.ts) file located in this folder. Here is an example of adding the `standup` command:
```diff
import * as codeOfConduct from './codeOfConduct';
import * as help from './help';
Expand All @@ -117,7 +135,7 @@ import * as stats from './stats';
export { fallback } from './fallback';
```

<br>
---

If you are having trouble creating a new command, here is an [example](https://github.com/EddieJaoudeCommunity/EddieBot/blob/develop/src/commandHandlers/standup.ts).
Feel free to [create an issue](https://github.com/EddieJaoudeCommunity/EddieBot/issues) or make a PR with a new command 😃. Please see our [Contributing](./.github/CONTRIBUTING.md) file first, before making new commits or opening a PR. We appreciate it ❤️!

0 comments on commit 141a815

Please sign in to comment.