update to d.js master and fix #17 (stage channels)

deleted the package-lock because i thought it would fix an npm issue which it didn't, shouldn't change anything though.  also added intents which are required in the new version of d.js
This commit is contained in:
Alex 2021-05-03 01:59:02 -07:00
parent dbff59af1b
commit 509cadea67
4 changed files with 716 additions and 724 deletions

View file

@ -7,9 +7,12 @@ const createNewChunk = () => {
exports.enter = function(msg, channelName) {
channelName = channelName.toLowerCase();
msg.guild.channels.cache.forEach(c => {
console.log(c);
})
const voiceChannel = msg.guild.channels.cache.find(channel => channel.name.toLowerCase() === channelName);
if (!voiceChannel || voiceChannel.type !== 'voice')
if (!voiceChannel || (voiceChannel.type !== 'voice' && voiceChannel.type !== 'stage'))
return msg.reply(`The channel #${channelName} doesn't exist or isn't a voice channel.`);
console.log(`Sliding into ${voiceChannel.name} ...`);
@ -33,19 +36,13 @@ exports.enter = function(msg, channelName) {
}
exports.exit = function (msg) {
// Use optional chaining when we upgrade to Node 14.
if (
!(
msg &&
msg.guild &&
msg.guild.voice &&
msg.guild.voice.channel &&
msg.guild.voice.connection
)
)
//check to see if the voice cache has any connections and if there is
//no ongoing connection (there shouldn't be undef issues with this).
if(msg.guild.voiceStates.cache.filter(a => a.connection !== null).size !== 1)
return;
const { channel: voiceChannel, connection: conn } = msg.guild.voice;
//make sure it's .last() not .first(). some discord js magic going on rn
const { channel: voiceChannel, connection: conn } = msg.guild.voiceStates.cache.last();
const dispatcher = conn.play(__dirname + "/../sounds/badumtss.mp3", { volume: 0.45 });
dispatcher.on("finish", () => {
voiceChannel.leave();

View file

@ -1,5 +1,7 @@
const Discord = require('discord.js');
const client = new Discord.Client();
const client = new Discord.Client(
{intents: ["GUILD_MESSAGES", "GUILD_VOICE_STATES", "GUILDS"]}
);
const fs = require("fs");

1411
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -14,7 +14,7 @@
},
"dependencies": {
"@discordjs/opus": "^0.3.2",
"discord.js": "^12.3.1",
"discord.js": "github:discordjs/discord.js#af00ec8970e77ea8a0afd21571eeeef9c554e1ec",
"ffmpeg-static": "^4.2.7"
}
}