toowake

vc-lock

Jun 21st, 2023
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
  2. const channel = require("../../Schemas.js/jointocreatechannels");
  3. const system = require("../../Schemas.js/jointocreate");
  4.  
  5. module.exports = {
  6.     data: new SlashCommandBuilder()
  7.     .setName("vc-lock")
  8.     .setDescription("Lock your voice channel")
  9.     .addNumberOption(option => option
  10.         .setName("user")
  11.         .setDescription("How many users are in your voice?")
  12.         .setMinValue(2)
  13.         .setMaxValue(99)
  14.         .setRequired(true)
  15.     ),
  16.  
  17.     async execute (interaction, client) {
  18.         const data = await channel.findOne({ Guild: interaction.guild.id, User: interaction.user.id});
  19.         const sys = await system.findOne({ Guild: interaction.guild.id});
  20.         const users = interaction.options.getNumber("user");
  21.  
  22.         if (!sys) {
  23.             return await interaction.reply({ content: "This **[GUILD/SERVER]** doesnt have a join to create system!", ephemeral: true});
  24.         } else if (!data) {
  25.             return await interaction.reply({ content: "You dont have a valid voice channel in this **[GUILD/SERVER]**!", ephemeral: true});
  26.         } else if (data) {
  27.             const channelID = data.Channel;
  28.             const channel = await interaction.guild.channels.cache.get(`${channelID}`);
  29.  
  30.             await channel.edit({
  31.                 userLimit: users,
  32.             })
  33.  
  34.             await interaction.reply({
  35.                 content: "Your voice channel has been locked!",
  36.                 ephemeral: true
  37.             })
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment