Compare commits

...

2 Commits

Author SHA1 Message Date
Wizzard fd0aa70556 Change help menu format 2024-02-05 22:38:35 -05:00
Wizzard fe06dbab3f Livestream command 2024-02-05 22:38:13 -05:00
3 changed files with 62 additions and 2 deletions

View File

@ -2,9 +2,15 @@ module.exports = {
name: 'help',
description: 'List all of my commands or info about a specific command.',
execute(message, args, deleteTimeout) {
let reply = 'Here are my supported commands:\n\n';
let reply = '```';
reply += 'Here are the available commands:\n\n';
const commands = Array.from(message.client.commands.values());
reply += commands.map(command => `.${command.name} - ${command.description}`).join('\n');
commands.forEach(command => {
reply += `.${command.name} - ${command.description}\n`;
});
reply += '```';
message.channel.send(reply).then(sentMessage => {
setTimeout(() => sentMessage.delete().catch(console.error), deleteTimeout);

51
commands/livestream.js Normal file
View File

@ -0,0 +1,51 @@
const { DiscordStreamClient } = require('discord-stream-client');
module.exports = {
name: 'livestream',
description: 'Starts a live stream in a voice channel with a provided video link.',
async execute(message, args, deleteTimeout) {
if (args.length < 2) {
return message.channel.send('Usage: .livestream <channelId> <videoLink>')
.then(msg => setTimeout(() => msg.delete().catch(console.error), deleteTimeout));
}
const channelId = args[0];
const videoLink = args[1];
const channel = message.client.channels.cache.get(channelId);
if (!channel) {
return message.channel.send('Channel not found.')
.then(msg => setTimeout(() => msg.delete().catch(console.error), deleteTimeout));
}
try {
const connection = await message.client.streamClient.joinVoiceChannel(channel, {
selfDeaf: true,
selfMute: true,
selfVideo: false,
});
const stream = await connection.createStream();
const player = message.client.streamClient.createPlayer(videoLink, stream.udp);
player.on('error', err => console.error(err));
player.play({
kbpsVideo: 7000,
fps: 60,
hwaccel: true,
kbpsAudio: 128,
volume: 1,
});
message.channel.send('Livestream started with the provided video link.')
.then(msg => setTimeout(() => msg.delete().catch(console.error), deleteTimeout));
} catch (error) {
console.error(error);
message.channel.send('Failed to start the livestream.')
.then(msg => setTimeout(() => msg.delete().catch(console.error), deleteTimeout));
}
},
};

View File

@ -1,8 +1,11 @@
require('dotenv').config();
const { Client } = require('discord.js-selfbot-v13');
const { DiscordStreamClient } = require('discord-stream-client');
const client = new Client();
const fs = require('fs');
client.streamClient = new DiscordStreamClient(client);
const PREFIX = process.env.PREFIX || '.';
const MESSAGE_DELETE_TIMEOUT = 10000