1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-23 03:33:17 +00:00

nigthCore added

This commit is contained in:
MatteZ02 2020-04-08 20:48:57 +03:00
parent 0af2ca1d44
commit 1beb0fa86a
4 changed files with 290 additions and 184 deletions

26
src/commands/nigthcore.ts Normal file
View File

@ -0,0 +1,26 @@
module.exports = {
name: "nigthcore",
alias: "nc",
usage: "<true/false>",
description: "Change nigthcore on/off",
onlyDev: false,
permission: "MANAGE_MESSAGES",
category: "music",
async execute(msg, args, client, Discord, prefix, command) {
const queue = client.queue.get(msg.guild.id);
if (!args[1] && queue)
return msg.channel.send(
`${client.messages.currentNigthCore}**${queue.nigthCore}**`
);
if (client.funcs.check(client, msg, command)) {
if (args[1] === "true") {
queue.nigthCore = true;
} else if (args[1] === "false") {
queue.nigthCore = false;
}
let message;
message = client.messages.nigthCoreApplied.replace("%BOOLEAN%", args[1]);
return msg.channel.send(message);
}
},
};

View File

@ -1,128 +1,188 @@
const emojis = require('./emojis.ts'); const emojis = require("./emojis.ts");
module.exports = { module.exports = {
alreadyPaused: emojis.redx + "The music is already paused!", alreadyPaused: emojis.redx + "The music is already paused!",
alreadyVoted: emojis.redx + "You have already voted to skip!", alreadyVoted: emojis.redx + "You have already voted to skip!",
announceSongs: emojis.megaPhone + "Current setting:", announceSongs: emojis.megaPhone + "Current setting:",
announceSongsFalse: emojis.green_check_mark + "announcesongs now set to `false`!", announceSongsFalse:
announceSongsTrue: emojis.green_check_mark + "announcesongs now set to `true`!", emojis.green_check_mark + "announcesongs now set to `false`!",
bassApplied: emojis.volumeHigh + "The bass level **%BASS%** will be applied when the next song starts playing!", announceSongsTrue:
bassFalse: emojis.green_check_mark + "Bass is now false!", emojis.green_check_mark + "announcesongs now set to `true`!",
bassLevel: emojis.green_check_mark + "Bass level is now", bassApplied:
boolean: emojis.redx + "Please define a boolean! (true/false)", emojis.volumeHigh +
cancellingVideoSelection: emojis.redx + "Cancelling video selection", "The bass level **%BASS%** will be applied when the next song starts playing!",
cantSkipToCurrent: emojis.redx + "You can't skip to the song currently playing!", bassFalse: emojis.green_check_mark + "Bass is now false!",
channelFull: emojis.redx + "Your voice channel is full!", bassLevel: emojis.green_check_mark + "Bass level is now",
cmdUsesFooter: "These statistics are from the current uptime.", boolean: emojis.redx + "Please define a boolean! (true/false)",
cmdUsesTitle: "Musix Command Usage During Current Uptime", cancellingVideoSelection: emojis.redx + "Cancelling video selection",
correctUsage: emojis.redx + "correct usage: ", cantSkipToCurrent:
currentBass: emojis.loudSound + "The current bass is: ", emojis.redx + "You can't skip to the song currently playing!",
currentDefaultBass: emojis.speaker + "Currect default bass level: ", channelFull: emojis.redx + "Your voice channel is full!",
currentDefaultVolume: emojis.speaker + "Current default volume is:", cmdUsesFooter: "These statistics are from the current uptime.",
currentPrefix: "Current prefix:", cmdUsesTitle: "Musix Command Usage During Current Uptime",
currentVolume: emojis.loudSound + "The current volume is: ", correctUsage: emojis.redx + "correct usage: ",
dbSaved: emojis.green_check_mark + "DB Saved!", currentBass: emojis.loudSound + "The current bass is: ",
defaultVolumeMax: emojis.redx + "The default volume must be below `100` for quality and safety resons.", currentDefaultBass: emojis.speaker + "Currect default bass level: ",
defaultVolumeNumber: emojis.redx + "I'm sorry, But the default volume needs to be a valid __number__.", currentDefaultVolume: emojis.speaker + "Current default volume is:",
defaultVolumeSet: emojis.green_check_mark + "Default volume set to:", currentNigthCore: emojis.speaker + "Currect Nigthcore setting: ",
devMode: emojis.redx + "Dev mode has been turned on! Commands are only available to developer(s)!", currentPrefix: "Current prefix:",
dispatcherError: "Error with the dispatcher: ", currentVolume: emojis.loudSound + "The current volume is: ",
djFalse: emojis.green_check_mark + "`DJ` now set to `false`", dbSaved: emojis.green_check_mark + "DB Saved!",
djRoleCreated: emojis.green_check_mark + "I did not find a role `DJ` so i have created one for you!", defaultVolumeMax:
djRoleFound: emojis.green_check_mark + "I found a `DJ` role from this guild! This role is now the DJ role.", emojis.redx +
error: emojis.redx + "An error occured!", "The default volume must be below `100` for quality and safety resons.",
errorConnecting: "Error with connecting to voice channel: ", defaultVolumeNumber:
errorDetected: "Error detected: ", emojis.redx +
errorDispatcher: emojis.redx + "An error has occured while playing music! The queue has been deleted.", "I'm sorry, But the default volume needs to be a valid __number__.",
errorExe: emojis.redx + "there was an error trying to execute that command!", defaultVolumeSet: emojis.green_check_mark + "Default volume set to:",
errorExeOpt: emojis.redx + "there was an error trying to execute that option!", devMode:
evalTitle: "Evaluation Command", emojis.redx +
helpCmdFooter: "Command Alias:", "Dev mode has been turned on! Commands are only available to developer(s)!",
helpFooter: "\"%PREFIX%help <command>\" to see more information about a command.", dispatcherError: "Error with the dispatcher: ",
helpTitle: "help", djFalse: emojis.green_check_mark + "`DJ` now set to `false`",
inviteTitle: "Invite Musix to your Discord server!", djRoleCreated:
joined: emojis.green_check_mark + "Joined", emojis.green_check_mark +
joinSupport: "Join the musix support server: ", "I did not find a role `DJ` so i have created one for you!",
loadingSongs: emojis.loading + "Loading song(s)", djRoleFound:
looping: emojis.repeat + "Looping the queue now!", emojis.green_check_mark +
loopingSong: emojis.repeatSong + "Looping **%TITLE%** now!", "I found a `DJ` role from this guild! This role is now the DJ role.",
maxBass: emojis.redx + "The max bass is `100`!", error: emojis.redx + "An error occured!",
maxVolume: emojis.redx + "The max volume is `100`!", errorConnecting: "Error with connecting to voice channel: ",
noDj: emojis.redx + "You need the `DJ` role to use this command!", errorDetected: "Error detected: ",
noLooping: emojis.repeat + "No longer looping the queue!", errorDispatcher:
noLoopingSong: emojis.repeatSong + "No longer looping the song!", emojis.redx +
noPerms: emojis.redx + `You need the %PERMS% permission to use this command!`, "An error has occured while playing music! The queue has been deleted.",
noPermsConnect: emojis.redx + "I cannot connect to your voice channel, make sure I have the proper permissions!", errorExe: emojis.redx + "there was an error trying to execute that command!",
noPermsEmbed: emojis.redx + "I cannot send embeds (Embed links), make sure I have the proper permissions!", errorExeOpt:
noPermsManageRoles: emojis.redx + "I cannot create roles (Manage roles), make sure I have the proper permissions! I will need this permission to create a `DJ` role since i did not find one!", emojis.redx + "there was an error trying to execute that option!",
noPermsManageSettings: emojis.redx + "You need the `MANAGE_SERVER` permission to change the settings!", evalTitle: "Evaluation Command",
noPermsSpeak: emojis.redx + "I cannot speak in your voice channel, make sure I have the proper permissions!", helpCmdFooter: "Command Alias:",
noPermsUseExternalEmojis: emojis.redx + "I cannot use external emojis, make sure I have the proper permissions!", helpFooter:
noQuery: emojis.redx + "you need to use a link or search for a song!", '"%PREFIX%help <command>" to see more information about a command.',
noResults: emojis.redx + "I could not obtain any search results!", helpTitle: "help",
noServerQueue: emojis.redx + "There is nothing playing!", inviteTitle: "Invite Musix to your Discord server!",
noSongs: emojis.redx + "That song does not exist!", joined: emojis.green_check_mark + "Joined",
nowPlayingDesc: emojis.notes + "**Now playing:**", joinSupport: "Join the musix support server: ",
notAllowed: emojis.redx + "You are not allowed to do that!", loadingSongs: emojis.loading + "Loading song(s)",
notEnoughVotes: emojis.redx + "Not enough votes!", looping: emojis.repeat + "Looping the queue now!",
notPaused: emojis.redx + "The music in not paused!", loopingSong: emojis.repeatSong + "Looping **%TITLE%** now!",
noVoiceChannel: emojis.redx + "I'm sorry but you need to be in a voice channel to play music!", maxBass: emojis.redx + "The max bass is `100`!",
nowPlaying: "__Now playing__", maxVolume: emojis.redx + "The max volume is `100`!",
paused: emojis.pause + "Paused the music!", nigthCoreApplied:
permission: "🔒 Permission requirement:", emojis.green_check_mark +
permissionsFalse: emojis.redx + "That value is already `false`!", "NigthCore is now **%BOOLEAN%** this will be applied when the next song starts playing!",
permissionsSetFalse: emojis.green_check_mark + "Permissions requirement now set to: `false`", noDj: emojis.redx + "You need the `DJ` role to use this command!",
permissionsSetTrue: emojis.green_check_mark + "Permissions requirement now set to: `true`", noLooping: emojis.repeat + "No longer looping the queue!",
permissionsTrue: emojis.redx + "That value is already `true`!", noLoopingSong: emojis.repeatSong + "No longer looping the song!",
pinging: emojis.loading + "Pinging...", noPerms: emojis.redx + `You need the %PERMS% permission to use this command!`,
playlistAdded: emojis.green_check_mark + "Playlist: **%TITLE%** has been added to the queue!", noPermsConnect:
positiveBass: emojis.redx + "The bass needs to be a positive number!", emojis.redx +
positiveVolume: emojis.redx + "The volume needs to be a positive number!", "I cannot connect to your voice channel, make sure I have the proper permissions!",
prefixHere: "My prefix here is: ", noPermsEmbed:
prefixMaxLength: "The prefix must be shorter or equal to 5 letters!", emojis.redx +
prefixSet: emojis.green_check_mark + "New prefix set to:", "I cannot send embeds (Embed links), make sure I have the proper permissions!",
provideANumber: "Please provide a number ranging from 1-10 to select one of the search results.", noPermsManageRoles:
provideASong: emojis.redx + "Please provide a song position in queue for me to remove!", emojis.redx +
queueDeleted: "Queue deleted!", "I cannot create roles (Manage roles), make sure I have the proper permissions! I will need this permission to create a `DJ` role since i did not find one!",
queueDesc: "**Now playing:** %SONG%<a:aNotes:674602408105476106>\n:arrow_down: Next in queue :arrow_down:", noPermsManageSettings:
queueFooter: "songs in the queue!", emojis.redx +
queueLength: emojis.redx + "There are only %SONGS% amount of songs in the queue!", "You need the `MANAGE_SERVER` permission to change the settings!",
queueTitle: "__Song queue__", noPermsSpeak:
quotaReached: emojis.redx + "Quota reached please try again after midnight Pacific Time (PT)!", emojis.redx +
reloaded: "All files reloaded!", "I cannot speak in your voice channel, make sure I have the proper permissions!",
removed: emojis.garbage + "removed `%SONG%` from the queue!", noPermsUseExternalEmojis:
reset: emojis.green_check_mark + "Reset __all__ guild settings!", emojis.redx +
restart: "restarting all shards...", "I cannot use external emojis, make sure I have the proper permissions!",
resumed: emojis.resume + "Resumed the music!", noQuery: emojis.redx + "you need to use a link or search for a song!",
seekingPointPositive: emojis.redx + "The seeking point needs to be a positive number!", noResults: emojis.redx + "I could not obtain any search results!",
seekMax: emojis.redx + "The lenght of this song is %LENGTH% seconds! You can't seek further than that!", noServerQueue: emojis.redx + "There is nothing playing!",
settingsAnnounceSongs: "announcesongs", noSongs: emojis.redx + "That song does not exist!",
settingsAnnounceSongsDesc: "Whether to announce songs that start playing or not.", nowPlayingDesc: emojis.notes + "**Now playing:**",
settingsBass: "bass", notAllowed: emojis.redx + "You are not allowed to do that!",
settingsBassDesc: "Change the default bass level.", notEnoughVotes: emojis.redx + "Not enough votes!",
settingsFooter: "how to use: %PREFIX%settings <Setting name> <value>", notPaused: emojis.redx + "The music in not paused!",
settingsPermissions: "permissions", noVoiceChannel:
settingsPermissionsDesc: "Change whether to require permissions to use eg `skip, stop, pause, loop, etc...`", emojis.redx +
settingsPrefix: "prefix", "I'm sorry but you need to be in a voice channel to play music!",
settingsPrefixDesc: "Change the guild specific prefix. (string)", nowPlaying: "__Now playing__",
settingsSetDj: "setdj", paused: emojis.pause + "Paused the music!",
settingsSetDjDesc: "Set a DJ role. This will allow chosen users to freely use all Musix commands. This will automatically set the `permissions` settings to true in order for the `DJ` role to have effect!", permission: "🔒 Permission requirement:",
settingsTitle: "Guild settings for Musix", permissionsFalse: emojis.redx + "That value is already `false`!",
settingsVolume: "volume", permissionsSetFalse:
settingsVolumeDesc: "Change the default volume that the bot will start playing at. (number)", emojis.green_check_mark + "Permissions requirement now set to: `false`",
setVolume: emojis.volumeHigh + "I set the volume to: ", permissionsSetTrue:
shuffled: emojis.shuffle + "Queue suffled!", emojis.green_check_mark + "Permissions requirement now set to: `true`",
skipped: emojis.skip + "Skipped the song!", permissionsTrue: emojis.redx + "That value is already `true`!",
songAdded: emojis.green_check_mark + "**%TITLE%** has been added to the queue!", pinging: emojis.loading + "Pinging...",
songBlockedWMG: emojis.redx + "This song had been blocked by WMG (Warner Music Groud).\n<:skip:674685614221688832> Skipped to next song.", playlistAdded:
songSelection: "__Song Selection__", emojis.green_check_mark +
startPlaying: emojis.notes + "Start playing: ", "Playlist: **%TITLE%** has been added to the queue!",
statusField1: emojis.signal + "Ping", positiveBass: emojis.redx + "The bass needs to be a positive number!",
statusField2: "Latency", positiveVolume: emojis.redx + "The volume needs to be a positive number!",
statusField3: emojis.stopWatch + "Uptime", prefixHere: "My prefix here is: ",
statusField4: "Shard: ", prefixMaxLength: "The prefix must be shorter or equal to 5 letters!",
statusTitle: "Status for Musix", prefixSet: emojis.green_check_mark + "New prefix set to:",
stop: emojis.stop + "Stopped the music!", provideANumber:
validNumber: emojis.redx + "I'm sorry, But you need to enter a valid __number__.", "Please provide a number ranging from 1-10 to select one of the search results.",
wrongVoiceChannel: emojis.redx + "I'm sorry but you need to be in the same voice channel as Musix to use this command!", provideASong:
emojis.redx + "Please provide a song position in queue for me to remove!",
queueDeleted: "Queue deleted!",
queueDesc:
"**Now playing:** %SONG%<a:aNotes:674602408105476106>\n:arrow_down: Next in queue :arrow_down:",
queueFooter: "songs in the queue!",
queueLength:
emojis.redx + "There are only %SONGS% amount of songs in the queue!",
queueTitle: "__Song queue__",
quotaReached:
emojis.redx +
"Quota reached please try again after midnight Pacific Time (PT)!",
reloaded: "All files reloaded!",
removed: emojis.garbage + "removed `%SONG%` from the queue!",
reset: emojis.green_check_mark + "Reset __all__ guild settings!",
restart: "restarting all shards...",
resumed: emojis.resume + "Resumed the music!",
seekingPointPositive:
emojis.redx + "The seeking point needs to be a positive number!",
seekMax:
emojis.redx +
"The lenght of this song is %LENGTH% seconds! You can't seek further than that!",
settingsAnnounceSongs: "announcesongs",
settingsAnnounceSongsDesc:
"Whether to announce songs that start playing or not.",
settingsBass: "bass",
settingsBassDesc: "Change the default bass level.",
settingsFooter: "how to use: %PREFIX%settings <Setting name> <value>",
settingsPermissions: "permissions",
settingsPermissionsDesc:
"Change whether to require permissions to use eg `skip, stop, pause, loop, etc...`",
settingsPrefix: "prefix",
settingsPrefixDesc: "Change the guild specific prefix. (string)",
settingsSetDj: "setdj",
settingsSetDjDesc:
"Set a DJ role. This will allow chosen users to freely use all Musix commands. This will automatically set the `permissions` settings to true in order for the `DJ` role to have effect!",
settingsTitle: "Guild settings for Musix",
settingsVolume: "volume",
settingsVolumeDesc:
"Change the default volume that the bot will start playing at. (number)",
setVolume: emojis.volumeHigh + "I set the volume to: ",
shuffled: emojis.shuffle + "Queue suffled!",
skipped: emojis.skip + "Skipped the song!",
songAdded:
emojis.green_check_mark + "**%TITLE%** has been added to the queue!",
songBlockedWMG:
emojis.redx +
"This song had been blocked by WMG (Warner Music Groud).\n<:skip:674685614221688832> Skipped to next song.",
songSelection: "__Song Selection__",
startPlaying: emojis.notes + "Start playing: ",
statusField1: emojis.signal + "Ping",
statusField2: "Latency",
statusField3: emojis.stopWatch + "Uptime",
statusField4: "Shard: ",
statusTitle: "Status for Musix",
stop: emojis.stop + "Stopped the music!",
validNumber:
emojis.redx + "I'm sorry, But you need to enter a valid __number__.",
wrongVoiceChannel:
emojis.redx +
"I'm sorry but you need to be in the same voice channel as Musix to use this command!",
}; };

