New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

slacmdregistry

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slacmdregistry

A modular slash command registry for Discord bots using Discord.js v14+. Handles dynamic loading and registration of commands with minimal setup.

latest
npmnpm
Version
4.3.6
Version published
Maintainers
1
Created
Source

slacmdregistry

A modular slash command registry for Discord bots using Discord.js v14+.
Handles dynamic loading and registration of commands with minimal setup.

Install

npm install slacmdregistry


Usage

const { deploy } = require('slacmdregistry');

deploy({
  scope: 'global', // or 'guild'
  guildId: 'YOUR_GUILD_ID', // required if scope is 'guild'
  path: './commands',
  log: true
});


Command Format

Each command lives in its own file inside /commands. Example:

// commands/ping.js
module.exports = {
  name: 'ping',
  description: 'Replies with Pong!',
  options: [],
  async execute(interaction) {
    await interaction.reply('Pong!');
  }
};


Examples
Kick Command
// commands/kick.js
const { EmbedBuilder } = require('discord.js');

module.exports = {
  name: 'kick',
  description: 'Kick a user from the server',
  options: [
    {
      name: 'user',
      description: 'The user to kick',
      type: 6,
      required: true
    },
    {
      name: 'reason',
      description: 'Reason for kick',
      type: 3
    }
  ],
  async execute(interaction) {
    const user = interaction.options.getUser('user');
    const reason = interaction.options.getString('reason') || 'No reason provided';
    const member = interaction.guild.members.cache.get(user.id);

    if (!member) {
      return interaction.reply({ content: 'User not found.', ephemeral: true });
    }

    try {
      await member.kick(reason);

      const embed = new EmbedBuilder()
        .setTitle('User Kicked')
        .setColor(0xff0000)
        .addFields(
          { name: 'User', value: user.tag, inline: true },
          { name: 'Moderator', value: interaction.user.tag, inline: true },
          { name: 'Reason', value: reason }
        )
        .setThumbnail(user.displayAvatarURL({ dynamic: true }))
        .setTimestamp();

      await interaction.reply({ embeds: [embed] });
    } catch (err) {
      await interaction.reply({ content: `Failed to kick: ${err.message}`, ephemeral: true });
    }
  }
};


Ban Command

// commands/ban.js
module.exports = {
  name: 'ban',
  description: 'Ban a user from the server',
  options: [
    {
      name: 'user',
      description: 'The user to ban',
      type: 6,
      required: true
    },
    {
      name: 'reason',
      description: 'Reason for ban',
      type: 3
    }
  ],
  async execute(interaction) {
    const user = interaction.options.getUser('user');
    const reason = interaction.options.getString('reason') || 'No reason provided';
    const member = interaction.guild.members.cache.get(user.id);

    if (!member) {
      return interaction.reply({ content: 'User not found.', ephemeral: true });
    }

    try {
      await member.ban({ reason });
      await interaction.reply(`Banned ${user.tag} for: ${reason}`);
    } catch (err) {
      await interaction.reply({ content: `Failed to ban: ${err.message}`, ephemeral: true });
    }
  }
};


Embed-Only Command

// commands/serverinfo.js
const { EmbedBuilder } = require('discord.js');

module.exports = {
  name: 'serverinfo',
  description: 'Shows server information',
  options: [],
  async execute(interaction) {
    const { guild } = interaction;

    const embed = new EmbedBuilder()
      .setTitle('Server Info')
      .setColor(0x00bfff)
      .addFields(
        { name: 'Name', value: guild.name, inline: true },
        { name: 'Members', value: `${guild.memberCount}`, inline: true }
      )
      .setThumbnail(guild.iconURL({ dynamic: true }))
      .setTimestamp();

    await interaction.reply({ embeds: [embed] });
  }
};


Features

- Supports both global and guild slash commands
- Loads commands dynamically from a folder
- Embed-friendly and option-rich
- Minimal setup, maximum control

License
MIT

FAQs

Package last updated on 13 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts