Skip to content

Commit 4ab5fb9

Browse files
naeruruVendicated
andauthored
Add support for webhooks (#39)
* (wip) start adding option for webhook (#38) * rework editEmbed() for webhook support * update dependencies * update requirements * oops update readme * handle edge case where messages may be either normal or a webhook * fix issue where createdAt was undefined for update db call * specify username and avatar for webhook msgs * use nullish coalescing operator * use discord.com over discordapp.com Co-authored-by: vee <[email protected]> * add option to set webhook username and avatar to the post author * update version to 1.7 --------- Co-authored-by: vee <[email protected]>
1 parent 8249f7f commit 4ab5fb9

File tree

6 files changed

+408
-349
lines changed

6 files changed

+408
-349
lines changed

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Starboard (also known as the smugboard™) is a Discordjs bot originally created
33

44
## Getting Started
55
### Requirements
6-
- NodeJS 16.9.0+
6+
- NodeJS 16.11.0+
77
- Enable Discord "Message Content Intent" (in Discord App/Bot settings)
88
### Setup
99
Create a [Discord application](https://discord.com/developers/applications) bot, and enable **Message Content Intent** under the **Privilieged Gateway Intents** section in the **bot** tab. This is required for your application to be able to view message content.
@@ -20,7 +20,9 @@ After creating your bot and cloning the repository, the only setup that needs to
2020
"hexcolor": "00AE86",
2121
"dateCutoff": 3,
2222
"fetchLimit": 100,
23-
"editMsgGracePeriod": 300
23+
"editMsgGracePeriod": 300,
24+
"webhook": "",
25+
"authorAsUsername": false
2426
}
2527
```
2628

@@ -29,13 +31,15 @@ After creating your bot and cloning the repository, the only setup that needs to
2931
| **token** | String | the discord bot token you get from your discord [developer portal](https://discordapp.com/developers/applications/). |
3032
| **serverID** | String | the ID of the server you want the bot to run in. After enabling developer mode, you can right click the server icon to get the server ID. |
3133
| **channelID** | String | the ID of the channel you want the starboard bot to post to. You can right click the channel name and obtain the channel ID after enabling developer mode. |
34+
| **webhook** | URL | (OPTIONAL) The URL of a user created webhook (Server Settings > Integrations). When a valid URL exists, the bot will post messages through the webhook instead. This options allows the bot to use any global emote on Discord. |
3235
| **reactionEmoji** | String | the emoji you want the bot to listen to. For default emojis, use the literal emoji. To easily obtain this, you can put a `\` infront of any emoji name like `\:star:` in discord (which would create ⭐). For custom emojis, simply put the exact name like `moon2SMUG`. |
3336
| **embedEmoji** | String | the emoji (Or any other piece of text) displayed at the bottom of the embeds in the starboard channel. |
3437
| **threshhold** | Integer | the amount of reactions it takes for a message to be posted to the starboard. |
3538
| **hexcolor** | String | the color of the embed in hex. if null, this value is generated from an incoming message's channel ID (unique color code per channel). |
3639
| **dateCutoff** | Integer | how old a message can be, in days, and still be tracked by the bot. if you don't want really old messages getting posted, then keep this number low. |
3740
| **fetchLimit** | Integer | how many messages from the starboard channel will be loaded in memory. This lets the script know what messages have already been posted. It's recommended to change this with respect to `dateCutoff` and how big your server is. Anything that isn't tracked has the possibility of getting double posted. |
3841
| **editMsgGracePeriod** | Integer | how long, in seconds, a message can to be edited to update its board post. disables this feature if set to null or 0. |
42+
| **authorAsUsername** | Boolean | Only when webhook is active. If true, sets the webhook username and avatar to the original post author. If false, it sets it to the bot. |
3943

4044
### Running the Project
4145
Use `npm install` to download dependencies. Finally, you can run the bot with `npm start`. I recommend using pm2 for continuous uptime.

config/settings.json.example

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@
88
"hexcolor": "00AE86",
99
"dateCutoff": 3,
1010
"fetchLimit": 100,
11-
"editMsgGracePeriod": 300
11+
"editMsgGracePeriod": 300,
12+
"webhook": "https://discord.com/api/webhooks/1240827868137787492/_N0uYLsTUxUG7WBhAv4BZn8tcKMdU5OcQikEp3iGHbFWBLjmEohGYjklJtjsSgh-ejcr",
13+
"authorAsUsername": true
1214
}

0 commit comments

Comments
 (0)