File tree Expand file tree Collapse file tree 3 files changed +58
-0
lines changed
src/interactions/commands Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import { saySlashCommand } from './handlers/say-slash';
1818import { sendToQuestionsContextMenuCommand } from './handlers/send-to-questions-context' ;
1919import { sendToIssuesContextMenuCommand } from './handlers/send-to-issues-context' ;
2020import { randomFeaturedSlashCommand } from './handlers/random-featured-slash' ;
21+ import { docsSlashCommand } from './handlers/docs/docs-slash' ;
2122
2223class CommandManager implements IInteractionManager {
2324 private handlers : ICommandHandler [ ] = [ ] ;
@@ -38,6 +39,7 @@ class CommandManager implements IInteractionManager {
3839 sendToIssuesContextMenuCommand ,
3940 sendToQuestionsContextMenuCommand ,
4041 randomFeaturedSlashCommand ,
42+ docsSlashCommand ,
4143 ] ;
4244
4345 for ( const handler of commandsToRegister ) {
Original file line number Diff line number Diff line change 1+ export const documentationPages : Array < {
2+ name : string ;
3+ url : string ;
4+ } > = [
5+ {
6+ name : 'Custom Scripts' ,
7+ url : 'https://docs.firebot.app/v5/dev/scripts' ,
8+ } ,
9+ {
10+ name : 'Dev Environment Setup' ,
11+ url : 'https://docs.firebot.app/v5/dev/environment-setup' ,
12+ } ,
13+ ] ;
Original file line number Diff line number Diff line change 1+ import { SlashCommandBuilder } from 'discord.js' ;
2+ import { CommandType , ICommandHandler } from '../../command-handler.interface' ;
3+ import { documentationPages } from './doc-pages' ;
4+
5+ const config = new SlashCommandBuilder ( )
6+ . setName ( 'docs' )
7+ . setDescription ( 'Link to Firebot Docs' )
8+ . addStringOption ( ( option ) =>
9+ option
10+ . setName ( 'page' )
11+ . setDescription ( 'The page to link to' )
12+ . setRequired ( false )
13+ . setChoices (
14+ documentationPages . map ( ( p ) => ( {
15+ name : p . name ,
16+ value : p . name ,
17+ } ) )
18+ )
19+ ) ;
20+
21+ export const docsSlashCommand : ICommandHandler = {
22+ type : CommandType . SlashCommand ,
23+ config,
24+ async onTrigger ( interaction ) {
25+ await interaction . deferReply ( ) ;
26+
27+ const pageName = interaction . options . getString ( 'page' ) ;
28+
29+ if ( ! pageName ) {
30+ await interaction . editReply ( {
31+ content :
32+ 'Firebot documentation is available at https://docs.firebot.app' ,
33+ } ) ;
34+ return ;
35+ }
36+
37+ const page = documentationPages . find ( ( p ) => p . name === pageName ) ;
38+
39+ await interaction . editReply ( {
40+ content : `Check out the ${ page . name } documentation here: ${ page . url } ` ,
41+ } ) ;
42+ } ,
43+ } ;
You can’t perform that action at this time.
0 commit comments