1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-09-19 22:11:55 +00:00
This commit is contained in:
MatteZ02 2020-04-20 19:56:23 +03:00
parent 2d55a3a8da
commit a6e3e8b0de
71 changed files with 158 additions and 164 deletions

3
.gitignore vendored
View File

@ -2,4 +2,5 @@
dev/
.env
.vscode/
struct/config/serviceAccount.json
struct/config/serviceAccount.json
./config/serviceAccount.json

View File

@ -20,7 +20,7 @@ module.exports = {
invite:
"https://discordapp.com/oauth2/authorize?client_id=607266889537945605&permissions=3427328&scope=bot",
supportServer: "https://discord.gg/rvHuJtB",
devMode: false,
devMode: true,
api: false,
saveDB: true,
respawn: true,

View File

@ -0,0 +1,12 @@
{
"type": "service_account",
"project_id": "global-1f5f9",
"private_key_id": "b5a6a0b88ae6140663840979255664efe81686b6",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDHtsqPN7JDzx/Z\n1V09wgEjytB+OpAZPWWRl42QGfAEhynYBXcQSOdXA6azZPfZvl+E2D5A48Ok/v47\nsruqLC5AWaA1uz53FbtyqH1AyMNG5bZIPyteR36yQzwJvqjVlufWG93v2htJt6bw\nl3tJva7/xYlTBBtoxuoZpHSKtKxNG5j2acPm31BZc3f+3KM6PCA6ZBnC/CiNOY37\nKEC1iLALK206ByU9WcVJo6yS49WufIfBOVFzYJVGdXy3ekGOnBfW1TlHSLiuw+qN\nMvLV8+yj9KxQfJ2oAnoYJwV9tboSTkDRu519izamGLBtiiPfSa4LSOcfPRcklO07\ncIYjq8WxAgMBAAECggEABPSr+5hP999KpMrm3Kq1AQieGlfFLh8oJ0/5rw75tf8N\nooLmNLT+apoYV6DEhrZy49bC2rTcLLq4H86cWgltH2Mp9tNd5jIXm+2C6CnjMJ3w\nI0RQBO+kvPMuqPY+dchgGd/IptREc5SXU6aKpGaM0mN6OCFktbmj4v2B99QqZ2Jh\n8BpF8V44naZpioCYF6Ve6WMhP+vLS3c1e9zCbBbJN2SLLLsiDnmQBxbW8O+SeLUL\ngOsiamIkMe7W2naY5+zPT9e1poX8a4JGxAuwffk3395093ReBXPU/9LOyWyVKSH3\n2e0rkGnrmXe2Zx8ghGdfl7rdzVNrgedyvzdJE9PX3QKBgQDwHoPFtUSkcNFmu+pq\nLGeUxfjj+FJfDDccok73sOro+oSIR7CrsPFER4xm9mAv7zhYoRQM9ST8iZF4gzS/\nadgQ80QE+fc0vf2cw7vmiWq8/qHI4OQ0QChWNXfN4FQ/8pLvlq+r8kiIuxgXKMJn\nFYjHywFp7sGJeePl3x3x2BFSHQKBgQDU7CwJWSEl2UfMP1f6cVz6KEL36ym7xIp/\nqSwKvnRAAxzKEFETzO46xq/N+F19AsGm4veacK+Z0/x9NeSPUuT38xvZyisTOwFe\n7yJZ/4aSxAHiOtjq1MTHQp8QievBPiHgk2TOn5vu1LfQRdaNXHvVRenSFfZTaSJY\nca/XnOHtpQKBgQDSrhN0Py2xEoPIngx5h+iCMonEjDbJyo/4gbjDvuj97gCnCi/L\nFP87p4NbO8T9ieloajyLefQv2AxZLtXzNM0tYiRGMYRjNGf3Sg3topiSpuAQvrG7\n3qcFrPgnHTMOwKmHqjEMrxJRVcc3Wr3ncI+IrWfaKHCLTPVW1cMSVUAtSQKBgBBl\nq7KAmavngr749daEmmttZFLhWlJqfVv9dDXTmvI/Cx2IiiXjN0lxeaJ8CP8SkkU+\n32CWYv+OsrgVyWc8NAPgRfnMtuqBNcbQ1a1mnz94NsjsTT4waoMJ32QPqwczuLop\nv66l3gVTfmBcsHwsbiDrhGk4ZcLgqtNy1d7d5ww9AoGBAJDjwVqkBJgmdBqnPdE+\n4BfTThQXUO6X976sQSX7op1uNv/ofE8fO3gvF/d8YzolpOrI0+igSUVEXASDkujx\nFmU3wR04qEr2LydGuaSvXvYIOw8htzx8wI9//OWA5p7f/+hNLo1bD0h7JTkfadEI\ntUL5tF7DbnMTXl6Wo8Ggsaj0\n-----END PRIVATE KEY-----\n",
"client_email": "firebase-adminsdk-nckf2@global-1f5f9.iam.gserviceaccount.com",
"client_id": "116364112880753391831",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-nckf2%40global-1f5f9.iam.gserviceaccount.com"
}

View File

@ -1,20 +1,35 @@
const config = require("./config/config.ts");
const config = require("./config/config.js");
/*const admin = require("firebase-admin");
const serviceAccount = require("./config/serviceAccount.json");
const secondaryAppConfig = {
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://global-1f5f9.firebaseio.com",
};
const secondary = admin.initializeApp(secondaryAppConfig, "secondary");
const globaldb = secondary.database();
const global = {
db: {
guilds: {},
},
};*/
if (config.devMode) {
console.log('- dev mode- ');
config.token = config.devToken;
config.shards = 1;
console.log("- dev mode- ");
config.token = config.devToken;
config.shards = 1;
}
const {
ShardingManager
} = require('discord.js');
const manager = new ShardingManager('./src/bot.ts', {
token: config.token,
respawn: config.respawn,
totalShards: config.shards
ShardingManager
} = require("discord.js");
const manager = new ShardingManager("./src/bot.js", {
token: config.token,
respawn: config.respawn,
totalShards: config.shards,
});
console.log('- Launching shards -');
console.log("- Launching shards -");
manager.spawn(config.shards, config.shardDelay, config.shardTimeout);
manager.on('shardCreate', shard => console.log(`- Launched shard ${shard.id} -`));
manager.on("shardCreate", (shard) =>
console.log(`- Launched shard ${shard.id} -`)
);

2
src/bot.js Normal file
View File

@ -0,0 +1,2 @@
const MusicClient = require('./struct/client.js');
const client = new MusicClient({});

View File

@ -1,2 +0,0 @@
const MusicClient = require('./struct/client.ts');
const client = new MusicClient({});

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(" ");

View File

@ -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);
}
};
};

