-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
78 additions
and
136 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { SecretManagerServiceClient } from '@google-cloud/secret-manager'; | ||
|
||
export const getSlackToken = async () => { | ||
const client = new SecretManagerServiceClient(); | ||
const [secret] = await client.accessSecretVersion({ | ||
name: 'projects/588063171007/secrets/SLACK_BOT_TOKEN/versions/latest', | ||
}); | ||
return secret.payload.data.toString(); | ||
}; |
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 @@ | ||
export const DISCORD_API_TOKEN = | ||
'projects/588063171007/secrets/DISCORD_API_TOKEN/versions/latest'; | ||
|
||
export const DISCORD_API_DEV_TOKEN = | ||
'projects/588063171007/secrets/DISCORD_API_DEV_TOKEN/versions/latest'; |
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,27 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { Context, SlashCommand, SlashCommandContext } from 'necord'; | ||
import { DEV_GUILDS } from '../../../constants'; | ||
|
||
@Injectable() | ||
export class DiscordPingService { | ||
@SlashCommand({ | ||
name: 'hello', | ||
description: 'Ping-Pong Command', | ||
}) | ||
public async onPing(@Context() [interaction]: SlashCommandContext) { | ||
console.log('hello'); | ||
public async handleHelloPingCommand( | ||
@Context() [interaction]: SlashCommandContext, | ||
) { | ||
return interaction.reply({ content: 'Pong!' }); | ||
} | ||
|
||
@SlashCommand({ | ||
name: 'wow', | ||
description: 'Wow Command', | ||
guilds: DEV_GUILDS, | ||
}) | ||
public async handleWowSlashCommand( | ||
@Context() [interaction]: SlashCommandContext, | ||
) { | ||
return interaction.reply({ content: 'Woweeeee!!!!' }); | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
.../discord/services/discordReady.service.ts → ...d/services/discordReadyLogging.service.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 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
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,14 @@ | ||
import { SlackModule } from 'nestjs-slack'; | ||
import { getSlackToken } from '../../appSecrets/getSlackToken'; | ||
|
||
export const createSlackModule = () => { | ||
return SlackModule.forRootAsync({ | ||
useFactory: async () => { | ||
return { | ||
token: await getSlackToken(), | ||
type: 'api', | ||
defaultChannel: 'bot-playground', | ||
}; | ||
}, | ||
}); | ||
}; |
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,17 +1,10 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { SlackModule } from 'nestjs-slack'; | ||
import { SlackConfigService } from './slackConfig.service'; | ||
import { GcpModule } from '../../gcp/gcp.module'; | ||
import { SlackTestService } from './slackTest.service'; | ||
import { createSlackModule } from './createSlackModule'; | ||
|
||
@Module({ | ||
// imports: [ | ||
// SlackModule.forRootAsync({ | ||
// imports: [GcpModule], | ||
// useClass: SlackConfigService, | ||
// }), | ||
// GcpModule, | ||
// ], | ||
// providers: [SlackConfigService], | ||
// exports: [SlackConfigService], | ||
imports: [createSlackModule(), GcpModule], | ||
providers: [SlackTestService], | ||
}) | ||
export class MySlackModule {} |
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 |
---|---|---|
@@ -1,72 +1,12 @@ | ||
// import {Injectable} from '@nestjs/common'; | ||
// import {Action, Command, Event, Message} from 'nestjs-slack-bolt'; | ||
// import {SlackActionMiddlewareArgs, SlackCommandMiddlewareArgs, SlackEventMiddlewareArgs,} from '@slack/bolt'; | ||
// | ||
// @Injectable() | ||
// export class SlackTestService { | ||
// @Message('hi') //Handle a message event | ||
// message({say}: SlackEventMiddlewareArgs) { | ||
// say('Hello'); | ||
// } | ||
// | ||
// @Action('click') //Handle an action | ||
// action({say}: SlackActionMiddlewareArgs) { | ||
// say('click event received'); | ||
// } | ||
// | ||
// @Command('/list') // handle command | ||
// command({say}: SlackCommandMiddlewareArgs) { | ||
// say('/list command received'); | ||
// } | ||
// | ||
// @Event('app_home_opened') | ||
// event({say}: SlackEventMiddlewareArgs) { | ||
// say('app_open_event received'); | ||
// } | ||
// | ||
// @Shortcut('test_shortcut') //Handle a shortcut event | ||
// async shortcut({shortcut, ack, client, logger}) { | ||
// try { | ||
// // Acknowledge shortcut request | ||
// await ack(); | ||
// | ||
// // Call the views.open method using one of the built-in WebClients | ||
// const result = await client.views.open({ | ||
// trigger_id: shortcut.trigger_id, | ||
// view: { | ||
// type: 'modal', | ||
// title: { | ||
// type: 'plain_text', | ||
// text: 'My App', | ||
// }, | ||
// close: { | ||
// type: 'plain_text', | ||
// text: 'Close', | ||
// }, | ||
// blocks: [ | ||
// { | ||
// type: 'section', | ||
// text: { | ||
// type: 'mrkdwn', | ||
// text: 'About the simplest modal you could conceive of :smile:\n\nMaybe <https://api.slack.com/reference/block-kit/interactive-components|*make the modal interactive*> or <https://api.slack.com/surfaces/modals/using#modifying|*learn more advanced modal use cases*>.', | ||
// }, | ||
// }, | ||
// { | ||
// type: 'context', | ||
// elements: [ | ||
// { | ||
// type: 'mrkdwn', | ||
// text: 'Psssst this modal was designed using <https://api.slack.com/tools/block-kit-builder|*Block Kit Builder*>', | ||
// }, | ||
// ], | ||
// }, | ||
// ], | ||
// }, | ||
// }); | ||
// | ||
// logger.info(result); | ||
// } catch (error) { | ||
// logger.error(error); | ||
// } | ||
// } | ||
// } | ||
import { Injectable } from '@nestjs/common'; | ||
import { SlackService } from 'nestjs-slack'; | ||
|
||
@Injectable() | ||
export class SlackTestService { | ||
constructor(private service: SlackService) {} | ||
|
||
async helloWorldMethod() { | ||
await this.service.sendText('Hello world was sent!'); | ||
return 'hello world'; | ||
} | ||
} |
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