toowake

join to create

Jun 21st, 2023
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1. const { SlashCommandBuilder, PermissionsBitField, EmbedBuilder, ChannelType } = require('discord.js');
  2. const voiceschema = require('../../Schemas.js/jointocreate');
  3.  
  4. module.exports = {
  5. data: new SlashCommandBuilder()
  6. .setName('join-to-create')
  7. .setDescription('Configure your join to create voice channel.')
  8. .setDMPermission(false)
  9. .addSubcommand(command => command.setName('setup').setDescription('Sets up your join to create voice channel.').addChannelOption(option => option.setName('channel').setDescription('Specified channel will be your join to create voice channel.').setRequired(true).addChannelTypes(ChannelType.GuildVoice)).addChannelOption(option => option.setName('category').setDescription('All new channels will be created in specified category.').setRequired(true).addChannelTypes(ChannelType.GuildCategory)).addIntegerOption(option => option.setName('voice-limit').setDescription('Set the default limit for the new voice channels.').setMinValue(2).setMaxValue(10)))
  10. .addSubcommand(command => command.setName('disable').setDescription('Disables your join to create voice channel system.')),
  11. async execute(interaction) {
  12.  
  13. if (!interaction.member.permissions.has(PermissionsBitField.Flags.Administrator) && interaction.user.id !== '619944734776885276') return await interaction.reply({ content: 'You **do not** have the permission to do that!', ephemeral: true});
  14.  
  15. const data = await voiceschema.findOne({ Guild: interaction.guild.id });
  16. const sub = interaction.options.getSubcommand();
  17.  
  18. switch (sub) {
  19. case 'setup':
  20.  
  21. if (data) return await interaction.reply({ content: `You have **already** set up the **join to create** system! \n> Do **/join-to-create disable** to undo.`, ephemeral: true});
  22. else {
  23.  
  24. const channel = await interaction.options.getChannel('channel');
  25. const category = await interaction.options.getChannel('category');
  26. const limit = await interaction.options.getInteger('voice-limit') || 3;
  27.  
  28. await voiceschema.create({
  29. Guild: interaction.guild.id,
  30. Channel: channel.id,
  31. Category: category.id,
  32. VoiceLimit: limit
  33. })
  34.  
  35. const setupembed = new EmbedBuilder()
  36. .setColor('Purple')
  37. .setAuthor({ name: `🔊 Join to Create system`})
  38. .setFooter({ text: `🔊 System Setup`})
  39. .setTimestamp()
  40. .addFields({ name: `• Join to Create was Enabled`, value: `> Your channel (${channel}) will now act as \n> your join to create channel.`})
  41. .addFields({ name: `• Category`, value: `> ${category}`})
  42. .addFields({ name: `• Voice Limit`, value: `> **${limit}**`, inline: true})
  43.  
  44. await interaction.reply({ embeds: [setupembed] });
  45. }
  46.  
  47. break;
  48. case 'disable':
  49.  
  50. if (!data) return await interaction.reply({ content: `You **do not** have the **join to create** system **set up**, cannot delete **nothing**..`, ephemeral: true});
  51. else {
  52.  
  53. const removeembed = new EmbedBuilder()
  54. .setColor('Purple')
  55. .setAuthor({ name: `🔊 Join to Create system`})
  56. .setFooter({ text: `🔊 System Disabled`})
  57. .setTimestamp()
  58. .addFields({ name: `• Join to Create was Disabled`, value: `> Your channel (<#${data.Channel}>) will no longer act as \n> your join to create channel.`})
  59.  
  60. await voiceschema.deleteMany({ Guild: interaction.guild.id });
  61.  
  62. await interaction.reply({ embeds: [removeembed] });
  63. }
  64. }
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment