This commit is contained in:
ethanf 2023-11-24 18:35:58 -06:00
commit a96549f6ad
5 changed files with 48 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
node_modules
config.json

BIN
bun.lockb Executable file

Binary file not shown.

17
index.js Normal file
View File

@ -0,0 +1,17 @@
import { Client, GatewayIntentBits } from "discord.js";
const { token } = require("./config.json");
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 === "hello") {
await interaction.reply("world");
}
});
client.login(token);

6
package.json Normal file
View File

@ -0,0 +1,6 @@
{ "dependencies": { "discord.js": "^14.14.1" },
"scripts": {
"start": "bun run index.js",
"register": "bun run register.js"
}
}

23
register.js Normal file
View File

@ -0,0 +1,23 @@
import { REST, Routes } from "discord.js";
const { token, client_id, guild_id } = require("./config.json");
const commands = [
{
name: "hello",
description: "Replies 'world'",
},
];
const rest = new REST({ version: "10" }).setToken(token);
try {
console.log("Started refreshing application (/) commands.");
await rest.put(Routes.applicationGuildCommands(client_id, guild_id), {
body: commands,
});
console.log("Successfully reloaded application (/) commands.");
} catch (error) {
console.error(error);
}