-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat(discord-bot): Implement Discord Bot Prototype #468
base: beta
Are you sure you want to change the base?
Conversation
Please fix conflict so I can review don't force push |
Can you explain more about the features of this bot. It would be great if you put some image what bot can do here. Please explain as much as possible you can. So, we'll review this feature later |
d05d214
to
b6461ae
Compare
I merge wrong branch ;w; |
This is a prototype of a discord bot, for now it main feature is summary user usage for 1 week, however the core module of this bot support many metric and dimension for used in further. This prototype design based on issue 439. (#439) |
What does the report look like when the bot send a it into Discord? |
Look like this for example, actually it support both text message and image but text message format is not yet discuss to other, so it has core code and template for that for now. However from the code, text command can be code in very short time (estimate may be < 1 week) The bot use slash command to register channel to send report and report will send at specific cron job time |
Note that this is only a prototype of CU Get Reg Bot, for further improvement I think we should discuss for more further information to used in development |
package.json
Outdated
"slate-react": "^0.82.0", | ||
"styled-components": "^5.3.5", | ||
"tough-cookie": "^4.0.0", | ||
"tslib": "^2.4.0", | ||
"uuid": "^8.3.2", | ||
"winston": "^3.8.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are these guys moved to devDependencies? these are prod deps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will move it, it may due to fix merge conflict
{ | ||
"extends": ["../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this file here for? doesn't this literally ignore every error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is copy from apps/api/.eslintrc.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you recommend how I should lint this apps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@saenyakorn did u add this in api?
get commands(): Map<string, ICommand> { | ||
return this.commandList | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's best if you keep the getter and private variable the same name, but prefix private var with underscore _
.
get commands(): Map<string, ICommand> { | |
return this.commandList | |
} | |
get commands(): Map<string, ICommand> { | |
return this._commands | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will do as your recommended. Also can you provided me convention reference, so I can know more info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't really have it, it's what i've seen and it really is easier to understand
import { PingCommand } from '../command/ping' | ||
import { RegisterReportChannelCommand } from '../command/registerReportChannel' | ||
|
||
export const CUGetRegCommands: ICommand[] = [PingCommand, RegisterReportChannelCommand] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also i think it's unnecessary to prefix everything with CUGetReg
. Leave things as like commands
, hooks
, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see
@@ -0,0 +1,53 @@ | |||
import { GoogleAnalyticData } from './google-analytic' | |||
|
|||
export class GoogleAnalyticDataExtended extends GoogleAnalyticData { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just put this in GoogleAnalyticData
if we're only gonna use the extended version only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
especially since GoogleAnalyticData
is our own class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for reusable of class, since GoogleAnalyticsData is core system of google analytics which directly use google analytics api, however GoogleAnalyticsDataExtended is only a set of command that a shortcut of calling core analytics command.
So the main reason is to separate between the necessary one and the shortcut one, however any other solution is accept if you have recommended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's literally no reason to split up the code into an "Extended" version, when the subclass is already our code in our repo and you're always going to use the extended one. This is way harder to read imo. Put it in the same class.
In fact, the only core method
that interfaces directly with the google analytics api is the getMetrics
method, which it literally just an http client.
} | ||
|
||
try { | ||
await command.execute(client, interaction) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
get db(): IDatabase { | ||
return this.database | ||
return this._database |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same goes here
get commands(): Map<string, ICommand> { | ||
return this.commandList | ||
return this._commandList | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i meant get commands()
should match the private variable name _commands
not _commandList
Why is there so many package.json changes (package name ordering is out of place, versions are upgraded)? That should not happen when you add new packages for your new app. Since we're using the same package.json for every single app, changing so many dependencies could break other apps and should be avoided. |
In fact, i'd say do this:
|
Because we may have other features for Discord bot like #438, I would like you to use discord-nestjs, the powerful DiscordJS-wrapper library based on Nestjs, as a main library for implementing Discord bot. Since, Nestjs is fully come with Typescript and Decorator that make other easy to read through the code. |
Here is the example repos that implemented with discord-nestjs. Feel free to copy the code from them. |
hold up this might conflict package.json with turborepo migration in #470 |
do you mean hold the pull request or hold the migration? |
hold the PR, as it would conflict the package.json a lot. U could keep on implementing the bot tho (like as @saenyakorn suggested), just be prepared to fix the package.json conflict |
u'll need to create a new package.json in your app directory with your own dependencies. No more piling every dependencies into single package.json at root. |
Why did you create this PR
What did you do
Demo
https://dev.cugetreg.com
Checklist