mirror of
https://github.com/musix-org/musix-oss
synced 2024-12-23 00:23:17 +00:00
New config system and error logging
This commit is contained in:
parent
3a1ad33dd6
commit
4b3b798ddc
14
index.js
14
index.js
@ -1,4 +1,5 @@
|
||||
const config = require("./src/struct/config/config.js");
|
||||
const DiscordWebhook = require("discord-webhook-node");
|
||||
|
||||
if (config.devMode) {
|
||||
console.log("- dev mode- ");
|
||||
@ -6,9 +7,7 @@ if (config.devMode) {
|
||||
config.shards = 1;
|
||||
}
|
||||
|
||||
const {
|
||||
ShardingManager
|
||||
} = require("discord.js");
|
||||
const { ShardingManager } = require("discord.js");
|
||||
const manager = new ShardingManager("./src/bot.js", {
|
||||
token: config.token,
|
||||
respawn: config.respawn,
|
||||
@ -20,3 +19,12 @@ manager.spawn(config.shards, config.shardDelay, config.shardTimeout);
|
||||
manager.on("shardCreate", (shard) =>
|
||||
console.log(`- Launched shard ${shard.id} -`)
|
||||
);
|
||||
|
||||
const webhookClient = new DiscordWebhook.Webhook(config.webhookUrl);
|
||||
|
||||
const oldConsole = {};
|
||||
oldConsole.log = console.log;
|
||||
console.log = function (arg) {
|
||||
oldConsole.log(arg);
|
||||
webhookClient.send(arg);
|
||||
};
|
||||
|
@ -23,6 +23,7 @@
|
||||
"cookie-parser": "^1.4.5",
|
||||
"cors": "^2.8.5",
|
||||
"dblapi.js": "^2.4.0",
|
||||
"discord-webhook-node": "^1.0.7",
|
||||
"discord.js": "^12.2.0",
|
||||
"dotenv": "^8.2.0",
|
||||
"erlpack": "github:discordapp/erlpack",
|
||||
|
11
src/bot.js
11
src/bot.js
@ -1,2 +1,11 @@
|
||||
const MusicClient = require('./struct/client.js');
|
||||
const MusicClient = require("./struct/client.js");
|
||||
const DiscordWebhook = require("discord-webhook-node");
|
||||
const client = new MusicClient({});
|
||||
const webhookClient = new DiscordWebhook.Webhook(client.config.webhookUrl);
|
||||
|
||||
const oldConsole = {};
|
||||
oldConsole.log = console.log;
|
||||
console.log = function (arg) {
|
||||
oldConsole.log(arg);
|
||||
webhookClient.send(arg);
|
||||
};
|
||||
|
@ -14,6 +14,7 @@ module.exports = {
|
||||
spotify_refresh_token: process.env.SPOTIFY_REFRESH_TOKEN,
|
||||
lastfm_api_key: process.env.LASTFM_API_KEY,
|
||||
lastfm_secret: process.env.LASTFM_SECRET,
|
||||
webhookUrl: process.env.WEBHOOK_URL,
|
||||
port: 8888,
|
||||
redirectUri: "http://localhost:8888/callback/",
|
||||
testServer: "489111553321336832",
|
||||
@ -23,7 +24,7 @@ module.exports = {
|
||||
embedColor: "#b50002",
|
||||
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,
|
||||
@ -40,3 +41,61 @@ module.exports = {
|
||||
startPlaying: true,
|
||||
bass: 1,
|
||||
};
|
||||
|
||||
module.exports.streamConfig = {
|
||||
ytdlOptions: {
|
||||
filter: "audio",
|
||||
highWaterMark: 1 << 25,
|
||||
volume: false,
|
||||
requestOptions: {
|
||||
maxRedirects: 4
|
||||
}
|
||||
},
|
||||
options: {
|
||||
seek: null,
|
||||
bitrate: 1024,
|
||||
volume: 1,
|
||||
type: "converted",
|
||||
},
|
||||
}
|
||||
|
||||
module.exports.queueConfig = {
|
||||
textChannel: null,
|
||||
voiceChannel: null,
|
||||
connection: null,
|
||||
songs: [],
|
||||
volume: null,
|
||||
bass: null,
|
||||
nigthCore: false,
|
||||
playing: false,
|
||||
paused: false,
|
||||
looping: false,
|
||||
songLooping: false,
|
||||
votes: 0,
|
||||
voters: [],
|
||||
votesNeeded: null,
|
||||
time: 0,
|
||||
endReason: null,
|
||||
}
|
||||
|
||||
module.exports.emojis = {
|
||||
garbage: "🗑️ ",
|
||||
green_check_mark: "<:green_check_mark:674265384777416705> ",
|
||||
loading: "<a:loading:674284196700618783> ",
|
||||
loudSound: ":loud_sound: ",
|
||||
megaPhone: "📣 ",
|
||||
notes: "<a:aNotes:674602408105476106>",
|
||||
pause: "<:pause:674685548610322462> ",
|
||||
previous: "<:reverse:705012312142119012> ",
|
||||
redx: "<:redx:674263474704220182> ",
|
||||
repeat: "<:repeat1:674685561377914892> ",
|
||||
repeatSong: "<:repeatsong:674685573419761716> ",
|
||||
resume: "<:resume:674685585478254603> ",
|
||||
shuffle: "<:shuffle:674685595980791871> ",
|
||||
signal: ":signal_strength: ",
|
||||
skip: "<:skip:674685614221688832> ",
|
||||
speaker: ":speaker: ",
|
||||
stop: "<:stop:674685626108477519> ",
|
||||
stopWatch: ":stopwatch: ",
|
||||
volumeHigh: "<:volumehigh:674685637626167307> ",
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
module.exports = {
|
||||
garbage: "🗑️ ",
|
||||
green_check_mark: "<:green_check_mark:674265384777416705> ",
|
||||
loading: "<a:loading:674284196700618783> ",
|
||||
loudSound: ":loud_sound: ",
|
||||
megaPhone: "📣 ",
|
||||
notes: "<a:aNotes:674602408105476106>",
|
||||
pause: "<:pause:674685548610322462> ",
|
||||
previous: "<:reverse:705012312142119012> ",
|
||||
redx: "<:redx:674263474704220182> ",
|
||||
repeat: "<:repeat1:674685561377914892> ",
|
||||
repeatSong: "<:repeatsong:674685573419761716> ",
|
||||
resume: "<:resume:674685585478254603> ",
|
||||
shuffle: "<:shuffle:674685595980791871> ",
|
||||
signal: ":signal_strength: ",
|
||||
skip: "<:skip:674685614221688832> ",
|
||||
speaker: ":speaker: ",
|
||||
stop: "<:stop:674685626108477519> ",
|
||||
stopWatch: ":stopwatch: ",
|
||||
volumeHigh: "<:volumehigh:674685637626167307> ",
|
||||
};
|
@ -1,4 +1,6 @@
|
||||
const emojis = require("./emojis.js");
|
||||
const {
|
||||
emojis
|
||||
} = require("./config.js");
|
||||
|
||||
module.exports = {
|
||||
emojis: emojis,
|
||||
|
@ -1,18 +0,0 @@
|
||||
module.exports = {
|
||||
textChannel: null,
|
||||
voiceChannel: null,
|
||||
connection: null,
|
||||
songs: [],
|
||||
volume: null,
|
||||
bass: null,
|
||||
nigthCore: false,
|
||||
playing: false,
|
||||
paused: false,
|
||||
looping: false,
|
||||
songLooping: false,
|
||||
votes: 0,
|
||||
voters: [],
|
||||
votesNeeded: null,
|
||||
time: 0,
|
||||
endReason: null,
|
||||
};
|
@ -1,13 +0,0 @@
|
||||
module.exports = {
|
||||
ytdlOptions: {
|
||||
filter: "audio",
|
||||
highWaterMark: 1 << 25,
|
||||
volume: false,
|
||||
},
|
||||
options: {
|
||||
seek: null,
|
||||
bitrate: 1024,
|
||||
volume: 1,
|
||||
type: "converted",
|
||||
},
|
||||
};
|
@ -1,10 +1,9 @@
|
||||
module.exports = async function (guild, song, client, seek, play) {
|
||||
const {
|
||||
Readable: ReadableStream
|
||||
} = require("stream");
|
||||
console.log("test");
|
||||
const { Readable: ReadableStream } = require("stream");
|
||||
const Discord = require("discord.js");
|
||||
const ytdl = require("ytdl-core");
|
||||
const streamConfig = require("../config/streamConfig.js");
|
||||
const { streamConfig } = require("../config/config.js");
|
||||
const prism = require("prism-media");
|
||||
const queue = client.queue.get(guild.id);
|
||||
if (!song) {
|
||||
@ -25,9 +24,10 @@ module.exports = async function (guild, song, client, seek, play) {
|
||||
streamConfig.options.seek = seek;
|
||||
|
||||
let input = song.url;
|
||||
if (song.type === "ytdl") input = ytdl(song.url, streamConfig.ytdlOptions)
|
||||
//.on('info', (info, format) => console.log(format))
|
||||
.on('error', err => console.log(err));
|
||||
if (song.type === "ytdl")
|
||||
input = ytdl(song.url, streamConfig.ytdlOptions)
|
||||
//.on('info', (info, format) => console.log(format))
|
||||
.on("error", (err) => console.log(err));
|
||||
|
||||
const ffmpegArgs = [
|
||||
"-analyzeduration",
|
||||
@ -80,7 +80,10 @@ module.exports = async function (guild, song, client, seek, play) {
|
||||
const embed = new Discord.MessageEmbed()
|
||||
.setTitle(`${client.messages.startPlaying}**${song.title}**`)
|
||||
.setDescription(
|
||||
`Song duration: \`${client.funcs.msToTime(queue.songs[0].info.lengthSeconds * 1000, "hh:mm:ss")}\``
|
||||
`Song duration: \`${client.funcs.msToTime(
|
||||
queue.songs[0].info.lengthSeconds * 1000,
|
||||
"hh:mm:ss"
|
||||
)}\``
|
||||
)
|
||||
.setColor(client.config.embedColor);
|
||||
queue.textChannel.send(embed);
|
||||
|
Loading…
Reference in New Issue
Block a user