Skip to content

Commit

Permalink
v2.2.14
Browse files Browse the repository at this point in the history
- Bumped version to v2.2.14
- Check whether value contains blanks or is 0 length instead of whether it is fully blank for configuration "prefix" and "token"
- Check if value is all numbers for configuration "developerIDs" and "developmentGuildIDs", IDs must be a non 0 length string consisting only 0~9
- "use strict"
- Added optional second parameter "nick" to function createMentionForUser(), when "nick" is true, the user mention will be created in the nickname format
- Added a cooldown of 30 minutes to the "/opensourcelicenses" command, as the response from bot is too long. Cooldown allows chat to not be flooded even if users want to view licenses for 3rd party libraries, and it also helps reduce the server workload and the chance of hitting Discord API rate limit.
- Added new configuration developmentGuildIDs, used to mark Discord servers as bot testing servers
- Added constant botUnavailableString, used to notify bot users when the bot is in testing
- Added a constant Map to map libraries to versions
- Stop the bot from responding to commands executed outside of developmentGuilds when developmentEnvironment is set to true
- Allow a user to be shipped with himself/herself/themselves when shipMaxAttempt is 0 or less
- Allow reminders to never be cancelled when reminderListMaxEntries is 0 or less. Note that the server might eventually run out of memory if too many reminders are tracked
- Allow a user to give positive infinite amount of items when giveMaxAmount is 0 or less. Note that it still doesn't accept users giving 0 or negative number of items
- Added an utility function isSentInDevelopmentGuild() to check if a message is sent in one of the developmentGuilds
- Renamed constant "package" to "packageJSON", as package is a future reserved word
- Added "keywords", "homepage", "bugs", "contributors", and "repository" field
- Fixed "author" field, which is supposed to be a person Object and not a string
- Updated node version in "engines" field
- Reorganized fields by the sequence they appear in NPM documentation, see https://docs.npmjs.com/files/package.json
- Updated license information everywhere
- Added a link to invite ChillBot to servers to README.md
- Added icon.png as avatar for ChillBot
- Added token-example.json as a sample for how to set bot token without environment variables
- Several configurations, "restartTimeout" to set time to wait for between stopping old process and starting new one, "presenceName" to set the game ChillBot is currently playing, "shipMaxAttempts" to specify maximum number of times to retry when using "/ship" if two random users are the same, "reminderListMaxEntries" to specify maximum entries of reminders to keep (set a lower number to reduce memory usage), "giveMaxAmount" to specify the maximum number of items a user can give when using "/give", and "changelogFetchTimeout" to set time to wait for GitHub API
- Added files containing license information for async-limiter, discord.js, long, ms, node, npm, prism-media, snekfetch (deprecated but still used by discord.js), tweetnacl-js, ws
- Changed overall formatting for index.js
- Added handler for uncaughtException event. Uncaught exceptions will now be logged, will no longer crash the bot, and will shutdown the bot cleanly (or if commandline option "restartOnFatalError" is present, restart the bot)
- Added an Object representing default option for sending messages, if the message could potentially exceed 2000 characters
- Added a constant message to send to channel where the command is invoked if DMs cannot be send for certain reasons
- Added a constant message to send when an error occur whilst fetching changelog
- Added a constant message for "/invite" command
- Added base URL for GitHub Releases API as a constant string
- Added permission strings as properties of const Object
- Added some animation to display in console when the bot is restarting
- Changed error logging, now error names and error messages will be shown besides generic logging info
- Added additional check for if a message author is a bot user
- Added additional check for if a message is sent in DM channel (or group DM channel). Commands in DMs are not tested and may produce undesirable effects
- Added a helper function respondToNonCommands() for responding to users when ChillBot is mentioned outside of command executions
- Fixed a serious bug where if your message arguments contain more than one whitespace between them, commands would fail as a result of incorrect method of dealing with argument processing. Now you can add as many whitespaces as you like
- Added permission checking everywhere, SEND_MESSAGES is required for most commands and ADD_REACTIONS is required for "/help"
- Tweaked logic, only after the help message has been successfully sent will ChillBot add the reaction to the original message
- "/ship me" now accepts mixed case message too
- Greatly improved the handling for whitespaces, now the whitespaces will remain as they were when you use "/remindme" and "/give".
- Warn a user if DMs are unable to be sent, most likely because "Allow direct messages from server members" has been turned off
- Added a utility function isDeveloper() to check if the message author is one of the developers listed in the configuration.json
- Added "/restart" command to auto start ChillBot again after it shuts down by command
- Added "/opensourcelicenses" command to display all license information for used open source tools and libraries. The items are in the following order: node, npm, direct dependencies ordered by first alphabet of the name from A-Z, indirect dependencies ordered by first alphabet of the name from A-Z. For node and direct dependencies, version numbers are also displayed. Don't wilfully overuse the command, as it will flood the chat *and it is rather resource demanding for the bot*!
- Added "/changelog" command to display the changelog of the latest release of ChillBot. If a tag name is provided and the provided tag name exists, the changelog of the release corresponding to the tag name will be sent instead. Tag name must be in the format of a.b.c or va.b.c, where a, b, and c are numbers without leading 0s
- Added "/invite" command to send the link for inviting ChillBot to other Discord servers
- Errors are now handled more gracefully
- Added a helper function exitProcess(), to attempt to log out the bot and terminate the process. If "shouldRestart" is true, a new detached process will be spawned
- Added a helper function login()
- Added a utility function clientHasPermissionInChannel() to check if the bot client has certain permission(s) in a given channel
- Added a helper function getMatchedOriginalFromArgs() to match original message with RegExp constructed from the arguments array
- Added a helper function handleGenerically() for handling errors
- Added "start" command to "script" field
- Added "engines" field and "node" version
- Removed "Procfile", the leftover from Heroku hosting
- Added missing 2nd argument of parseInt()
- Log "Chilled!" only after the presence has been set, not before
- Used concise body for all arrow functions
- Moved bot token into token.json
- Added configuration.json for setting prefix and other configurations
- Moved "/remindme" time string length limit to a constant
- Added "/stop" command to properly terminate node process, usable by bot developers
- Added the ability to log bot token on login error. Only enabled when configuration "developmentEnvironment" is set to true.
- Refined "/give" messages
- Added getConfiguration() to get configurations from JSON files
- Changed heading in README.md to "ChillBot"
- Added "Commands" section to README.md for features overview
- Added new configuration "developerIDs" to configuration.json
- Removed all economy related features as discord-eco is deprecated
- Changed package description from "Chill" to "Chill!"
- Added license information to README.md and source files, corrected license information in other places
- Updated discord.js from 11.2.1 to 11.4.2
- Updated ms from 2.0.0 to 2.1.1
- Changed test script to exit with exit code 0
- Added .gitignore
- Changed author in package.json to match the one listed in LICENSE
- Used JSDoc style license block
- Added author doc
- Moved most constants out of functions to the top of script
- Reimplemented "8ball" and mention-to-respond features, and fixed the bugs in previous implementation. See 43600be and a67e789 .
- Fixed some typos and missing space in predefined responses
- Added "repository" command
- Chained calls as on() returns the bot client
- Replaced deprecated setGame() with setPresence()
- Changed all emojis in the source file and the shortname ( :emoji: ) to their JavaScript representations
- Properly utilize Promise, added more loggings too
- Used raw string literal syntax everywhere needed for consistency and readability
- Updated help message
- Removed the dangerous "eval" command
- Tried to prevent "ship" from shipping the same user with himself/herself/themselves
- Added checks to fail early for "remindme" command if the time string is too long, time string is invalid, or time is negative
- Updated behavior so that the bot only keep timers for at most 300 reminders by default. Upon exceeding the limit, the oldest timer is removed, and the new one is added. Note that the oldest timer might not actually be the one with the longest timeout.
- Added a check so that one can not give others items with negative numbers or 0
- Added hasMentionForUser() for checking if a message contains mentions for the specific user
- Added getRandomFromArray() utility function to get a random item from an array or an array like object
- Added bold() and code(), this addresses the issue where manually inserting * and ` in strings is more error prone.
- Added getFirstMentionedUser() to get the first mention in a message
- Added isInteger() utility function to quickly check if a string only contains 0 ~ 9 and optionally the "+" or "-" sign. Note that numbers presented in other formats will still make the function return false.
- Added createMentionForUser() to get a string in the format of a user mention
  • Loading branch information
LightWayUp committed Dec 14, 2018
1 parent f55b397 commit 14306ca
Show file tree
Hide file tree
Showing 19 changed files with 3,275 additions and 102 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Cache and additional info
Thumbs.db
.cache/
Desktop.ini
.DS_Store

# Node.js dependencies
node_modules/

# npm
.npmrc
package-lock.json

# Bot token
configurations/token.json
4 changes: 1 addition & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
MIT License

Copyright (c) 2017 vanishalways
Copyright (c) 2017-2018 VanishedApps

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

46 changes: 45 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,46 @@
# Chill
# ChillBot [![MIT License](https://img.shields.io/badge/license-MIT-0366d6.svg?longCache=true&style=flat-square)](/LICENSE) [![Invite ChillBot to server!](https://img.shields.io/badge/invite-to%20Discord-7289da.svg?longCache=true&style=flat-square&logo=discord)](https://discordapp.com/api/oauth2/authorize?client_id=511463919399731201&scope=bot&permissions=3136)
Chill!

ChillBot is a Discord bot. [View all available commands](#commands).

## Note
The project is in maintenance mode, which means bugs are fixed and pull requests are accepted, however no new features will be actively added.

## Commands
The prefix is `/`.

* `help` : Get a list of syntax for all implemented commands.
* `ping` : Get the ping of ChillBot.
* `ship [me]` : Ship two random users in the same guild. If "me" is present, ship another random user with you.
* `(reminder|remind|remindme) <time> <value>` : Remind you for something after the specified time. Time must not be negative.
* `give <mention> <amount> <item>` : Give someone something. Amount must be greater than 0 and less than or equal to 64.
* `(eightball|8ball) <value>` : Get an answer for a question. Note that you shouldn't always listen to what ChillBot says.
* `(source|github|repo|repository)` : Get information about ChillBot's source code repository.
* `stop` : Stop the bot. This command is only available for developers of ChillBot.
* `restart` : Restart the bot in a new instance of Node.js. This command is only available for developers of ChillBot.
* `(osslicenses|opensourcelicenses)` : Get licenses information and notices about ChillBot's dependencies, used tools and JavaScript runtime.
* `(changes|changelog|changelogs) [tagName]` : Get changelog for the latest release. If "tagName" is present and corresponds to a release, get the changelog for the specific release.
* `invite` : Get the link to invite ChillBot to a server.

## License
Chill is licensed under [MIT License](/LICENSE).

> Copyright (c) 2017-2018 VanishedApps
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all
> copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> SOFTWARE.
16 changes: 16 additions & 0 deletions configurations/configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"restartTimeout": 3000,
"presenceName": "In maintenance mode \ud83d\udd3a | Chilling.",
"prefix": "/",
"shipMaxAttempts": 10,
"listMaxEntries": 300,
"giveMaxAmount": 64,
"changelogFetchTimeout": 5000,
"developerIDs": [
"313314003562528768"
],
"developmentGuildIDs": [
"511620513643364353"
],
"developmentEnvironment": false
}
3 changes: 3 additions & 0 deletions configurations/token-example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"token": "Please-put-your-Discord-application-58digit-bot-token-here"
}
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 14306ca

Please sign in to comment.