View File

@ -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;

View File

@ -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}`);

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)
);
}
};
};

View File

@ -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!",
};
};

View File

@ -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;
};
};

View File

@ -1,4 +1,4 @@
const config = require("../config/config.ts");
const config = require("../config/config.js");
const express = require("express"); // Express web server framework
const request = require("request"); // "Request" library
const cors = require("cors");
@ -42,13 +42,13 @@ app.get("/login", function (req, res) {
res.redirect(
"https://accounts.spotify.com/authorize?" +
querystring.stringify({
response_type: "code",
client_id: client_id,
scope: scope,
redirect_uri: redirect_uri,
state: state,
})
querystring.stringify({
response_type: "code",
client_id: client_id,
scope: scope,
redirect_uri: redirect_uri,
state: state,
})
);
});
@ -63,9 +63,9 @@ app.get("/callback", function (req, res) {
if (state === null || state !== storedState) {
res.redirect(
"/#" +
querystring.stringify({
error: "state_mismatch",
})
querystring.stringify({
error: "state_mismatch",
})
);
} else {
res.clearCookie(stateKey);
@ -77,8 +77,7 @@ app.get("/callback", function (req, res) {
grant_type: "authorization_code",
},
headers: {
Authorization:
"Basic " +
Authorization: "Basic " +
new Buffer(client_id + ":" + client_secret).toString("base64"),
},
json: true,
@ -105,17 +104,17 @@ app.get("/callback", function (req, res) {
// we can also pass the token to the browser to make requests from there
res.redirect(
"/#" +
querystring.stringify({
access_token: access_token,
refresh_token: refresh_token,
})
querystring.stringify({
access_token: access_token,
refresh_token: refresh_token,
})
);
} else {
res.redirect(
"/#" +
querystring.stringify({
error: "invalid_token",
})
querystring.stringify({
error: "invalid_token",
})
);
}
});
@ -128,8 +127,7 @@ app.get("/refresh_token", function (req, res) {
var authOptions = {
url: "https://accounts.spotify.com/api/token",
headers: {
Authorization:
"Basic " +
Authorization: "Basic " +
new Buffer(client_id + ":" + client_secret).toString("base64"),
},
form: {
@ -150,4 +148,4 @@ app.get("/refresh_token", function (req, res) {
});
console.log("Listening on " + config.port);
app.listen(config.port);
app.listen(config.port);