mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-25 22:32:50 +02:00
Fix lots of code dupe
This commit is contained in:
@@ -20,7 +20,8 @@ module.exports = class GenderCommand extends Command {
|
|||||||
{
|
{
|
||||||
key: 'name',
|
key: 'name',
|
||||||
prompt: 'What name do you want to determine the gender of?',
|
prompt: 'What name do you want to determine the gender of?',
|
||||||
type: 'string'
|
type: 'string',
|
||||||
|
max: 20
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -53,13 +53,7 @@ module.exports = class AceAttorneyCommand extends Command {
|
|||||||
prompt: `What character do you want to use? Either ${list(Object.keys(characters), 'or')}.`,
|
prompt: `What character do you want to use? Either ${list(Object.keys(characters), 'or')}.`,
|
||||||
type: 'string',
|
type: 'string',
|
||||||
oneOf: Object.values(characters).reduce((a, b) => a.concat(b)),
|
oneOf: Object.values(characters).reduce((a, b) => a.concat(b)),
|
||||||
parse: character => {
|
parse: character => character.toLowerCase()
|
||||||
for (const [id, arr] of Object.entries(characters)) {
|
|
||||||
if (!arr.includes(character.toLowerCase())) continue;
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
return character.toLowerCase();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'quote',
|
key: 'quote',
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const gm = require('gm').subClass({ imageMagick: true });
|
const gm = require('gm').subClass({ imageMagick: true });
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
|
const { magikToBuffer } = require('../../util/Util');
|
||||||
|
|
||||||
module.exports = class CharcoalCommand extends Command {
|
module.exports = class CharcoalCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -38,20 +39,11 @@ module.exports = class CharcoalCommand extends Command {
|
|||||||
const magik = gm(body);
|
const magik = gm(body);
|
||||||
magik.charcoal(1);
|
magik.charcoal(1);
|
||||||
magik.setFormat('png');
|
magik.setFormat('png');
|
||||||
const attachment = await this.toBuffer(magik);
|
const attachment = await magikToBuffer(magik);
|
||||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||||
return msg.say({ files: [{ attachment, name: 'sketch.png' }] });
|
return msg.say({ files: [{ attachment, name: 'sketch.png' }] });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toBuffer(magik) {
|
|
||||||
return new Promise((res, rej) => {
|
|
||||||
magik.toBuffer((err, buffer) => {
|
|
||||||
if (err) return rej(err);
|
|
||||||
return res(buffer);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const gm = require('gm').subClass({ imageMagick: true });
|
const gm = require('gm').subClass({ imageMagick: true });
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
|
const { magikToBuffer } = require('../../util/Util');
|
||||||
|
|
||||||
module.exports = class EmbossCommand extends Command {
|
module.exports = class EmbossCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -38,20 +39,11 @@ module.exports = class EmbossCommand extends Command {
|
|||||||
const magik = gm(body);
|
const magik = gm(body);
|
||||||
magik.emboss();
|
magik.emboss();
|
||||||
magik.setFormat('png');
|
magik.setFormat('png');
|
||||||
const attachment = await this.toBuffer(magik);
|
const attachment = await magikToBuffer(magik);
|
||||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||||
return msg.say({ files: [{ attachment, name: 'emboss.png' }] });
|
return msg.say({ files: [{ attachment, name: 'emboss.png' }] });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toBuffer(magik) {
|
|
||||||
return new Promise((res, rej) => {
|
|
||||||
magik.toBuffer((err, buffer) => {
|
|
||||||
if (err) return rej(err);
|
|
||||||
return res(buffer);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const gm = require('gm').subClass({ imageMagick: true });
|
const gm = require('gm').subClass({ imageMagick: true });
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
|
const { magikToBuffer } = require('../../util/Util');
|
||||||
|
|
||||||
module.exports = class ImplodeCommand extends Command {
|
module.exports = class ImplodeCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -45,20 +46,11 @@ module.exports = class ImplodeCommand extends Command {
|
|||||||
const magik = gm(body);
|
const magik = gm(body);
|
||||||
magik.implode(level / 100);
|
magik.implode(level / 100);
|
||||||
magik.setFormat('png');
|
magik.setFormat('png');
|
||||||
const attachment = await this.toBuffer(magik);
|
const attachment = await magikToBuffer(magik);
|
||||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||||
return msg.say({ files: [{ attachment, name: 'implode.png' }] });
|
return msg.say({ files: [{ attachment, name: 'implode.png' }] });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toBuffer(magik) {
|
|
||||||
return new Promise((res, rej) => {
|
|
||||||
magik.toBuffer((err, buffer) => {
|
|
||||||
if (err) return rej(err);
|
|
||||||
return res(buffer);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const gm = require('gm').subClass({ imageMagick: true });
|
const gm = require('gm').subClass({ imageMagick: true });
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
|
const { magikToBuffer } = require('../../util/Util');
|
||||||
|
|
||||||
module.exports = class LiquidRescaleCommand extends Command {
|
module.exports = class LiquidRescaleCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -41,20 +42,11 @@ module.exports = class LiquidRescaleCommand extends Command {
|
|||||||
magik.out('50%');
|
magik.out('50%');
|
||||||
magik.implode(0.25);
|
magik.implode(0.25);
|
||||||
magik.setFormat('png');
|
magik.setFormat('png');
|
||||||
const attachment = await this.toBuffer(magik);
|
const attachment = await magikToBuffer(magik);
|
||||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||||
return msg.say({ files: [{ attachment, name: 'liquid-rescale.png' }] });
|
return msg.say({ files: [{ attachment, name: 'liquid-rescale.png' }] });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toBuffer(magik) {
|
|
||||||
return new Promise((res, rej) => {
|
|
||||||
magik.toBuffer((err, buffer) => {
|
|
||||||
if (err) return rej(err);
|
|
||||||
return res(buffer);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const gm = require('gm').subClass({ imageMagick: true });
|
const gm = require('gm').subClass({ imageMagick: true });
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
const { list } = require('../../util/Util');
|
const { list, magikToBuffer } = require('../../util/Util');
|
||||||
const types = ['uniform', 'gaussian', 'multiplicative', 'impulse', 'laplacian', 'poisson'];
|
const types = ['uniform', 'gaussian', 'multiplicative', 'impulse', 'laplacian', 'poisson'];
|
||||||
|
|
||||||
module.exports = class NoiseCommand extends Command {
|
module.exports = class NoiseCommand extends Command {
|
||||||
@@ -48,20 +48,11 @@ module.exports = class NoiseCommand extends Command {
|
|||||||
const magik = gm(body);
|
const magik = gm(body);
|
||||||
magik.noise(type);
|
magik.noise(type);
|
||||||
magik.setFormat('png');
|
magik.setFormat('png');
|
||||||
const attachment = await this.toBuffer(magik);
|
const attachment = await magikToBuffer(magik);
|
||||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||||
return msg.say({ files: [{ attachment, name: 'noise.png' }] });
|
return msg.say({ files: [{ attachment, name: 'noise.png' }] });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toBuffer(magik) {
|
|
||||||
return new Promise((res, rej) => {
|
|
||||||
magik.toBuffer((err, buffer) => {
|
|
||||||
if (err) return rej(err);
|
|
||||||
return res(buffer);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const gm = require('gm').subClass({ imageMagick: true });
|
const gm = require('gm').subClass({ imageMagick: true });
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
|
const { magikToBuffer } = require('../../util/Util');
|
||||||
|
|
||||||
module.exports = class OilPaintingCommand extends Command {
|
module.exports = class OilPaintingCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -39,20 +40,11 @@ module.exports = class OilPaintingCommand extends Command {
|
|||||||
const magik = gm(body);
|
const magik = gm(body);
|
||||||
magik.paint(5);
|
magik.paint(5);
|
||||||
magik.setFormat('png');
|
magik.setFormat('png');
|
||||||
const attachment = await this.toBuffer(magik);
|
const attachment = await magikToBuffer(magik);
|
||||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||||
return msg.say({ files: [{ attachment, name: 'old-painting.png' }] });
|
return msg.say({ files: [{ attachment, name: 'old-painting.png' }] });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toBuffer(magik) {
|
|
||||||
return new Promise((res, rej) => {
|
|
||||||
magik.toBuffer((err, buffer) => {
|
|
||||||
if (err) return rej(err);
|
|
||||||
return res(buffer);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const gm = require('gm').subClass({ imageMagick: true });
|
const gm = require('gm').subClass({ imageMagick: true });
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
|
const { magikToBuffer } = require('../../util/Util');
|
||||||
|
|
||||||
module.exports = class SketchCommand extends Command {
|
module.exports = class SketchCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -41,20 +42,11 @@ module.exports = class SketchCommand extends Command {
|
|||||||
magik.out('-sketch');
|
magik.out('-sketch');
|
||||||
magik.out('0x20+120');
|
magik.out('0x20+120');
|
||||||
magik.setFormat('png');
|
magik.setFormat('png');
|
||||||
const attachment = await this.toBuffer(magik);
|
const attachment = await magikToBuffer(magik);
|
||||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||||
return msg.say({ files: [{ attachment, name: 'sketch.png' }] });
|
return msg.say({ files: [{ attachment, name: 'sketch.png' }] });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toBuffer(magik) {
|
|
||||||
return new Promise((res, rej) => {
|
|
||||||
magik.toBuffer((err, buffer) => {
|
|
||||||
if (err) return rej(err);
|
|
||||||
return res(buffer);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const gm = require('gm').subClass({ imageMagick: true });
|
const gm = require('gm').subClass({ imageMagick: true });
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
|
const { magikToBuffer } = require('../../util/Util');
|
||||||
|
|
||||||
module.exports = class SquishCommand extends Command {
|
module.exports = class SquishCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -50,20 +51,11 @@ module.exports = class SquishCommand extends Command {
|
|||||||
magik.out('-liquid-rescale');
|
magik.out('-liquid-rescale');
|
||||||
magik.out(command);
|
magik.out(command);
|
||||||
magik.setFormat('png');
|
magik.setFormat('png');
|
||||||
const attachment = await this.toBuffer(magik);
|
const attachment = await magikToBuffer(magik);
|
||||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||||
return msg.say({ files: [{ attachment, name: 'squish.png' }] });
|
return msg.say({ files: [{ attachment, name: 'squish.png' }] });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toBuffer(magik) {
|
|
||||||
return new Promise((res, rej) => {
|
|
||||||
magik.toBuffer((err, buffer) => {
|
|
||||||
if (err) return rej(err);
|
|
||||||
return res(buffer);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const gm = require('gm').subClass({ imageMagick: true });
|
const gm = require('gm').subClass({ imageMagick: true });
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
|
const { magikToBuffer } = require('../../util/Util');
|
||||||
|
|
||||||
module.exports = class SwirlCommand extends Command {
|
module.exports = class SwirlCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -45,20 +46,11 @@ module.exports = class SwirlCommand extends Command {
|
|||||||
const magik = gm(body);
|
const magik = gm(body);
|
||||||
magik.swirl(degrees);
|
magik.swirl(degrees);
|
||||||
magik.setFormat('png');
|
magik.setFormat('png');
|
||||||
const attachment = await this.toBuffer(magik);
|
const attachment = await magikToBuffer(magik);
|
||||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||||
return msg.say({ files: [{ attachment, name: 'swirl.png' }] });
|
return msg.say({ files: [{ attachment, name: 'swirl.png' }] });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toBuffer(magik) {
|
|
||||||
return new Promise((res, rej) => {
|
|
||||||
magik.toBuffer((err, buffer) => {
|
|
||||||
if (err) return rej(err);
|
|
||||||
return res(buffer);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ const Command = require('../../structures/Command');
|
|||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
const { createCanvas, registerFont } = require('canvas');
|
const { createCanvas, registerFont } = require('canvas');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const { reactIfAble } = require('../../util/Util');
|
||||||
const { wrapText } = require('../../util/Canvas');
|
const { wrapText } = require('../../util/Canvas');
|
||||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'OPTIKorinna-Agency.otf'), { family: 'Korinna' });
|
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'OPTIKorinna-Agency.otf'), { family: 'Korinna' });
|
||||||
|
|
||||||
@@ -47,9 +48,7 @@ module.exports = class JeopardyCommand extends Command {
|
|||||||
const connection = msg.guild ? this.client.voice.connections.get(msg.guild.id) : null;
|
const connection = msg.guild ? this.client.voice.connections.get(msg.guild.id) : null;
|
||||||
if (connection) {
|
if (connection) {
|
||||||
connection.play(path.join(__dirname, '..', '..', 'assets', 'sounds', 'jeopardy.mp3'));
|
connection.play(path.join(__dirname, '..', '..', 'assets', 'sounds', 'jeopardy.mp3'));
|
||||||
if (msg.channel.permissionsFor(this.client.user).has(['ADD_REACTIONS', 'READ_MESSAGE_HISTORY'])) {
|
await reactIfAble(msg, this.client.user, '🔉');
|
||||||
await msg.react('🔉');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
await msg.reply(`The category is: **${question.category.title.toUpperCase()}**. 30 seconds, good luck.`, {
|
await msg.reply(`The category is: **${question.category.title.toUpperCase()}**. 30 seconds, good luck.`, {
|
||||||
files: [{ attachment: clueCard, name: 'clue-card.png' }]
|
files: [{ attachment: clueCard, name: 'clue-card.png' }]
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ module.exports = class WhosThatPokemonCommand extends Command {
|
|||||||
ctx.font = '60px Pokemon';
|
ctx.font = '60px Pokemon';
|
||||||
ctx.textAlign = 'center';
|
ctx.textAlign = 'center';
|
||||||
ctx.textBaseline = 'bottom';
|
ctx.textBaseline = 'bottom';
|
||||||
ctx.lineWidth = 10;
|
ctx.lineWidth = 8;
|
||||||
ctx.strokeStyle = '#3c5aa6';
|
ctx.strokeStyle = '#3c5aa6';
|
||||||
ctx.strokeText(pokemon.name, 362, 158, 240);
|
ctx.strokeText(pokemon.name, 362, 158, 240);
|
||||||
ctx.fillStyle = '#ffcb05';
|
ctx.fillStyle = '#ffcb05';
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ module.exports = class RandomUserCommand extends Command {
|
|||||||
run(msg) {
|
run(msg) {
|
||||||
if (msg.channel.type === 'dm') {
|
if (msg.channel.type === 'dm') {
|
||||||
const members = [this.client.user, msg.channel.recipient];
|
const members = [this.client.user, msg.channel.recipient];
|
||||||
return msg.say(`I choose ${members[Math.floor(Math.random() * members.length)].username}!`);
|
return msg.say(`I choose ${members[Math.floor(Math.random() * members.length)].tag}!`);
|
||||||
}
|
}
|
||||||
return msg.say(`I choose ${msg.guild.members.cache.random().displayName}!`);
|
return msg.say(`I choose ${msg.guild.members.cache.random().user.tag}!`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const { reactIfAble } = require('../../util/Util');
|
||||||
const sounds = require('../../assets/json/airhorn');
|
const sounds = require('../../assets/json/airhorn');
|
||||||
|
|
||||||
module.exports = class AirhornCommand extends Command {
|
module.exports = class AirhornCommand extends Command {
|
||||||
@@ -34,9 +35,7 @@ module.exports = class AirhornCommand extends Command {
|
|||||||
}
|
}
|
||||||
const airhorn = sounds[Math.floor(Math.random() * sounds.length)];
|
const airhorn = sounds[Math.floor(Math.random() * sounds.length)];
|
||||||
connection.play(path.join(__dirname, '..', '..', 'assets', 'sounds', 'airhorn', airhorn));
|
connection.play(path.join(__dirname, '..', '..', 'assets', 'sounds', 'airhorn', airhorn));
|
||||||
if (msg.channel.permissionsFor(this.client.user).has(['ADD_REACTIONS', 'READ_MESSAGE_HISTORY'])) {
|
await reactIfAble(msg, this.client.user, '🔉');
|
||||||
await msg.react('🔉');
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
const { Readable } = require('stream');
|
const { Readable } = require('stream');
|
||||||
|
const { reactIfAble } = require('../../util/Util');
|
||||||
const { LOADING_EMOJI_ID } = process.env;
|
const { LOADING_EMOJI_ID } = process.env;
|
||||||
|
|
||||||
module.exports = class DECTalkCommand extends Command {
|
module.exports = class DECTalkCommand extends Command {
|
||||||
@@ -54,18 +55,15 @@ module.exports = class DECTalkCommand extends Command {
|
|||||||
return msg.reply(`I am not in a voice channel. Use ${usage} to fix that!`);
|
return msg.reply(`I am not in a voice channel. Use ${usage} to fix that!`);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (msg.channel.permissionsFor(this.client.user).has(['ADD_REACTIONS', 'READ_MESSAGE_HISTORY'])) {
|
await reactIfAble(msg, this.client.user, LOADING_EMOJI_ID, '💬');
|
||||||
await msg.react(LOADING_EMOJI_ID);
|
|
||||||
}
|
|
||||||
const { body } = await request
|
const { body } = await request
|
||||||
.get('http://tts.cyzon.us/tts')
|
.get('http://tts.cyzon.us/tts')
|
||||||
.query({ text });
|
.query({ text });
|
||||||
connection.play(Readable.from([body]));
|
connection.play(Readable.from([body]));
|
||||||
if (msg.channel.permissionsFor(this.client.user).has(['ADD_REACTIONS', 'READ_MESSAGE_HISTORY'])) {
|
await reactIfAble(msg, this.client.user, '🔉');
|
||||||
await msg.react('🔉');
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
await reactIfAble(msg, this.client.user, '⚠️');
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { list } = require('../../util/Util');
|
const { list, reactIfAble } = require('../../util/Util');
|
||||||
const sounds = require('../../assets/json/soundboard');
|
const sounds = require('../../assets/json/soundboard');
|
||||||
|
|
||||||
module.exports = class SoundboardCommand extends Command {
|
module.exports = class SoundboardCommand extends Command {
|
||||||
@@ -69,9 +69,7 @@ module.exports = class SoundboardCommand extends Command {
|
|||||||
return msg.reply(`I am not in a voice channel. Use ${usage} to fix that!`);
|
return msg.reply(`I am not in a voice channel. Use ${usage} to fix that!`);
|
||||||
}
|
}
|
||||||
connection.play(path.join(__dirname, '..', '..', 'assets', 'sounds', 'soundboard', sound));
|
connection.play(path.join(__dirname, '..', '..', 'assets', 'sounds', 'soundboard', sound));
|
||||||
if (msg.channel.permissionsFor(this.client.user).has(['ADD_REACTIONS', 'READ_MESSAGE_HISTORY'])) {
|
await reactIfAble(msg, this.client.user, '🔉');
|
||||||
await msg.react('🔉');
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
const { Readable } = require('stream');
|
const { Readable } = require('stream');
|
||||||
const { list } = require('../../util/Util');
|
const { list, reactIfAble } = require('../../util/Util');
|
||||||
const voices = require('../../assets/json/vocodes');
|
const voices = require('../../assets/json/vocodes');
|
||||||
const { LOADING_EMOJI_ID } = process.env;
|
const { LOADING_EMOJI_ID } = process.env;
|
||||||
|
|
||||||
@@ -52,9 +52,7 @@ module.exports = class VocodesCommand extends Command {
|
|||||||
return msg.reply(`I am not in a voice channel. Use ${usage} to fix that!`);
|
return msg.reply(`I am not in a voice channel. Use ${usage} to fix that!`);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (msg.channel.permissionsFor(this.client.user).has(['ADD_REACTIONS', 'READ_MESSAGE_HISTORY'])) {
|
await reactIfAble(msg, this.client.user, LOADING_EMOJI_ID, '💬');
|
||||||
await msg.react(LOADING_EMOJI_ID);
|
|
||||||
}
|
|
||||||
const { body } = await request
|
const { body } = await request
|
||||||
.post('https://mumble.stream/speak_spectrogram')
|
.post('https://mumble.stream/speak_spectrogram')
|
||||||
.send({
|
.send({
|
||||||
@@ -62,11 +60,10 @@ module.exports = class VocodesCommand extends Command {
|
|||||||
text
|
text
|
||||||
});
|
});
|
||||||
connection.play(Readable.from([Buffer.from(body.audio_base64, 'base64')]));
|
connection.play(Readable.from([Buffer.from(body.audio_base64, 'base64')]));
|
||||||
if (msg.channel.permissionsFor(this.client.user).has(['ADD_REACTIONS', 'READ_MESSAGE_HISTORY'])) {
|
await reactIfAble(msg, this.client.user, '🔉');
|
||||||
await msg.react('🔉');
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
await reactIfAble(msg, this.client.user, '⚠️');
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "119.34.5",
|
"version": "119.34.6",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -162,6 +162,15 @@ module.exports = class Util {
|
|||||||
return today;
|
return today;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static magikToBuffer(magik) {
|
||||||
|
return new Promise((res, rej) => {
|
||||||
|
magik.toBuffer((err, buffer) => {
|
||||||
|
if (err) return rej(err);
|
||||||
|
return res(buffer);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
static embedURL(title, url, display) {
|
static embedURL(title, url, display) {
|
||||||
return `[${title}](${url.replaceAll(')', '%29')}${display ? ` "${display}"` : ''})`;
|
return `[${title}](${url.replaceAll(')', '%29')}${display ? ` "${display}"` : ''})`;
|
||||||
}
|
}
|
||||||
@@ -172,6 +181,18 @@ module.exports = class Util {
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async reactIfAble(msg, user, emoji, fallbackEmoji) {
|
||||||
|
if (fallbackEmoji && !msg.channel.permissionsFor(user).has('USE_EXTERNAL_EMOJIS')) emoji = fallbackEmoji;
|
||||||
|
if (msg.channel.permissionsFor(user).has(['ADD_REACTIONS', 'READ_MESSAGE_HISTORY'])) {
|
||||||
|
try {
|
||||||
|
await msg.react(emoji);
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
static async verify(channel, user, { time = 30000, extraYes = [], extraNo = [] } = {}) {
|
static async verify(channel, user, { time = 30000, extraYes = [], extraNo = [] } = {}) {
|
||||||
const filter = res => {
|
const filter = res => {
|
||||||
const value = res.content.toLowerCase();
|
const value = res.content.toLowerCase();
|
||||||
|
|||||||
Reference in New Issue
Block a user