Skip to content

Commit

Permalink
add distinction between commands and non-commands in deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
daniwasonline committed May 17, 2024
1 parent 8012a40 commit 5f4dda2
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/util/deploy.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import process from 'node:process';
import { URL } from 'node:url';
import { API } from '@discordjs/core/http-only';
import { REST } from 'discord.js';
import { Environment } from './helpers.js';
import { loadCommands } from './loaders.js';
import process from "node:process";
import { URL } from "node:url";
import { API } from "@discordjs/core/http-only";
import { REST } from "discord.js";
import { Environment } from "./helpers.js";
import { loadCommands } from "./loaders.js";

import chalk from 'chalk';
import chalk from "chalk";

export const cmdRollout = async () => {
const env = new Environment();

const commands = await loadCommands(new URL('../commands/', import.meta.url));
const commandData = [...commands.values()].map((command) => command.data);
const commands = await loadCommands(new URL("../commands/", import.meta.url));
const commandData = [...commands.values()]
.filter((c) => !c.type || c.type === "command")
.map((command) => command.data);

const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_TOKEN);
const rest = new REST({ version: "10" }).setToken(process.env.DISCORD_TOKEN);
const api = new API(rest);

const result =
env.getRuntimeScenario() === 'development'
env.getRuntimeScenario() === "development"
? await api.applicationCommands.bulkOverwriteGuildCommands(
process.env.APPLICATION_ID,
process.env.DEV_GUILD,
Expand All @@ -26,6 +28,6 @@ export const cmdRollout = async () => {
: await api.applicationCommands.bulkOverwriteGlobalCommands(process.env.APPLICATION_ID, commandData);

console.log(
`${chalk.bold.green('Core')} Successfully registered ${chalk.bold(result.length)} commands (${Temporal.Now.instant().toLocaleString('en-GB', { timeZone: 'Etc/UTC', timeZoneName: 'short' })})`,
`${chalk.bold.green("Core")} Successfully registered ${chalk.bold(result.length)} commands (${Temporal.Now.instant().toLocaleString("en-GB", { timeZone: "Etc/UTC", timeZoneName: "short" })})`,
);
};

0 comments on commit 5f4dda2

Please sign in to comment.