Skip to content

Commit

Permalink
[New] send a message to the channel when the channelEmpty event gets …
Browse files Browse the repository at this point in the history
…triggered
  • Loading branch information
naseif committed Nov 8, 2021
1 parent 718e8a6 commit e8a1b7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions commands/Music/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ module.exports = {
leaveOnEmptyCooldown: 60 * 1000 * 3,
bufferingTimeout: 200,
leaveOnEmpty: true,
metadata: {
channel: message.channel,
},
async onBeforeCreateStream(track, source, _queue) {
if (source === "soundcloud") {
const client_id = await playdl.getFreeClientID();
Expand Down
6 changes: 5 additions & 1 deletion playerEvents/player.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { embedMessage } = require("../modules/embedSimple");
const { logger } = require("../modules/logger");

module.exports.playerEvents = (player) => {
Expand All @@ -7,10 +8,13 @@ module.exports.playerEvents = (player) => {
player.on("botDisconnect", (queue) => {
logger(`${queue.guild.name} Disconnected from Channel`);
});
player.on("channelEmpty", (queue) => {
player.on("channelEmpty", async (queue) => {
logger(
`${queue.guild.name}: Voice channel is empty right now!, leaving the Channel`
);
await queue.metadata.channel.send({
embeds: [embedMessage("9dcc37", `Leaving the channel since its empty!`)],
});
});
player.on("connectionCreate", (queue, connection) => {
logger(
Expand Down

0 comments on commit e8a1b7e

Please sign in to comment.