forked from embee/woomy
Add new music commands
This commit is contained in:
parent
42df6b71c7
commit
59084b07cb
7 changed files with 275 additions and 0 deletions
30
src/commands/fixmusic.js
Normal file
30
src/commands/fixmusic.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
const { getGuild } = require('../modules/music')
|
||||
module.exports.run = async (client, message, args, level) =>{
|
||||
guild = getGuild(message.guild.id)
|
||||
|
||||
guild.queue = []
|
||||
guild.playing = false
|
||||
guild.paused = false
|
||||
guild.skippers = []
|
||||
|
||||
if (guild.dispatcher) {
|
||||
guild.dispatcher.end('silent')
|
||||
}
|
||||
|
||||
message.channel.send('<:success:466995111885144095> Music has been fixed (hopefully)')
|
||||
}
|
||||
|
||||
exports.conf = {
|
||||
enabled: true,
|
||||
guildOnly: true,
|
||||
aliases: [],
|
||||
permLevel: "Moderator",
|
||||
requiredPerms: []
|
||||
};
|
||||
|
||||
exports.help = {
|
||||
name: "fixmusic",
|
||||
category: "Music",
|
||||
description: 'Fixes music if it breaks.',
|
||||
usage: 'fixmusic',
|
||||
};
|
33
src/commands/movehere.js
Normal file
33
src/commands/movehere.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
const { getGuild } = require('../modules/music')
|
||||
const Discord = require("discord.js")
|
||||
|
||||
module.exports.run = async (client, message, args, level) =>{
|
||||
const guild = getGuild(message.guild.id)
|
||||
|
||||
if (!guild.playing) {
|
||||
return message.channel.send('<:error:466995152976871434> Nothing is playing.')
|
||||
}
|
||||
|
||||
if (guild.channel.id === message.channel.id) {
|
||||
return message.channel.send('<:error:466995152976871434> Music messages are already being sent to this channel.')
|
||||
}
|
||||
|
||||
guild.channel = message.channel
|
||||
|
||||
message.channel.send('<:success:466995111885144095> Music messages will now be sent to this channel.')
|
||||
}
|
||||
|
||||
exports.conf = {
|
||||
enabled: true,
|
||||
guildOnly: true,
|
||||
aliases: [],
|
||||
permLevel: "Moderator",
|
||||
requiredPerms: []
|
||||
};
|
||||
|
||||
exports.help = {
|
||||
name: 'movehere',
|
||||
category: 'Music',
|
||||
description: 'Moves music related messages to the channel the this command is ran in.',
|
||||
usage: 'movehere',
|
||||
};
|
56
src/commands/movesong.js
Normal file
56
src/commands/movesong.js
Normal file
|
@ -0,0 +1,56 @@
|
|||
const { getGuild } = require('../modules/music')
|
||||
exports.run = async (client, message, args) => {
|
||||
const queue = getGuild(message.guild.id).queue
|
||||
|
||||
if (queue.length < 3) {
|
||||
return message.channel.send('<:error:466995152976871434> Not enough songs are in the queue for this command to work!')
|
||||
}
|
||||
|
||||
if (!args[0]) {
|
||||
return client.userError(message, exports, 'Missing argument, the `current position` argument is required!')
|
||||
}
|
||||
|
||||
if (!args[1]) {
|
||||
return client.userError(message, exports, 'Missing argument, the `new position` argument is required!')
|
||||
}
|
||||
|
||||
const oldPosition = +args[0]
|
||||
const newPosition = +args[1]
|
||||
|
||||
if (isNaN(oldPosition) === true) {
|
||||
return message.channel.send('<:error:466995152976871434> That isn\'t a number! You need to tell me the songs position in the queue (1, 2, etc.)')
|
||||
}
|
||||
|
||||
if (isNaN(newPosition) === true) {
|
||||
return message.channel.send('<:error:466995152976871434> That isn\'t a number! You need to tell me the songs position in the queue (1, 2, etc.)')
|
||||
}
|
||||
|
||||
if (oldPosition < 1 || oldPosition >= queue.length) {
|
||||
return message.channel.send('<:error:466995152976871434> Old position is not a valid song ID.')
|
||||
}
|
||||
|
||||
if (newPosition < 1 || newPosition >= queue.length) {
|
||||
return message.channel.send('<:error:466995152976871434> New position is not a valid song ID.')
|
||||
}
|
||||
|
||||
const songName = queue[oldPosition].video.title
|
||||
|
||||
queue.splice(newPosition, 0, queue.splice(oldPosition, 1)[0])
|
||||
|
||||
message.channel.send(`<:success:466995111885144095> Moved **${songName}** from position \`${oldPosition}\` to \`${newPosition}\``)
|
||||
}
|
||||
|
||||
exports.conf = {
|
||||
enabled: true,
|
||||
guildOnly: true,
|
||||
aliases: [],
|
||||
permLevel: "Moderator",
|
||||
requiredPerms: []
|
||||
}
|
||||
|
||||
exports.help = {
|
||||
name: 'movesong',
|
||||
category: 'Music',
|
||||
description: 'Moves a song to a new position in the queue.',
|
||||
usage: 'movesong [current position] [new position]'
|
||||
}
|
23
src/commands/playnext.js
Normal file
23
src/commands/playnext.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
const { play } = require('../modules/music')
|
||||
exports.run = async (client, message, args) => {
|
||||
if (!args[0]) {
|
||||
return message.channel.send(`<:error:466995152976871434> You didn't give me a song name or YouTube URL! Usage: \`${client.commands.get('play').help.usage}\``)
|
||||
}
|
||||
|
||||
await play(client, message, args.join(' '), true)
|
||||
}
|
||||
|
||||
exports.conf = {
|
||||
enabled: true,
|
||||
guildOnly: true,
|
||||
aliases: [],
|
||||
permLevel: "Moderator",
|
||||
requiredPerms: []
|
||||
}
|
||||
|
||||
exports.help = {
|
||||
name: 'playnext',
|
||||
category: 'Music',
|
||||
description: 'Similar to play, but adds it to the start of the queue instead of the end.',
|
||||
usage: 'playnext [song]'
|
||||
}
|
34
src/commands/shuffle.js
Normal file
34
src/commands/shuffle.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
const { getGuild } = require('../modules/music')
|
||||
exports.run = async (client, message) => {
|
||||
var queue = getGuild(message.guild.id).queue
|
||||
|
||||
if (queue.length < 4) {
|
||||
return message.channel.send('<:error:466995152976871434> There aren\'t enough songs are in the queue for this command to work!')
|
||||
}
|
||||
|
||||
const max = queue.length - 1
|
||||
const min = 1
|
||||
for (let i = max; i >= min; i--) {
|
||||
const randomIndex = Math.floor(Math.random() * (max - min + 1)) + min
|
||||
const itemAtIndex = queue[randomIndex]
|
||||
queue[randomIndex] = queue[i]
|
||||
queue[i] = itemAtIndex
|
||||
}
|
||||
|
||||
message.channel.send('<:success:466995111885144095> Queue shuffled!')
|
||||
}
|
||||
|
||||
exports.conf = {
|
||||
enabled: true,
|
||||
guildOnly: true,
|
||||
aliases: [],
|
||||
permLevel: "Moderator",
|
||||
requiredPerms: []
|
||||
}
|
||||
|
||||
exports.help = {
|
||||
name: 'shuffle',
|
||||
category: 'Music',
|
||||
description: 'Mixes up the songs in the queue',
|
||||
usage: 'shuffle'
|
||||
}
|
42
src/commands/songinfo.js
Normal file
42
src/commands/songinfo.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
const { getGuild, createTimestamp } = require('../modules/music')
|
||||
const { MessageEmbed } = require('discord.js')
|
||||
exports.run = async (client, message, args) => {
|
||||
const guild = getGuild(message.guild.id)
|
||||
|
||||
if (guild.queue.length < 1) {
|
||||
return message.channel.send(client.config.emojis.error + ' Nothing is in the queue!')
|
||||
}
|
||||
|
||||
const songID = +args[0]
|
||||
|
||||
if (isNaN(songID) === true) {
|
||||
return message.channel.send('<:error:466995152976871434> That isn\'t a number! You need to tell me the songs position in the queue (1, 2, etc.)')
|
||||
}
|
||||
|
||||
const s = guild.queue[songID]
|
||||
|
||||
const embed = new MessageEmbed()
|
||||
embed.setThumbnail(s.video.videoThumbnails[1].url)
|
||||
embed.setColor(client.embedColour(message))
|
||||
embed.setDescription(`**[${s.video.title}](https://www.youtube.com/watch?v=${s.video.videoId})**`)
|
||||
embed.addField('Channel:', s.video.author, true)
|
||||
embed.addField('Length:', '`[' + createTimestamp(s.video.lengthSeconds) + ']`', true)
|
||||
embed.setFooter('Requested by ' + s.requestedBy.tag, s.requestedBy.avatarURL({ format: 'png', dynamic: true, size: 2048 }))
|
||||
|
||||
message.channel.send(embed)
|
||||
}
|
||||
|
||||
exports.conf = {
|
||||
enabled: true,
|
||||
guildOnly: true,
|
||||
aliases: [],
|
||||
permLevel: "User",
|
||||
requiredPerms: []
|
||||
}
|
||||
|
||||
exports.help = {
|
||||
name: "songinfo",
|
||||
category: "Music",
|
||||
description: "Sends you information about a song in the queue. Song ID is the song's position in the queue.",
|
||||
usage: "songinfo [songID]"
|
||||
}
|
57
src/commands/volume.js
Normal file
57
src/commands/volume.js
Normal file
|
@ -0,0 +1,57 @@
|
|||
const { getGuild, setVolume } = require('../modules/music')
|
||||
exports.run = async (client, message, args) => {
|
||||
if (!args[0]) {
|
||||
return message.channel.send(`<:error:466995152976871434> No input! Usage: \`${client.commands.get('volume').help.usage}\``)
|
||||
}
|
||||
|
||||
const guild = getGuild(message.guild.id)
|
||||
|
||||
if (guild.queue.length < 1 || !guild.playing || !guild.dispatcher) {
|
||||
return message.channel.send(
|
||||
'<:error:466995152976871434> Nothing is playing.'
|
||||
)
|
||||
}
|
||||
|
||||
let userVolume = args[0]
|
||||
|
||||
if (userVolume.includes('%')) {
|
||||
userVolume = userVolume.replace('%', '')
|
||||
}
|
||||
|
||||
userVolume = +userVolume
|
||||
|
||||
if (isNaN(userVolume) === true) {
|
||||
return message.channel.send('<:error:466995152976871434> Input must be a number!')
|
||||
}
|
||||
|
||||
if (userVolume > 100 || userVolume < 1) {
|
||||
return message.channel.send('<:error:466995152976871434> Invalid input, input must be between 1-100')
|
||||
}
|
||||
|
||||
if (userVolume) {
|
||||
userVolume = Number(userVolume)
|
||||
|
||||
userVolume = userVolume / 100
|
||||
|
||||
if (userVolume <= 1) {
|
||||
setVolume(message.guild, userVolume)
|
||||
|
||||
message.channel.send('<:success:466995111885144095> Set volume to ' + userVolume * 100 + '%')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.conf = {
|
||||
enabled: true,
|
||||
guildOnly: true,
|
||||
aliases: [],
|
||||
permLevel: "Moderator",
|
||||
requiredPerms: []
|
||||
}
|
||||
|
||||
exports.help = {
|
||||
name: 'volume',
|
||||
category: 'Music',
|
||||
description: 'Sets volume of currently playing music. (100% = 25% of the actual volume)',
|
||||
usage: 'volume [volume]'
|
||||
}
|
Loading…
Reference in a new issue