Moved gm extensions and lavalink connection to start of ready, removed unused variable in stats

This commit is contained in:
TheEssem 2020-07-02 10:33:27 -05:00
parent c141540a2a
commit 111b177968
2 changed files with 42 additions and 41 deletions

View file

@ -4,7 +4,7 @@ const moment = require("moment");
require("moment-duration-format");
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 embed = {
embed: {

View file

@ -15,6 +15,46 @@ const twitter =
// run when ready
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
for (const [id] of client.guilds) {
const guildDB = (
@ -92,45 +132,6 @@ module.exports = async () => {
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
if (twitter !== null && twitter.active === false) {
const blocks = await twitter.client.blocks.ids();
@ -182,7 +183,7 @@ module.exports = async () => {
) {
tweetContent = await misc.getTweet(tweet, true, true);
} else {
tweetContent = await misc.getTweet(tweets, true);
tweetContent = await misc.getTweet(tweets, true).replace(/{{user}}/gm, `@${tweet.user.screen_name}`);
}
const payload = {
status: `@${tweet.user.screen_name} ${tweetContent}`,