View File

@ -1,17 +1,18 @@
module.exports = { module.exports = {
textChannel: null, textChannel: null,
voiceChannel: null, voiceChannel: null,
connection: null, connection: null,
songs: [], songs: [],
volume: null, volume: null,
bass: null, bass: null,
playing: false, nigthCore: false,
paused: false, playing: false,
looping: false, paused: false,
songLooping: false, looping: false,
votes: 0, songLooping: false,
voters: [], votes: 0,
votesNeeded: null, voters: [],
time: 0, votesNeeded: null,
endReason: null, time: 0,
} endReason: null,
};

View File

@ -1,48 +1,67 @@
module.exports = async function (guild, song, client, seek, play) { module.exports = async function (guild, song, client, seek, play) {
const Discord = require('discord.js'); const Discord = require("discord.js");
const ytdl = require('ytdl-core'); const ytdl = require("ytdl-core");
const streamConfig = require("../config/streamConfig.ts"); const streamConfig = require("../config/streamConfig.ts");
const getThumb = require('video-thumbnail-url'); const getThumb = require("video-thumbnail-url");
const prism = require('prism-media'); const prism = require("prism-media");
const queue = client.queue.get(guild.id); const queue = client.queue.get(guild.id);
if (!song) { if (!song) {
queue.voiceChannel.leave(); queue.voiceChannel.leave();
client.queue.delete(guild.id); client.queue.delete(guild.id);
return; return;
} }
streamConfig.ytdlOptions.begin = seek; streamConfig.ytdlOptions.begin = seek;
const ffmpegArgs = [ const ffmpegArgs = [
"-analyzeduration", "0", "-analyzeduration",
"-loglevel", "0", "0",
"-f", "s16le", "-loglevel",
"-ar", "48000", "0",
"-ac", "2", "-f",
"-af", `bass=g=${queue.bass}`, "s16le",
]; "-ar",
const transcoder = new prism.FFmpeg({ args: ffmpegArgs }); "48000",
"-ac",
"2",
"-af",
`bass=g=${queue.bass}`,
];
if (queue.nigthCore) {
ffmpegArgs.push("-af");
ffmpegArgs.push("asetrate=52920");
}
const dispatcher = queue.connection const transcoder = new prism.FFmpeg({ args: ffmpegArgs });
.play(await ytdl(song.url, streamConfig.ytdlOptions).pipe(transcoder), streamConfig.options).on("finish", () => {
client.dispatcher.finish(client, queue.endReason, guild); const dispatcher = queue.connection
}).on('start', () => { .play(
dispatcher.player.streamingData.pausedTime = 0; await ytdl(song.url, streamConfig.ytdlOptions).pipe(transcoder),
}).on('error', error => { streamConfig.options
client.dispatcher.error(client, error, guild); )
}); .on("finish", () => {
dispatcher.setVolume(queue.volume / 10); client.dispatcher.finish(client, queue.endReason, guild);
if (client.global.db.guilds[guild.id].startPlaying || play) { })
const data = await Promise.resolve(ytdl.getInfo(queue.songs[0].url)); .on("start", () => {
const songtime = (data.length_seconds * 1000).toFixed(0); dispatcher.player.streamingData.pausedTime = 0;
const thumbnail = getThumb(queue.songs[0].url); })
const embed = new Discord.MessageEmbed() .on("error", (error) => {
.setTitle(`${client.messages.startPlaying}**${song.title}**`) client.dispatcher.error(client, error, guild);
.setDescription(`Song duration: \`${client.funcs.msToTime(songtime, "hh:mm:ss")}\``) });
.setThumbnail(thumbnail._rejectionHandler0) dispatcher.setVolume(queue.volume / 10);
.setColor(client.config.embedColor) if (client.global.db.guilds[guild.id].startPlaying || play) {
queue.textChannel.send(embed); const data = await Promise.resolve(ytdl.getInfo(queue.songs[0].url));
} const songtime = (data.length_seconds * 1000).toFixed(0);
queue.playing = true; const thumbnail = getThumb(queue.songs[0].url);
} const embed = new Discord.MessageEmbed()
.setTitle(`${client.messages.startPlaying}**${song.title}**`)
.setDescription(
`Song duration: \`${client.funcs.msToTime(songtime, "hh:mm:ss")}\``
)
.setThumbnail(thumbnail._rejectionHandler0)
.setColor(client.config.embedColor);
queue.textChannel.send(embed);
}
queue.playing = true;
};