forked from eritislami/evobot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e877e1a
commit 1ce79e8
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module.exports = { | ||
name: "clip", | ||
description: "Plays a clip sound", | ||
async execute(message, args) { | ||
const { channel } = message.member.voice; | ||
const queue = message.client.queue.get(message.guild.id); | ||
|
||
if (!args.length) return message.reply("Usage: /clip <name>").catch(console.error); | ||
if (queue) return message.reply("Can't play clip because there is an active queue."); | ||
if (!channel) return message.reply("You need to join a voice channel first!").catch(console.error); | ||
|
||
const queueConstruct = { | ||
textChannel: message.channel, | ||
channel, | ||
connection: null, | ||
songs: [], | ||
loop: false, | ||
volume: 100, | ||
playing: true | ||
}; | ||
|
||
message.client.queue.set(message.guild.id, queueConstruct); | ||
|
||
try { | ||
queueConstruct.connection = await channel.join(); | ||
const dispatcher = queueConstruct.connection | ||
.play(`./sounds/${args[0]}.mp3`) | ||
.on("finish", () => { | ||
message.client.queue.delete(message.guild.id); | ||
channel.leave(); | ||
}) | ||
.on("error", err => { | ||
message.client.queue.delete(message.guild.id); | ||
channel.leave(); | ||
console.error(err); | ||
}); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const fs = require("fs"); | ||
|
||
module.exports = { | ||
name: "clips", | ||
description: "List all clips", | ||
execute(message) { | ||
fs.readdir("./sounds", function(err, files) { | ||
if (err) return console.log("Unable to read directory: " + err); | ||
|
||
let clips = []; | ||
|
||
files.forEach(function(file) { | ||
clips.push(file.substring(0, file.length - 4)); | ||
}); | ||
|
||
message.reply(`${clips.join(" ")}`).catch(console.error); | ||
}); | ||
} | ||
}; |
Empty file.