tomassirio / listbot Goto Github PK
View Code? Open in Web Editor NEWListBot is a Discord Bot which let's you create community lists on each channel.
Home Page: https://discord.io/siriobots
License: MIT License
ListBot is a Discord Bot which let's you create community lists on each channel.
Home Page: https://discord.io/siriobots
License: MIT License
The list command output looks kind of bad. See if you can make it any better
The Add command let's you add only one element to the list. Add a MultiAdd command that lets you add more than one on a single command
If you try to use this bot in discord, after install the application with the bot, if you try to execute the list
command it thros a fatal exception and stops the server service:
In order to reproduce this:
Is your feature request related to a problem? Please describe.
This is more of a code refactoring request than a feature request. The use of process.env
is sprinkled throughout the ListBot code base instead of utilizing the main config
object (from src/config/index.js
).
Describe the solution you'd like
It would be better if all configuration for the bot was accessed through the main config
object instead of using process.env
. This makes all possible settings/configuration for the bot "knowable" by reading through the config file settings (i.e. no need to search for usages of process.env
in the code to see what can/should be set in the .env
file or external environment variables).
This refactoring would need the following:
process.env
and, where possible, update them so that the setting value is using the corresponding property from the main config
object.process.env
to come from the main config file, document the reason why and include a section explaining how the setting should be set in an environemnet variable and what the setting controls in the src/config/.env.example
file.Hi @tomassirio, I liked your project and added locally a $remind command so the bot in Discord can remind you of a certain element after n minutes.
If you like it I can pull it for your review. :)
2020-10-15T12:29:17.044062+00:00 app[worker.1]: /app/src/commands/poll.js:127
2020-10-15T12:29:17.044089+00:00 app[worker.1]: }
2020-10-15T12:29:17.044089+00:00 app[worker.1]: ^
2020-10-15T12:29:17.044089+00:00 app[worker.1]:
2020-10-15T12:29:17.044090+00:00 app[worker.1]: SyntaxError: Unexpected token '}'
2020-10-15T12:29:17.044091+00:00 app[worker.1]: at wrapSafe (internal/modules/cjs/loader.js:979:16)
2020-10-15T12:29:17.044091+00:00 app[worker.1]: at Module._compile (internal/modules/cjs/loader.js:1027:27)
2020-10-15T12:29:17.044138+00:00 app[worker.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
2020-10-15T12:29:17.044139+00:00 app[worker.1]: at Module.load (internal/modules/cjs/loader.js:928:32)
2020-10-15T12:29:17.044140+00:00 app[worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:769:14)
2020-10-15T12:29:17.044140+00:00 app[worker.1]: at Module.require (internal/modules/cjs/loader.js:952:19)
2020-10-15T12:29:17.044140+00:00 app[worker.1]: at require (internal/modules/cjs/helpers.js:88:18)
2020-10-15T12:29:17.044141+00:00 app[worker.1]: at module.exports (/app/src/handlers/command.js:12:22)
2020-10-15T12:29:17.044141+00:00 app[worker.1]: at /app/src/index.js:16:37
2020-10-15T12:29:17.044141+00:00 app[worker.1]: at Array.forEach ()
2020-10-15T12:29:17.044142+00:00 app[worker.1]: at Object. (/app/src/index.js:14:14)
2020-10-15T12:29:17.044142+00:00 app[worker.1]: at Module._compile (internal/modules/cjs/loader.js:1063:30)
2020-10-15T12:29:17.044142+00:00 app[worker.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
2020-10-15T12:29:17.044142+00:00 app[worker.1]: at Module.load (internal/modules/cjs/loader.js:928:32)
2020-10-15T12:29:17.044143+00:00 app[worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:769:14)
2020-10-15T12:29:17.044149+00:00 app[worker.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
2020-10-15T12:29:17.117259+00:00 heroku[worker.1]: Process exited with status 1
As a good practice, we use to add the .env
file to the git repository, this is because the .env
file use to have confidential information about the server and connection.
If we want to preserve the possible entries, we should create a .env.example
file which has the requires structure.
Describe the bug
It seems that after some of the refactoring that's been performed recently, the code in src/commands/info/commands.js
is no longer in use. It makes sense to delete this file from the repo.
This repo is getting popular, what do you think if we create a suite of tests to ensure that the incoming pull request does not broke anything?
Polling command accepts a time element for the polling but that is not documented inside the README.md.
Better documentation suggested.
Latest features of NodeJS, also known as EcmaScript 2017 and above, won't work in older versions than Node 8.0, in order to run scripts with all the features available, we should wrap the code using babel and polyfill.
The idea is the follwoing:
javascript
files to the src
directory.production
in order to connect with the real mognodb parameters.src
directory should be transpiled into the build
directory using babel an polyfill.Easy for beginners. This is all about lists in the end
Comes from issue #76
The command should check if the user calling it is an Admin. It should receive as parameter a user (fe: $promote @tomassirio).
The person that adds ListBot to a server should be the first admin
For example:
In the general channel, only the admins will have permission to add/remove on a list. The users will be able to only see what's on a list
As stated by @medusalix:
The Remove command let's you remove only one element to the list. Add a MultiRemove command that lets you remove more than one on a single command
change from ../CHANGELOG to ../../CHANGELOG
As apointed by @rgroves:
Also, it looks like the code base is in a somewhat broken state. I had to modify src\commands\polls.js to remove an error and modify the devMongoUrl connection string in src\config\index.js. (Note: I was not using Docker)
Data is private. We need to encrypt the Discord channels, users, and elements added to the list when we are saving them to the Db instance.
A next issue will add a secret key for the Hash function
As appointed by @rgroves:
It also looks like linting checks may have been modified or added, because it looks like files that weren't part of my PR changes are failing checks. Let me know how to proceed or if this is fine. Thanks!
It's added on the Readme. You can join here
It's still barebones but we might make it harder, better, faster, stronger
Same as de $promote command. This command should check if the user calling it is an admin. Removes the admin role of the user passed as parameter (if this user was an admin before, of course)
I created that badge using Shields.io Think you can fix it?
Comes from a discussion on Issue #27
Apparently the remove command is not removing the element associated to the DB
(node:48710) UnhandledPromiseRejectionWarning: MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/
at NativeConnection.Connection.openUri (/Users/tomassirio/Bots/DiscordBot/node_modules/mongoose/lib/connection.js:800:32)
at /Users/tomassirio/Bots/DiscordBot/node_modules/mongoose/lib/index.js:341:10
at /Users/tomassirio/Bots/DiscordBot/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:5
at new Promise ()
at promiseOrCallback (/Users/tomassirio/Bots/DiscordBot/node_modules/mongoose/lib/helpers/promiseOrCallback.js:30:10)
at Mongoose.connect (/Users/tomassirio/Bots/DiscordBot/node_modules/mongoose/lib/index.js:340:10)
at _callee$ (/Users/tomassirio/Bots/DiscordBot/build/utils/mongoose.js:55:31)
at tryCatch (/Users/tomassirio/Bots/DiscordBot/node_modules/regenerator-runtime/runtime.js:63:40)
at Generator.invoke [as _invoke] (/Users/tomassirio/Bots/DiscordBot/node_modules/regenerator-runtime/runtime.js:293:22)
at Generator.next (/Users/tomassirio/Bots/DiscordBot/node_modules/regenerator-runtime/runtime.js:118:21)
at asyncGeneratorStep (/Users/tomassirio/Bots/DiscordBot/build/utils/mongoose.js:3:103)
at _next (/Users/tomassirio/Bots/DiscordBot/build/utils/mongoose.js:5:194)
at /Users/tomassirio/Bots/DiscordBot/build/utils/mongoose.js:5:364
at new Promise ()
at Object. (/Users/tomassirio/Bots/DiscordBot/build/utils/mongoose.js:5:97)
at Object.init (/Users/tomassirio/Bots/DiscordBot/build/utils/mongoose.js:69:20)
(Usenode --trace-warnings ...
to show where the warning was created)
(node:48710) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:48710) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
2020-10-09T14:31:08.410764+00:00 app[worker.1]: /app/src/commands/ping.js:17
2020-10-09T14:31:08.410783+00:00 app[worker.1]: } catch (error) {
2020-10-09T14:31:08.410784+00:00 app[worker.1]: ^^^^^
2020-10-09T14:31:08.410784+00:00 app[worker.1]:
2020-10-09T14:31:08.410785+00:00 app[worker.1]: SyntaxError: Unexpected token 'catch'
2020-10-09T14:31:08.410785+00:00 app[worker.1]: at compileFunction ()
2020-10-09T14:31:08.410786+00:00 app[worker.1]: at wrapSafe (internal/modules/cjs/loader.js:931:16)
2020-10-09T14:31:08.410786+00:00 app[worker.1]: at Module._compile (internal/modules/cjs/loader.js:979:27)
2020-10-09T14:31:08.410786+00:00 app[worker.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
2020-10-09T14:31:08.410787+00:00 app[worker.1]: at Module.load (internal/modules/cjs/loader.js:879:32)
2020-10-09T14:31:08.410787+00:00 app[worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:724:14)
2020-10-09T14:31:08.410787+00:00 app[worker.1]: at Module.require (internal/modules/cjs/loader.js:903:19)
2020-10-09T14:31:08.410788+00:00 app[worker.1]: at require (internal/modules/cjs/helpers.js:74:18)
2020-10-09T14:31:08.410788+00:00 app[worker.1]: at module.exports (/app/src/handlers/command.js:10:16)
2020-10-09T14:31:08.410788+00:00 app[worker.1]: at /app/src/index.js:15:37
2020-10-09T14:31:08.410789+00:00 app[worker.1]: at Array.forEach ()
2020-10-09T14:31:08.410789+00:00 app[worker.1]: at Object. (/app/src/index.js:14:13)
2020-10-09T14:31:08.410789+00:00 app[worker.1]: at Module._compile (internal/modules/cjs/loader.js:1015:30)
2020-10-09T14:31:08.410790+00:00 app[worker.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
2020-10-09T14:31:08.410790+00:00 app[worker.1]: at Module.load (internal/modules/cjs/loader.js:879:32)
2020-10-09T14:31:08.410790+00:00 app[worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:724:14)
2020-10-09T14:31:08.529644+00:00 heroku[worker.1]: Process exited with status 1
Basically the poll never shows the results given the votes on the emojis
The bot is really sloppy since it was a hobby project. If you want to change something or make something look better, then give it a try
Describe the bug
When a poll is started the bot should announce the poll via a message and create the initial reacts that are to be used for voting on that message. Currently, when a poll with no time limit is created the initial reacts are not created.
To Reproduce
Steps to reproduce the behavior:
$poll
without specifying a time parameter or use zero, $poll 0
Expected behavior
After the poll command is issued, the bot should announce the poll and create the initial reacts that are used to vote, regardless of if the bot has a time duration associated with it.
Screenshots
Here is what a poll without a time parameter looks like currently. Notice there are no reacts available for voting
This is what a poll with a time parameter supplied looks like. Notice the bot supplied the initial reacts that are to be used for voting.
I was thinking that it could be added as an exception on the add command or add many.
But it could be whatever you feel up to
I have noticed that the project require some extra steps to be executed in local environments, as well, as some good practices that we could implement in here.
I have created a PR with 3 main changes:
.env.example
file to store the constants of the project, this will allow you to have your own copy of .env
file with your personal information.node_modules
from the git repository, since it could be easilly installes by running the npm install
or yarn install
command, also, the node_modules is the bigger in all the project.The PR with this changes is this one: #15
Mostly for users and admin purposes
- The project should really follow a consistent code style: Semicolons/no semicolons, double quotes/single quotes, let for constant variables, etc... I'd suggest using a combination of Prettier and ESLint. Makes contributing so much easier.
My suggestions would be: No semicolons, single quotes and let for variables.
However, i'm not an experienced Node.js developer. So any suggestions, such as Prettier and ESLint as stated before will be considered
Describe the bug
When a poll is started and the list has less than 5 items, the bot provides all 5 reacts for voting.
To Reproduce
Steps to reproduce the behavior:
$poll 1
Expected behavior
When a poll is started and the list has less than 5 items, the bot provides should only provide a number of reacts equal to the number of items being voted on. (e.g. if only two items in list, initial reacts should be: 1️⃣ & 2️⃣; for 3 items 1️⃣, 2️⃣, 3️⃣; etc.)
Screenshots
Here you can see a 1 minute poll run in a channel where there are only two items available in the list, yet the bot supplies all 5 reacts for voting, when it should only have two so that it matches the number of items being voted on.
(node:4) UnhandledPromiseRejectionWarning: ReferenceError: client is not defined
2020-10-09T23:33:01.843042+00:00 app[worker.1]: at Object.execute (/app/src/commands/ping.js:11:45)
2020-10-09T23:33:01.843044+00:00 app[worker.1]: at processTicksAndRejections (internal/process/task_queues.js:97:5)
2020-10-09T23:33:01.843137+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
2020-10-09T23:33:01.847679+00:00 app[worker.1]: (node:4) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
That was the issue with ping
That was the issue with ping in heroku's log
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.