This commit is contained in:
MatteZ02 committed 2020-04-20 19:56:23 +03:00
1 parent 2d55a3a8da
commit a6e3e8b0de
71 files changed
+158 -164

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
const MusicClient = require('./struct/client.js');
const client = new MusicClient({});
-2
View File
@@ -1,2 +0,0 @@
const MusicClient = require('./struct/client.ts');
const client = new MusicClient({});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+11 -3
View File
@@ -1,6 +1,7 @@
const YouTube = require("simple-youtube-api");
const search = require("yt-search");
const SpotifyApi = require("spotify-web-api-node");
const { globaldb } = require("../../index.js");
module.exports = {
name: "play",
@@ -16,9 +17,16 @@ module.exports = {
secret: client.config.spotify_client_secret,
});
spotify.setAccessToken(
client.global.db.guilds[msg.guild.id].spotify_access_key
);
const dbdata = await globaldb
.collection("guilds")
.doc(msg.guild.id)
.get()
.catch((err) => {
console.log("Error getting document", err);
return "error";
});
const accessKey = dbdata.data();
spotify.setAccessToken(accessKey);
const youtube = new YouTube(client.config.api_key);
const searchString = args.slice(1).join(" ");
@@ -1,7 +1,7 @@
module.exports = {
name: 'queue',
alias: 'q',
usage: '<page(opt)>',
usage: '',
description: 'See the queue.',
onlyDev: false,
permission: 'none',
@@ -25,4 +25,4 @@ module.exports = {
.setColor(client.config.embedColor)
return msg.channel.send(embed);
}
};
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,3 +1,5 @@
const { db } = require("../../../index-.js");
module.exports = {
name: "message",
async execute(client, msg, Discord) {
@@ -6,9 +8,9 @@ module.exports = {
const args = msg.content.split(" ");
if (!args[1] || !args[2])
return msg.channel.send(client.messages.setKeyUsage);
if (!client.guilds.cache.get(args[2]))
return msg.channel.send(client.messages.invalidGuild);
client.global.db.guilds[args[2]].spotify_access_key = args[1];
client.config.db.collection("guilds").doc(args[2]).set({
key: args[1],
});
return msg.channel.send(client.messages.keySet);
}
if (!msg.guild) return;
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -2,16 +2,16 @@ module.exports = function (client) {
const Discord = require('discord.js');
const events = './clientEvents/';
client.on('ready', () => {
require(`${events}ready.ts`).execute(client, Discord);
require(`${events}ready.js`).execute(client, Discord);
});
client.on('message', (msg) => {
require(`${events}msg.ts`).execute(client, msg, Discord);
require(`${events}msg.js`).execute(client, msg, Discord);
});
client.on('guildCreate', (guild) => {
require(`${events}guildCreate.ts`).execute(client, guild);
require(`${events}guildCreate.js`).execute(client, guild);
});
client.on('voiceStateUpdate', (oldState, newState) => {
require(`${events}voiceStateUpdate.ts`).execute(client, oldState, newState);
require(`${events}voiceStateUpdate.js`).execute(client, oldState, newState);
});
client.on('error', (error) => {
client.channels.fetch(client.config.debug_channel).send(`Error: ${error} on shard: ${client.shard}`);
+12 -9
View File
@@ -1,9 +1,12 @@
const { Client, Collection } = require("discord.js");
const {
Client,
Collection
} = require("discord.js");
const admin = require("firebase-admin");
const serviceAccount = require("./config/serviceAccount.json");
const fs = require("fs");
const path = require("path");
const events = require("../events/events.ts");
const events = require("../events/events.js");
module.exports = class extends Client {
constructor() {
@@ -21,12 +24,12 @@ module.exports = class extends Client {
this.queue = new Map();
this.funcs = {};
this.dispatcher = {};
this.config = require("../../config/config.ts");
this.messages = require("./config/messages.ts");
this.config = require("../../config/config.js");
this.messages = require("./config/messages.js");
this.db = admin.firestore();
this.db.FieldValue = require("firebase-admin").firestore.FieldValue;
this.dispatcher.finish = require("../events/dispatcherEvents/finish.ts");
this.dispatcher.error = require("../events/dispatcherEvents/error.ts");
this.dispatcher.finish = require("../events/dispatcherEvents/finish.js");
this.dispatcher.error = require("../events/dispatcherEvents/error.js");
this.global = {
db: {
guilds: {},
@@ -39,7 +42,7 @@ module.exports = class extends Client {
const commandFiles = fs
.readdirSync(path.join(path.dirname(__dirname), "commands"))
.filter((f) => f.endsWith(".ts"));
.filter((f) => f.endsWith(".js"));
for (const file of commandFiles) {
const command = require(`../commands/${file}`);
command.uses = 0;
@@ -48,7 +51,7 @@ module.exports = class extends Client {
}
const settingFiles = fs
.readdirSync(path.join(path.dirname(__dirname), "commands/settings"))
.filter((f) => f.endsWith(".ts"));
.filter((f) => f.endsWith(".js"));
for (const file of settingFiles) {
const option = require(`../commands/settings/${file}`);
this.settingCmd.set(option.name, option);
@@ -63,4 +66,4 @@ module.exports = class extends Client {
console.log("Failed to login: " + err)
);
}
};
};
File renamed without changes.
@@ -1,34 +1,25 @@
const emojis = require("./emojis.ts");
const emojis = require("./emojis.js");
module.exports = {
alreadyPaused: emojis.redx + "The music is already paused!",
alreadyVoted: emojis.redx + "You have already voted to skip!",
announceSongs: emojis.megaPhone + "Current setting:",
announceSongsFalse:
emojis.green_check_mark + "announcesongs now set to `false`!",
announceSongsTrue:
emojis.green_check_mark + "announcesongs now set to `true`!",
bassApplied:
emojis.volumeHigh + "The bass level **%BASS%** has been applied!",
announceSongsFalse: emojis.green_check_mark + "announcesongs now set to `false`!",
announceSongsTrue: emojis.green_check_mark + "announcesongs now set to `true`!",
bassApplied: emojis.volumeHigh + "The bass level **%BASS%** has been applied!",
bassFalse: emojis.green_check_mark + "Bass is now false!",
bassLevel: emojis.green_check_mark + "Bass level is now",
blacklistTitle: "Currently blacklisted channels:",
blackListedVC:
emojis.redx +
blackListedVC: emojis.redx +
"Your voiceChannel is blacklisted! Please choose another channel!",
boolean: emojis.redx + "Please define a boolean! (true/false)",
cancellingVideoSelection: emojis.redx + "Cancelling video selection",
cantSkipToCurrent:
emojis.redx + "You can't skip to the song currently playing!",
channelAdded:
emojis.green_check_mark + "Channel %CHANNEL% added to the blacklist!",
channelAlreadyBlackListed:
emojis.redx + "That channel is already blacklisted!",
cantSkipToCurrent: emojis.redx + "You can't skip to the song currently playing!",
channelAdded: emojis.green_check_mark + "Channel %CHANNEL% added to the blacklist!",
channelAlreadyBlackListed: emojis.redx + "That channel is already blacklisted!",
channelFull: emojis.redx + "Your voice channel is full!",
channelNotBlackListed:
emojis.redx + "That channel is not blacklisted or does not exist!",
channelRemoved:
emojis.green_check_mark +
channelNotBlackListed: emojis.redx + "That channel is not blacklisted or does not exist!",
channelRemoved: emojis.green_check_mark +
"Channel %CHANNEL% has been removed from the blacklist!",
cmdUsesFooter: "These statistics are from the current uptime.",
cmdUsesTitle: "Musix Command Usage During Current Uptime",
@@ -40,43 +31,33 @@ module.exports = {
currentPrefix: "Current prefix:",
currentVolume: emojis.loudSound + "The current volume is: ",
dbSaved: emojis.green_check_mark + "DB Saved!",
defaultVolumeMax:
emojis.redx +
defaultVolumeMax: emojis.redx +
"The default volume must be below `100` for quality and safety resons.",
defaultVolumeNumber:
emojis.redx +
defaultVolumeNumber: emojis.redx +
"I'm sorry, But the default volume needs to be a valid __number__.",
defaultVolumeSet: emojis.green_check_mark + "Default volume set to:",
devMode:
emojis.redx +
devMode: emojis.redx +
"Dev mode has been turned on! Commands are only available to developer(s)!",
disableNigthCore:
emojis.redx + "Please disable nigthCore in order to use this command!",
disableNigthCore: emojis.redx + "Please disable nigthCore in order to use this command!",
dispatcherError: "Error with the dispatcher: ",
djFalse: emojis.green_check_mark + "`DJ` now set to `false`",
djRoleCreated:
emojis.green_check_mark +
djRoleCreated: emojis.green_check_mark +
"I did not find a role `DJ` so i have created one for you!",
djRoleFound:
emojis.green_check_mark +
djRoleFound: emojis.green_check_mark +
"I found a `DJ` role from this guild! This role is now the DJ role.",
error: emojis.redx + "An error occured!",
errorConnecting: "Error with connecting to voice channel: ",
errorDetected: "Error detected: ",
errorDispatcher:
emojis.redx +
errorDispatcher: emojis.redx +
"An error has occured while playing music! The queue has been deleted.",
errorExe: emojis.redx + "there was an error trying to execute that command!",
errorExeOpt:
emojis.redx + "there was an error trying to execute that option!",
errorExeOpt: emojis.redx + "there was an error trying to execute that option!",
evalTitle: "Evaluation Command",
failedToLoad: emojis.redx + "Songs failed to load: ",
helpCmdFooter: "Command Alias:",
helpFooter:
'"%PREFIX%help <command>" to see more information about a command.',
helpFooter: '"%PREFIX%help <command>" to see more information about a command.',
helpTitle: "help",
idOrMentionChannel:
emojis.redx + "Please provide a channel id or mention a channel!",
idOrMentionChannel: emojis.redx + "Please provide a channel id or mention a channel!",
invalidGuild: emojis.redx + "Invalid guild id!",
inviteTitle: "Invite Musix to your Discord server!",
joined: emojis.green_check_mark + "Joined",
@@ -90,40 +71,31 @@ module.exports = {
maxBass: emojis.redx + "The max bass is `100`!",
maxVolume: emojis.redx + "The max volume is `100`!",
mentionChannel: emojis.redx + "Please mention a channel!",
musicCommandsDisabled:
emojis.redx +
musicCommandsDisabled: emojis.redx +
"This channels has been blacklisted! Music commands cannot be used here!",
nigthCoreApplied:
emojis.green_check_mark +
nigthCoreApplied: emojis.green_check_mark +
"NigthCore is now **%BOOLEAN%** this will be applied when the next song starts playing!",
noDj: emojis.redx + "You need the `DJ` role to use this command!",
noLooping: emojis.repeat + "No longer looping the queue!",
noLoopingSong: emojis.repeatSong + "No longer looping the song!",
noMorePremium: ":cry: Guild %GUILD% is no longer premium!",
noPerms: emojis.redx + `You need the %PERMS% permission to use this command!`,
noPermsConnect:
emojis.redx +
noPermsConnect: emojis.redx +
"I cannot connect to your voice channel, make sure I have the proper permissions!",
noPermsEmbed:
emojis.redx +
noPermsEmbed: emojis.redx +
"I cannot send embeds (Embed links), make sure I have the proper permissions!",
noPermsManageRoles:
emojis.redx +
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!",
noPermsManageSettings:
emojis.redx +
noPermsManageSettings: emojis.redx +
"You need the `MANAGE_SERVER` permission to change the settings!",
noPermsSpeak:
emojis.redx +
noPermsSpeak: emojis.redx +
"I cannot speak in your voice channel, make sure I have the proper permissions!",
noPermsUseExternalEmojis:
emojis.redx +
noPermsUseExternalEmojis: emojis.redx +
"I cannot use external emojis, make sure I have the proper permissions!",
noQuery: emojis.redx + "you need to use a link or search for a song!",
noResults: emojis.redx + "I could not obtain any search results!",
noResultsLyrics: emojis.redx + "I could not obtain any results!",
noResultsSpotify:
emojis.redx +
noResultsSpotify: emojis.redx +
"I could not obtain any results! Make sure you have a key set! More info with the setkey setting.",
noServerQueue: emojis.redx + "There is nothing playing!",
noSongs: emojis.redx + "That song does not exist!",
@@ -132,8 +104,7 @@ module.exports = {
notAllowed: emojis.redx + "You are not allowed to do that!",
notEnoughVotes: emojis.redx + "Not enough votes!",
notPaused: emojis.redx + "The music in not paused!",
noVoiceChannel:
emojis.redx +
noVoiceChannel: emojis.redx +
"I'm sorry but you need to be in a voice channel to play music!",
nowPlaying: "__Now playing__",
nowPremium: ":tada: Guild %GUILD% is now premium!",
@@ -141,14 +112,11 @@ module.exports = {
paused: emojis.pause + "Paused the music!",
permission: "🔒 Permission requirement:",
permissionsFalse: emojis.redx + "That value is already `false`!",
permissionsSetFalse:
emojis.green_check_mark + "Permissions requirement now set to: `false`",
permissionsSetTrue:
emojis.green_check_mark + "Permissions requirement now set to: `true`",
permissionsSetFalse: emojis.green_check_mark + "Permissions requirement now set to: `false`",
permissionsSetTrue: emojis.green_check_mark + "Permissions requirement now set to: `true`",
permissionsTrue: emojis.redx + "That value is already `true`!",
pinging: emojis.loading + "Pinging...",
playlistAdded:
emojis.green_check_mark +
playlistAdded: emojis.green_check_mark +
"Playlist: **%TITLE%** has been added to the queue!",
positiveBass: emojis.redx + "The bass needs to be a positive number!",
positiveVolume: emojis.redx + "The volume needs to be a positive number!",
@@ -156,62 +124,47 @@ module.exports = {
prefixMaxLength: "The prefix must be shorter or equal to 5 letters!",
prefixSet: emojis.green_check_mark + "New prefix set to:",
premiumState: "Premium status: ",
provideANumber:
"Please provide a number ranging from 1-10 to select one of the search results.",
provideASong:
emojis.redx + "Please provide a song position in queue for me to remove!",
provideANumber: "Please provide a number ranging from 1-10 to select one of the search results.",
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:",
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!",
queueLength: emojis.redx + "There are only %SONGS% amount of songs in the queue!",
queueTitle: "__Song queue__",
quotaReached:
emojis.redx +
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 +
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!",
setKeyUsage:
"Usage: `setkey <key> <guild id>`. Get your key from <https://developer.spotify.com/documentation/web-playback-sdk/quick-start/#> by pressing `Get your web playback sdk access token`.\nThe key will expire in 60 minutes!\nDO THIS COMMAND IN THE DMS! YOUR KEY IS PRIVATE DO NOT SHARE IT WITH ANYONE!",
setKeyUsage: "Usage: `setkey <key> <guild id>`. Get your key from <https://developer.spotify.com/documentation/web-playback-sdk/quick-start/#> by pressing `Get your web playback sdk access token`.\nThe key will expire in 60 minutes!\nDO THIS COMMAND IN THE DMS! YOUR KEY IS PRIVATE DO NOT SHARE IT WITH ANYONE!",
settingsAnnounceSongs: "announcesongs",
settingsAnnounceSongsDesc:
"Whether to announce songs that start playing or not.",
settingsAnnounceSongsDesc: "Whether to announce songs that start playing or not.",
settingsBass: "bass",
settingsBassDesc: "Change the default bass level.",
settingsBlacklist: "blacklist",
settingsBlacklistDesc:
"Blacklist channels that you wan't to block music commands to be executed on or block the bot from joining certain voiceChannels.",
settingsBlacklistDesc: "Blacklist channels that you wan't to block music commands to be executed on or block the bot from joining certain voiceChannels.",
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...`",
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!",
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!",
settingsSetKey: "setkey",
settingsSetKeyDesc: "Get instructions on how to set a spotify key.",
settingsTitle: "Guild settings for Musix",
settingsVolume: "volume",
settingsVolumeDesc:
"Change the default volume that the bot will start playing at. (number)",
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 +
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: ",
@@ -221,9 +174,7 @@ module.exports = {
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 +
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!",
};
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,8 +1,10 @@
module.exports = async function (guild, song, client, seek, play) {
const { Readable: ReadableStream } = require("stream");
const {
Readable: ReadableStream
} = require("stream");
const Discord = require("discord.js");
const ytdl = require("ytdl-core");
const streamConfig = require("../config/streamConfig.ts");
const streamConfig = require("../config/streamConfig.js");
const prism = require("prism-media");
const queue = client.queue.get(guild.id);
if (!song) {
@@ -41,7 +43,9 @@ module.exports = async function (guild, song, client, seek, play) {
const args = isStream ? ffmpegArgs.slice() : ["-i", input, ...ffmpegArgs];
args.unshift("-ss", String(seek));
const transcoder = new prism.FFmpeg({ args: args });
const transcoder = new prism.FFmpeg({
args: args
});
const stream = input.pipe(transcoder);
@@ -71,4 +75,4 @@ module.exports = async function (guild, song, client, seek, play) {
queue.textChannel.send(embed);
}
queue.playing = true;
};
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.