Moved gm extensions and lavalink connection to start of ready, removed unused variable in stats
This commit is contained in:
parent
c141540a2a
commit
111b177968
2 changed files with 42 additions and 41 deletions
|
@ -4,7 +4,7 @@ const moment = require("moment");
|
||||||
require("moment-duration-format");
|
require("moment-duration-format");
|
||||||
const os = require("os");
|
const os = require("os");
|
||||||
|
|
||||||
exports.run = async (message) => {
|
exports.run = async () => {
|
||||||
const duration = moment.duration(client.uptime).format(" D [days], H [hrs], m [mins], s [secs]");
|
const duration = moment.duration(client.uptime).format(" D [days], H [hrs], m [mins], s [secs]");
|
||||||
const embed = {
|
const embed = {
|
||||||
embed: {
|
embed: {
|
||||||
|
|
|
@ -15,6 +15,46 @@ const twitter =
|
||||||
|
|
||||||
// run when ready
|
// run when ready
|
||||||
module.exports = async () => {
|
module.exports = async () => {
|
||||||
|
// add gm extensions
|
||||||
|
gm.prototype.writePromise = promisify(gm.prototype.write);
|
||||||
|
gm.prototype.streamPromise = promisify(gm.prototype.stream);
|
||||||
|
gm.prototype.sizePromise = promisify(gm.prototype.size);
|
||||||
|
gm.prototype.identifyPromise = promisify(gm.prototype.identify);
|
||||||
|
gm.prototype.bufferPromise = function(format, delay, type) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
this.in(
|
||||||
|
delay ? "-delay" : "",
|
||||||
|
delay ? delay.split("/").reverse().join("x") : ""
|
||||||
|
)
|
||||||
|
.out(
|
||||||
|
type !== "sonic" ? "-layers" : "",
|
||||||
|
type !== "sonic" ? "OptimizeTransparency" : ""
|
||||||
|
)
|
||||||
|
.out(type !== "sonic" ? "-fuzz" : "", type !== "sonic" ? "2%" : "")
|
||||||
|
.out("+profile", "xmp")
|
||||||
|
.out("-limit", "memory", "64MB")
|
||||||
|
.out("-limit", "map", "128MB")
|
||||||
|
.stream(format, (err, stdout, stderr) => {
|
||||||
|
if (err) return reject(err);
|
||||||
|
const chunks = [];
|
||||||
|
stdout.on("data", (chunk) => {
|
||||||
|
chunks.push(chunk);
|
||||||
|
});
|
||||||
|
// these are 'once' because they can and do fire multiple times for multiple errors,
|
||||||
|
// but this is a promise so you'll have to deal with them one at a time
|
||||||
|
stdout.once("end", () => {
|
||||||
|
resolve(Buffer.concat(chunks));
|
||||||
|
});
|
||||||
|
stderr.once("data", (data) => {
|
||||||
|
reject(data.toString());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// connect to lavalink
|
||||||
|
if (!soundPlayer.status) await soundPlayer.connect();
|
||||||
|
|
||||||
// make sure settings/tags exist
|
// make sure settings/tags exist
|
||||||
for (const [id] of client.guilds) {
|
for (const [id] of client.guilds) {
|
||||||
const guildDB = (
|
const guildDB = (
|
||||||
|
@ -92,45 +132,6 @@ module.exports = async () => {
|
||||||
setTimeout(activityChanger, 900000);
|
setTimeout(activityChanger, 900000);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// add gm extensions
|
|
||||||
gm.prototype.writePromise = promisify(gm.prototype.write);
|
|
||||||
gm.prototype.streamPromise = promisify(gm.prototype.stream);
|
|
||||||
gm.prototype.sizePromise = promisify(gm.prototype.size);
|
|
||||||
gm.prototype.identifyPromise = promisify(gm.prototype.identify);
|
|
||||||
gm.prototype.bufferPromise = function(format, delay, type) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
this.in(
|
|
||||||
delay ? "-delay" : "",
|
|
||||||
delay ? delay.split("/").reverse().join("x") : ""
|
|
||||||
)
|
|
||||||
.out(
|
|
||||||
type !== "sonic" ? "-layers" : "",
|
|
||||||
type !== "sonic" ? "OptimizeTransparency" : ""
|
|
||||||
)
|
|
||||||
.out(type !== "sonic" ? "-fuzz" : "", type !== "sonic" ? "2%" : "")
|
|
||||||
.out("+profile", "xmp")
|
|
||||||
.out("-limit", "memory", "64MB")
|
|
||||||
.out("-limit", "map", "128MB")
|
|
||||||
.stream(format, (err, stdout, stderr) => {
|
|
||||||
if (err) return reject(err);
|
|
||||||
const chunks = [];
|
|
||||||
stdout.on("data", (chunk) => {
|
|
||||||
chunks.push(chunk);
|
|
||||||
});
|
|
||||||
// these are 'once' because they can and do fire multiple times for multiple errors,
|
|
||||||
// but this is a promise so you'll have to deal with them one at a time
|
|
||||||
stdout.once("end", () => {
|
|
||||||
resolve(Buffer.concat(chunks));
|
|
||||||
});
|
|
||||||
stderr.once("data", (data) => {
|
|
||||||
reject(data.toString());
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!soundPlayer.status) await soundPlayer.connect();
|
|
||||||
|
|
||||||
// tweet stuff
|
// tweet stuff
|
||||||
if (twitter !== null && twitter.active === false) {
|
if (twitter !== null && twitter.active === false) {
|
||||||
const blocks = await twitter.client.blocks.ids();
|
const blocks = await twitter.client.blocks.ids();
|
||||||
|
@ -182,7 +183,7 @@ module.exports = async () => {
|
||||||
) {
|
) {
|
||||||
tweetContent = await misc.getTweet(tweet, true, true);
|
tweetContent = await misc.getTweet(tweet, true, true);
|
||||||
} else {
|
} else {
|
||||||
tweetContent = await misc.getTweet(tweets, true);
|
tweetContent = await misc.getTweet(tweets, true).replace(/{{user}}/gm, `@${tweet.user.screen_name}`);
|
||||||
}
|
}
|
||||||
const payload = {
|
const payload = {
|
||||||
status: `@${tweet.user.screen_name} ${tweetContent}`,
|
status: `@${tweet.user.screen_name} ${tweetContent}`,
|
||||||
|
|
Loading…
Reference in a new issue