const { SlashCommandBuilder } = require('@discordjs/builders'); const { PermissionsBitField } = require('discord.js'); const inviteSchema = require('../../Schemas.js/inviteSchema'); const { EmbedBuilder } = require('discord.js'); const { ChannelType } = require('discord.js') module.exports = { data: new SlashCommandBuilder() .setName('welcomeset') .setDescription('Welcomes the upcoming users and counts the invites of each') .addSubcommand(option => option.setName('setup').setDescription('Setups the channel to send a welcome message in').addChannelOption(option => option.setName('channel').setDescription('The channel to send a welcome message in').setRequired(true).addChannelTypes(ChannelType.GuildText))) .addSubcommand(option => option.setName('disable').setDescription('Disable welcomer message')), async execute(interaction) { if (!interaction.member.permissions.has(PermissionsBitField.Flags.Administrator)) return interaction.reply({ content: "You don't have perms to setup/disable the welcome channel", ephemeral: true }) const { options } = interaction; const sub = options.getSubcommand(); const Data = await inviteSchema.findOne({ Guild: interaction.guild.id }); switch (sub) { case 'setup': const channel = options.getChannel('channel'); if (Data) return await interaction.reply({ content: 'Welcomer already set to this channel', emphereal: true }); else { await inviteSchema.create({ Guild: interaction.guild.id, Channel: channel.id }); const embed = new EmbedBuilder() .setColor('#006400') .setDescription(`The welcomer has been enabled in ${channel}`); await interaction.reply({ embeds: [embed] }); } break; case 'disable': if (!Data) return await interaction.reply({ content: 'There is no welcomer set in this channel', emphereal: true }); else { await inviteSchema.deleteMany({ Guild: interaction.guild.id }); const embed = new EmbedBuilder() .setColor('#006400') .setDescription(`The welcomer has been disabled`); await interaction.reply({ embeds: [embed] }); } break; default: break; } } }