Skip to content

Commit

Permalink
Feat: send interface into voice channel / change logic for interface …
Browse files Browse the repository at this point in the history
…command
  • Loading branch information
Ballaual committed Jul 21, 2023
1 parent 7df91c9 commit 438545d
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 53 deletions.
57 changes: 4 additions & 53 deletions commands/dvc/interface.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');
const { vcInterface } = require('../../util/vcInterface');

module.exports = {
data: new SlashCommandBuilder()
Expand All @@ -7,58 +8,8 @@ module.exports = {
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
async execute(interaction) {
const vcLock = new ButtonBuilder()
.setCustomId('vcLock')
.setLabel('🔒')
.setStyle(ButtonStyle.Secondary);

const vcUnlock = new ButtonBuilder()
.setCustomId('vcUnlock')
.setLabel('🔓')
.setStyle(ButtonStyle.Secondary);

/* const vcRename = new ButtonBuilder()
.setCustomId('vcRename')
.setLabel('✏️')
.setStyle(ButtonStyle.Secondary);
const vcBlock = new ButtonBuilder()
.setCustomId('vcBlock')
.setLabel('🚫')
.setStyle(ButtonStyle.Secondary);
const vcPermit = new ButtonBuilder()
.setCustomId('vcPermit')
.setLabel('✅')
.setStyle(ButtonStyle.Secondary);
const vcLimit = new ButtonBuilder()
.setCustomId('vcLimit')
.setLabel('👪')
.setStyle(ButtonStyle.Secondary);
const vcKick = new ButtonBuilder()
.setCustomId('vcKick')
.setLabel('❌')
.setStyle(ButtonStyle.Secondary);*/

const row1 = new ActionRowBuilder()
.addComponents([vcLock, vcUnlock /* vcRename*/]);

/* const row2 = new ActionRowBuilder()
.addComponents([vcBlock, vcPermit, vcLimit, vcKick]);*/

const embed = new EmbedBuilder()
.setTitle('Voice Channel Interface')
.setDescription('You can use this interface to manage your voice channel.\nYou can also use the slash commands!\n\n🔒 Lock\n🔓 Unlock')
/* .setDescription('You can use this interface to manage your voice channel.\nYou can also use the slash commands!\n\n🔒 Lock\n🔓 Unlock\n✏️ Rename\n🚫 Block\n✅ Permit\n👪 Limit\n❌ Kick')*/
.setFooter({ text: 'Use the buttons below to manage your voice channel!' });

await interaction.reply({ content: 'The interface has been sent!', ephemeral: true });

await interaction.channel.send({
embeds: [embed],
components: [row1.toJSON() /* row2.toJSON()*/],
});
await interaction.reply({ content: 'The interface has been created and will be sent shortly!', ephemeral: true });
await vcInterface(interaction.channel);
},
};
2 changes: 2 additions & 0 deletions events/voiceStateUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const path = require('path');
const directory = './config/dvc';
const formatDate = require('../functions/formatDate');
const getGuildFilePath = (guildId) => path.join(directory, `${guildId}.json`);
const { vcInterface } = require('../util/vcInterface');

if (!fs.existsSync(directory)) {
fs.mkdirSync(directory, { recursive: true });
Expand Down Expand Up @@ -70,6 +71,7 @@ module.exports = {
});

newState.setChannel(newChannel);
await vcInterface(newChannel);

const creatorChannel = guild.channels.cache.get(newState.channel.id);
if (creatorChannel) {
Expand Down
59 changes: 59 additions & 0 deletions util/vcInterface.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');

async function vcInterface(channel) {
const vcLock = new ButtonBuilder()
.setCustomId('vcLock')
.setLabel('🔒')
.setStyle(ButtonStyle.Secondary);

const vcUnlock = new ButtonBuilder()
.setCustomId('vcUnlock')
.setLabel('🔓')
.setStyle(ButtonStyle.Secondary);

/* const vcRename = new ButtonBuilder()
.setCustomId('vcRename')
.setLabel('✏️')
.setStyle(ButtonStyle.Secondary);
const vcBlock = new ButtonBuilder()
.setCustomId('vcBlock')
.setLabel('🚫')
.setStyle(ButtonStyle.Secondary);
const vcPermit = new ButtonBuilder()
.setCustomId('vcPermit')
.setLabel('✅')
.setStyle(ButtonStyle.Secondary);
const vcLimit = new ButtonBuilder()
.setCustomId('vcLimit')
.setLabel('👪')
.setStyle(ButtonStyle.Secondary);
const vcKick = new ButtonBuilder()
.setCustomId('vcKick')
.setLabel('❌')
.setStyle(ButtonStyle.Secondary);*/

const row1 = new ActionRowBuilder()
.addComponents([vcLock, vcUnlock /* vcRename*/]);

/* const row2 = new ActionRowBuilder()
.addComponents([vcBlock, vcPermit, vcLimit, vcKick]);*/

const embed = new EmbedBuilder()
.setTitle('Voice Channel Interface')
.setDescription('You can use this interface to manage your voice channel.\nYou can also use the slash commands!\n\n🔒 Lock\n🔓 Unlock')
/* .setDescription('You can use this interface to manage your voice channel.\nYou can also use the slash commands!\n\n🔒 Lock\n🔓 Unlock\n✏️ Rename\n🚫 Block\n✅ Permit\n👪 Limit\n❌ Kick')*/
.setFooter({ text: 'Use the buttons below to manage your voice channel!' });

await channel.send({
embeds: [embed],
components: [row1.toJSON() /* row2.toJSON()*/],
});
}

module.exports = {
vcInterface,
};

0 comments on commit 438545d

Please sign in to comment.