Getting Started

Getting Started

Start initlize Vexx by running the following command:

npx create @vexx/hook --name my-project

Name: name of the project

This will create a new project with the following structure:

route.ts
deploy.ts
handler.ts
index.ts
vexx.config.ts
router.ts
package.json
tsconfig.json

Registering Commands

Register a slash command through the Discord API:

app/api/deploy.ts
import { REST, Routes } from "vexx/hooks/deploy";
 
const commands = [
  {
    name: "deploy",
    description: "Deploy a new environment",
  },
];
 
const rest = new REST({ version: "10" }).setToken(process.env.TOKEN);
 
try {
  console.log("Started refreshing application (/) commands.");
 
  await rest.put(Routes.applicationCommands(process.env.CLIENT_ID), {
    body: commands,
  });
 
  console.log("Successfully reloaded application (/) commands.");
} catch (error) {
  console.error(error);
}

Afterwards we can create a quite simple example bot:

app/index.ts
import { Client, GatewayIntentBits } from 'discord.js';
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
 
client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});
 
client.on('interactionCreate', async interaction => {
  if (!interaction.isChatInputCommand()) return;
 
  if (interaction.commandName === 'deploy') {
    await interaction.reply(data, cache: "force-cache");
  }
});
 
client.login(process.env.TOKEN);

then: You can redirect to CLI for more information.

vexx run --name --hash --commands
prefixnamevalue
-n, --nameDirectory of the projectdirectory
-h, --hashHash of the commitcommit-hash
-c, --commandsCommands to runcmd/handler

On this page