init
This commit is contained in:
commit
a96549f6ad
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
node_modules
|
||||||
|
config.json
|
||||||
17
index.js
Normal file
17
index.js
Normal 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
6
package.json
Normal 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
23
register.js
Normal 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);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user