Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/interactions/commands/command-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { saySlashCommand } from './handlers/say-slash';
import { sendToQuestionsContextMenuCommand } from './handlers/send-to-questions-context';
import { sendToIssuesContextMenuCommand } from './handlers/send-to-issues-context';
import { randomFeaturedSlashCommand } from './handlers/random-featured-slash';
import { docsSlashCommand } from './handlers/docs/docs-slash';

class CommandManager implements IInteractionManager {
private handlers: ICommandHandler[] = [];
Expand All @@ -38,6 +39,7 @@ class CommandManager implements IInteractionManager {
sendToIssuesContextMenuCommand,
sendToQuestionsContextMenuCommand,
randomFeaturedSlashCommand,
docsSlashCommand,
];

for (const handler of commandsToRegister) {
Expand Down
13 changes: 13 additions & 0 deletions src/interactions/commands/handlers/docs/doc-pages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export const documentationPages: Array<{
name: string;
url: string;
}> = [
{
name: 'Custom Scripts',
url: 'https://docs.firebot.app/v5/dev/scripts',
},
{
name: 'Dev Environment Setup',
url: 'https://docs.firebot.app/v5/dev/environment-setup',
},
];
43 changes: 43 additions & 0 deletions src/interactions/commands/handlers/docs/docs-slash.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { SlashCommandBuilder } from 'discord.js';
import { CommandType, ICommandHandler } from '../../command-handler.interface';
import { documentationPages } from './doc-pages';

const config = new SlashCommandBuilder()
.setName('docs')
.setDescription('Link to Firebot Docs')
.addStringOption((option) =>
option
.setName('page')
.setDescription('The page to link to')
.setRequired(false)
.setChoices(
documentationPages.map((p) => ({
name: p.name,
value: p.name,
}))
)
);

export const docsSlashCommand: ICommandHandler = {
type: CommandType.SlashCommand,
config,
async onTrigger(interaction) {
await interaction.deferReply();

const pageName = interaction.options.getString('page');

if (!pageName) {
await interaction.editReply({
content:
'Firebot documentation is available at https://docs.firebot.app',
});
return;
}

const page = documentationPages.find((p) => p.name === pageName);

await interaction.editReply({
content: `Check out the ${page.name} documentation here: ${page.url}`,
});
},
};