Merge pull request #18 from AlexIsOK/master
Fix some minor annoyances and add stage channel support
This commit is contained in:
commit
89dfb8a509
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,3 @@
|
||||||
config.json
|
config.json
|
||||||
node_modules
|
node_modules
|
||||||
recordings
|
.idea
|
||||||
|
|
|
@ -6,9 +6,15 @@ const createNewChunk = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.enter = function(msg, channelName) {
|
exports.enter = function(msg, channelName) {
|
||||||
const voiceChannel = msg.guild.channels.cache.find(channel => channel.name === channelName);
|
channelName = channelName.toLowerCase();
|
||||||
|
|
||||||
if (!voiceChannel || voiceChannel.type !== 'voice')
|
//filter out all channels that aren't voice or stage
|
||||||
|
const voiceChannel = msg.guild.channels.cache
|
||||||
|
.filter(c => c.type === "voice" || c.type === "stage")
|
||||||
|
.find(channel => channel.name.toLowerCase() === channelName);
|
||||||
|
|
||||||
|
//if there is no voice channel at all or the channel is not voice or stage
|
||||||
|
if (!voiceChannel || (voiceChannel.type !== 'voice' && voiceChannel.type !== 'stage'))
|
||||||
return msg.reply(`The channel #${channelName} doesn't exist or isn't a voice channel.`);
|
return msg.reply(`The channel #${channelName} doesn't exist or isn't a voice channel.`);
|
||||||
|
|
||||||
console.log(`Sliding into ${voiceChannel.name} ...`);
|
console.log(`Sliding into ${voiceChannel.name} ...`);
|
||||||
|
@ -32,19 +38,13 @@ exports.enter = function(msg, channelName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.exit = function (msg) {
|
exports.exit = function (msg) {
|
||||||
// Use optional chaining when we upgrade to Node 14.
|
//check to see if the voice cache has any connections and if there is
|
||||||
if (
|
//no ongoing connection (there shouldn't be undef issues with this).
|
||||||
!(
|
if(msg.guild.voiceStates.cache.filter(a => a.connection !== null).size !== 1)
|
||||||
msg &&
|
|
||||||
msg.guild &&
|
|
||||||
msg.guild.voice &&
|
|
||||||
msg.guild.voice.channel &&
|
|
||||||
msg.guild.voice.connection
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return;
|
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 });
|
const dispatcher = conn.play(__dirname + "/../sounds/badumtss.mp3", { volume: 0.45 });
|
||||||
dispatcher.on("finish", () => {
|
dispatcher.on("finish", () => {
|
||||||
voiceChannel.leave();
|
voiceChannel.leave();
|
||||||
|
|
11
index.js
11
index.js
|
@ -1,9 +1,18 @@
|
||||||
const Discord = require('discord.js');
|
const Discord = require('discord.js');
|
||||||
const client = new Discord.Client();
|
const client = new Discord.Client(
|
||||||
|
{intents: ["GUILD_MESSAGES", "GUILD_VOICE_STATES", "GUILDS"]}
|
||||||
|
);
|
||||||
|
|
||||||
const config = require('./config.json');
|
const config = require('./config.json');
|
||||||
const commands = require(`./bin/commands`);
|
const commands = require(`./bin/commands`);
|
||||||
|
|
||||||
|
//in case the bot was not configured properly
|
||||||
|
if(!config.PREFIX || !config.BOT_TOKEN) {
|
||||||
|
console.error("Error: the configuration file was configured properly.");
|
||||||
|
console.error("Make sure there are no spelling mistakes.");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
client.on('message', msg => {
|
client.on('message', msg => {
|
||||||
if (msg.content.startsWith(config.PREFIX)) {
|
if (msg.content.startsWith(config.PREFIX)) {
|
||||||
const commandBody = msg.content.substring(config.PREFIX.length).split(' ');
|
const commandBody = msg.content.substring(config.PREFIX.length).split(' ');
|
||||||
|
|
39
package-lock.json
generated
39
package-lock.json
generated
|
@ -213,16 +213,14 @@
|
||||||
"integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups="
|
"integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups="
|
||||||
},
|
},
|
||||||
"discord.js": {
|
"discord.js": {
|
||||||
"version": "12.3.1",
|
"version": "github:discordjs/discord.js#af00ec8970e77ea8a0afd21571eeeef9c554e1ec",
|
||||||
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.3.1.tgz",
|
"from": "github:discordjs/discord.js#af00ec8970e77ea8a0afd21571eeeef9c554e1ec",
|
||||||
"integrity": "sha512-mSFyV/mbvzH12UXdS4zadmeUf8IMQOo/YdunubG1wWt1xjWvtaJz/s9CGsFD2B5pTw1W/LXxxUbrQjIZ/xlUdw==",
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@discordjs/collection": "^0.1.6",
|
"@discordjs/collection": "^0.1.6",
|
||||||
"@discordjs/form-data": "^3.0.1",
|
"@discordjs/form-data": "^3.0.1",
|
||||||
"abort-controller": "^3.0.0",
|
"abort-controller": "^3.0.0",
|
||||||
"node-fetch": "^2.6.0",
|
"node-fetch": "^2.6.1",
|
||||||
"prism-media": "^1.2.2",
|
"prism-media": "^1.2.2",
|
||||||
"setimmediate": "^1.0.5",
|
|
||||||
"tweetnacl": "^1.0.3",
|
"tweetnacl": "^1.0.3",
|
||||||
"ws": "^7.3.1"
|
"ws": "^7.3.1"
|
||||||
}
|
}
|
||||||
|
@ -370,16 +368,16 @@
|
||||||
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
|
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
|
||||||
},
|
},
|
||||||
"mime-db": {
|
"mime-db": {
|
||||||
"version": "1.44.0",
|
"version": "1.47.0",
|
||||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz",
|
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.47.0.tgz",
|
||||||
"integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg=="
|
"integrity": "sha512-QBmA/G2y+IfeS4oktet3qRZ+P5kPhCKRXxXnQEudYqUaEioAU1/Lq2us3D/t1Jfo4hE9REQPrbB7K5sOczJVIw=="
|
||||||
},
|
},
|
||||||
"mime-types": {
|
"mime-types": {
|
||||||
"version": "2.1.27",
|
"version": "2.1.30",
|
||||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz",
|
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.30.tgz",
|
||||||
"integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==",
|
"integrity": "sha512-crmjA4bLtR8m9qLpHvgxSChT+XoSlZi8J4n/aIdn3z92e/U47Z0V/yl+Wh9W046GgFVAmoNR/fmdbZYcSSIUeg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"mime-db": "1.44.0"
|
"mime-db": "1.47.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"minimatch": {
|
"minimatch": {
|
||||||
|
@ -536,9 +534,9 @@
|
||||||
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
|
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
|
||||||
},
|
},
|
||||||
"prism-media": {
|
"prism-media": {
|
||||||
"version": "1.2.2",
|
"version": "1.2.9",
|
||||||
"resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.9.tgz",
|
||||||
"integrity": "sha512-I+nkWY212lJ500jLe4tN9tWO7nRiBAVdMv76P9kffZjYhw20raMlW1HSSvS+MLXC9MmbNZCazMrAr+5jEEgTuw=="
|
"integrity": "sha512-UHCYuqHipbTR1ZsXr5eg4JUmHER8Ss4YEb9Azn+9zzJ7/jlTtD1h0lc4g6tNx3eMlB8Mp6bfll0LPMAV4R6r3Q=="
|
||||||
},
|
},
|
||||||
"process-nextick-args": {
|
"process-nextick-args": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
|
@ -608,11 +606,6 @@
|
||||||
"resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
|
||||||
"integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc="
|
"integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc="
|
||||||
},
|
},
|
||||||
"setimmediate": {
|
|
||||||
"version": "1.0.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
|
|
||||||
"integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU="
|
|
||||||
},
|
|
||||||
"signal-exit": {
|
"signal-exit": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz",
|
||||||
|
@ -698,9 +691,9 @@
|
||||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||||
},
|
},
|
||||||
"ws": {
|
"ws": {
|
||||||
"version": "7.3.1",
|
"version": "7.4.5",
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.5.tgz",
|
||||||
"integrity": "sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA=="
|
"integrity": "sha512-xzyu3hFvomRfXKH8vOFMU3OguG6oOvhXMo3xsGy3xWExqaM2dxBbVxuD99O7m3ZUFMvvscsZDqxfgMaRr/Nr1g=="
|
||||||
},
|
},
|
||||||
"yallist": {
|
"yallist": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/opus": "^0.3.2",
|
"@discordjs/opus": "^0.3.2",
|
||||||
"discord.js": "^12.3.1",
|
"discord.js": "github:discordjs/discord.js#af00ec8970e77ea8a0afd21571eeeef9c554e1ec",
|
||||||
"ffmpeg-static": "^4.2.7"
|
"ffmpeg-static": "^4.2.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
5
recordings/.gitignore
vendored
Normal file
5
recordings/.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
# ignore audio-type files
|
||||||
|
*.pcm
|
||||||
|
*.mp3
|
||||||
|
*.opus
|
Loading…
Reference in a new issue