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:
Register a slash command through the Discord API:
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:
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
| prefix | name | value |
|---|
-n, --name | Directory of the project | directory |
-h, --hash | Hash of the commit | commit-hash |
-c, --commands | Commands to run | cmd/handler |