Initial bot code

This commit is contained in:
2025-07-31 02:43:35 -04:00
parent 44b65e5196
commit 54b8c67dd9
8 changed files with 1027 additions and 0 deletions

64
register.js Normal file
View File

@ -0,0 +1,64 @@
import 'dotenv/config';
import { REST, Routes } from 'discord.js';
const TOKEN = process.env.DISCORD_TOKEN;
const CLIENT_ID = process.env.DISCORD_CLIENT_ID;
const commands = [
{
name: 'register',
description: 'Send a registration message with a button'
},
{
name: 'load',
description: 'Load a list of Steam keys from a file',
options: [
{
name: 'file',
description: 'Text file with one Steam key per line',
type: 11, // Attachment
required: true
}
]
},
{
name: 'setlogging',
description: 'Set the logging channel for key warnings',
options: [
{
name: 'channel',
description: 'Channel to send logging messages to',
type: 7, // Channel
required: true
}
]
}
];
const rest = new REST({ version: '10' }).setToken(TOKEN);
(async () => {
try {
// Fetch all current global commands
const currentCommands = await rest.get(
Routes.applicationCommands(CLIENT_ID)
);
// Delete each existing command
for (const cmd of currentCommands) {
await rest.delete(
Routes.applicationCommand(CLIENT_ID, cmd.id)
);
console.log(`Deleted command: ${cmd.name}`);
}
// Register new commands
await rest.put(
Routes.applicationCommands(CLIENT_ID),
{ body: commands }
);
console.log('Global slash commands registered.');
} catch (error) {
console.error(error);
}
})();