-
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
Open
PongDev
wants to merge
14
commits into
beta
Choose a base branch
from
PongDev-Leo/discord-bot
base: beta
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
517dc4c
Initialize Discord Bot Apps
PongDev e6ab576
Add discord.js package
PongDev c68d72f
Scaffolding Discord Bot
PongDev 980d6b0
Implement Ping-Pong
PongDev e6c4005
Implement Basic Database with SQLite
PongDev 15b4d6a
Add Scheduler to Send Message At Specific Time
PongDev eee2558
Add Google Analytic Data API
PongDev bda7fa5
fix: possible crash due to un-awaited save
saengowp 87c8541
remove deploy stage in action
bombnp 5372002
fix gened section data
bombnp f9f6a5c
Add Image Report
PongDev b6461ae
fix: merge commit
PongDev 2cb0093
refactor: as recommended by comment
PongDev 8811d82
refactor: rename hook type file from hook.ts to type.ts
PongDev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { ICommand } from './ICommand' | ||
import { PingCommand } from './ping' | ||
import { RegisterReportChannelCommand } from './registerReportChannel' | ||
|
||
export const commands: ICommand[] = [PingCommand, RegisterReportChannelCommand] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { ChatInputCommandInteraction, Client, TextChannel } from 'discord.js' | ||
import { ChatInputCommandInteraction } from 'discord.js' | ||
|
||
import { CUGetReg } from '../core/CUGetReg' | ||
import { ICommand } from './ICommand' | ||
|
||
export const RegisterReportChannelCommand: ICommand = { | ||
name: 'register_report_channel', | ||
description: 'Register Channel for Retriving Reports', | ||
description: 'channel to receive reports', | ||
execute: async (client: CUGetReg, interaction: ChatInputCommandInteraction): Promise<void> => { | ||
await client.db.saveRegisterReportChannel(interaction.guildId, interaction.channelId) | ||
console.log(await client.db.getAllReportChannels()) | ||
|
||
interaction.reply('Channel Registered!') | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
import { AttachmentBuilder, Client, GatewayIntentBits, TextChannel } from 'discord.js' | ||
import * as cron from 'node-cron' | ||
|
||
import { commands } from '../command' | ||
import { ICommand } from '../command/ICommand' | ||
import { database } from '../database' | ||
import { IDatabase } from '../database/IDatabase' | ||
import { HookFunction } from '../hook/hook' | ||
import { hooks } from '../hook' | ||
import { HookFunction } from '../hook/type' | ||
import { scheduler } from '../scheduler' | ||
import { IScheduler } from '../scheduler/IScheduler' | ||
import { CUGetRegCommands } from './CUGetRegCommands' | ||
import { CUGetRegDatabase } from './CUGetRegDatabase' | ||
import { CUGetRegHooks } from './CUGetRegHooks' | ||
import { CUGetRegScheduler } from './CUGetRegScheduler' | ||
|
||
export class CUGetReg extends Client { | ||
private commandList = new Map<string, ICommand>() | ||
private database: IDatabase = CUGetRegDatabase | ||
private _commandList = new Map<string, ICommand>() | ||
private _database: IDatabase = database | ||
|
||
constructor(token: string) { | ||
super({ intents: [GatewayIntentBits.Guilds] }) | ||
this.login(token) | ||
this.addHook(CUGetRegHooks) | ||
this.registerCommand(CUGetRegCommands) | ||
this.registerScheduler(CUGetRegScheduler) | ||
this.addHook(hooks) | ||
this.registerCommand(commands) | ||
this.registerScheduler(scheduler) | ||
} | ||
|
||
addHook(hookFunctions: HookFunction[]): void { | ||
|
@@ -28,7 +28,7 @@ export class CUGetReg extends Client { | |
|
||
registerCommand(commands: ICommand[]): void { | ||
commands.forEach((command) => { | ||
this.commandList.set(command.name, command) | ||
this._commandList.set(command.name, command) | ||
}) | ||
} | ||
|
||
|
@@ -52,10 +52,10 @@ export class CUGetReg extends Client { | |
} | ||
|
||
get commands(): Map<string, ICommand> { | ||
return this.commandList | ||
return this._commandList | ||
} | ||
|
||
get db(): IDatabase { | ||
return this.database | ||
return this._database | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same goes here |
||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { IDatabase } from './IDatabase' | ||
import { SQLiteDatabaseDriver } from './sqlite/SQLiteDatabaseDriver' | ||
|
||
export const database: IDatabase = new SQLiteDatabaseDriver() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
apps/discord-bot/src/google-analytic/type.ts → .../discord-bot/src/google-analytics/type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { CommandHook } from './command' | ||
import { ReadyHook } from './ready' | ||
import { HookFunction } from './type' | ||
|
||
export const hooks: HookFunction[] = [ReadyHook, CommandHook] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { IScheduler } from './IScheduler' | ||
import { ReportChannelScheduler } from './reportChannelScheduler' | ||
|
||
export const scheduler: IScheduler[] = [ReportChannelScheduler] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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