Skip to content

Commit

Permalink
chore: revert changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rdsov committed May 31, 2024
1 parent 04dc863 commit cc93c23
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 203 deletions.
89 changes: 6 additions & 83 deletions commands/kickoff.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
const {
joinVoiceChannel,
createAudioPlayer,
createAudioResource,
AudioPlayerStatus,
VoiceConnectionStatus
} = require('@discordjs/voice');
const play = require('play-dl');
const sodium = require('libsodium-wrappers');
const { PermissionFlagsBits } = require("discord.js");

module.exports = {
Expand All @@ -17,12 +8,10 @@ module.exports = {
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages)
.addStringOption(option =>
option.setName('link')
.setDescription('Pre-intro audio source.')
.setDescription('Event video link.')
.setRequired(true)),
async execute(interaction, config) {
const link = interaction.options.getString('link');
const member = await interaction.guild.members.fetch(interaction.user.id);
const voiceChannel = member.voice.channel;

const moderatorRole = interaction.guild.roles.cache.get(config.roles.moderator);
const memberRole = interaction.guild.roles.cache.get(config.roles.member);
Expand All @@ -32,62 +21,13 @@ module.exports = {
return interaction.reply({ content: 'You do not have permission to use this command.', ephemeral: true });
}

if (!voiceChannel) {
return interaction.reply({ content: 'You need to join a voice channel first.', ephemeral: true });
}

// Validate the YouTube link
const youtubeRegex = /^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\/.+$/;
if (!youtubeRegex.test(link)) {
return interaction.reply({ content: 'Please provide a valid YouTube link.', ephemeral: true });
// Validate youtube link
if (!link.match(/^(https?\:\/\/)?((www\.)?youtube\.com|youtu\.?be)\/.+$/)) {
return interaction.reply({ content: 'Invalid YouTube link.', ephemeral: true });
}

await interaction.deferReply();

// Initialize sodium
await sodium.ready;

const connection = joinVoiceChannel({
channelId: voiceChannel.id,
guildId: voiceChannel.guild.id,
adapterCreator: voiceChannel.guild.voiceAdapterCreator,
});

const player = createAudioPlayer();

connection.on(VoiceConnectionStatus.Ready, async () => {
console.log('The bot has connected to the channel!');
try {
// In highest quality
const stream = await play.stream(link, { filter: 'audio' });
const resource = createAudioResource(stream.stream, {
inputType: stream.type,
});

player.play(resource);
connection.subscribe(player);

player.on(AudioPlayerStatus.Idle, () => {
connection.destroy();
});
} catch (error) {
console.error('Error while trying to play the audio:', error);
await interaction.editReply({ content: 'An error occurred while trying to play the audio.' });
connection.destroy();
}
});

connection.on(VoiceConnectionStatus.Disconnected, () => {
connection.destroy();
});

player.on('error', error => {
console.error('Error in audio player:', error);
connection.destroy();
});

return;

const publicChannels = Object.values(config.channels).filter(channel => channel.public);

try {
Expand All @@ -107,25 +47,8 @@ module.exports = {
}
}

const vc = interaction.guild.channels.cache.get(config.vc.stage.id);
if (vc) {
await vc.permissionOverwrites.edit(memberRole, {
ViewChannel: true,
Connect: true
});
}

const stage1 = interaction.guild.channels.cache.get(config.channels.stage1.id);
if (stage1) {
await stage1.permissionOverwrites.edit(memberRole, {
ViewChannel: true,
SendMessages: true
});

stage1.send("🍿 Opening the curtains soon. Get your snacks ready.");
}

await interaction.editReply({ content: `🔒 **All** channels have been locked. The fun begins in <#${ config.channels.stage1.id }>.` });
// Reply with link but no embed
await interaction.editReply({ content: `🔒 All channels have been locked. The fun begins **[here](<${ link }>)**.` });

if (logChannel) {
logChannel.send(`[SYSTEM] **${ interaction.user.tag }** started a special event.`);
Expand Down
18 changes: 0 additions & 18 deletions commands/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,6 @@ module.exports = {
}
}

const vc = interaction.guild.channels.cache.get(config.vc.stage.id);
if (vc) {
await vc.permissionOverwrites.edit(memberRole, {
ViewChannel: false,
Connect: false
});
}

const stage1 = interaction.guild.channels.cache.get(config.channels.stage1.id);
if (stage1) {
await stage1.permissionOverwrites.edit(memberRole, {
ViewChannel: false,
SendMessages: false
});

stage1.send("👋 The show is over. Thanks for stopping by.");
}

await interaction.editReply({ content: '🎉 Thank you for attending the event. All channels are now open again.' });

// Log the event
Expand Down
9 changes: 0 additions & 9 deletions config.development.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,11 @@
"id": "1245283061927510096",
"public": true
},
"stage1": {
"id": "1245666539454337084",
"public": false
},
"log": {
"id": "1242917814117859419",
"public": false
}
},
"vc": {
"stage": {
"id": "1245308342205939763"
}
},
"roles": {
"member": "1242742481234296914",
"moderator": "1242886360646422558",
Expand Down
9 changes: 0 additions & 9 deletions config.production.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,11 @@
"id": "1245281700871929957",
"public": true
},
"stage1": {
"id": "1245671187208605767",
"public": false
},
"log": {
"id": "1235954356378144940",
"public": false
}
},
"vc": {
"stage": {
"id": "1245299407440711751"
}
},
"roles": {
"member": "1241849442408206397",
"moderator": "1242886712204464191",
Expand Down
77 changes: 1 addition & 76 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@
"license": "ISC",
"dependencies": {
"@discordjs/builders": "^1.8.1",
"@discordjs/voice": "^0.17.0",
"discord.js": "^14.15.2",
"dotenv": "^16.4.5",
"libsodium-wrappers": "^0.7.13",
"play-dl": "^1.9.7"
"dotenv": "^16.4.5"
},
"devDependencies": {
"@flydotio/dockerfile": "^0.5.7"
Expand Down
2 changes: 0 additions & 2 deletions utils/verifyChannels.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ module.exports = async function checkChannels(guild, config, logChannel) {
{ id: config.channels.log.id, name: 'Log' },
{ id: config.channels.render.id, name: 'Render' },
{ id: config.channels.introduce.id, name: 'Introduce' },
{ id: config.channels.stage1.id, name: 'Stage 1' },
{ id: config.vc.stage.id, name: 'Stage VC' },
];

let missingChannels = false;
Expand Down
4 changes: 2 additions & 2 deletions version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "0.5.1",
"lastUpdated": "May 30, 2024"
"version": "0.4.0",
"lastUpdated": "May 31, 2024"
}

0 comments on commit cc93c23

Please sign in to comment.