Fixed some DM command issues, made reload and restart use IPC
This commit is contained in:
parent
e0e0c9c7d4
commit
56113a1cf8
18 changed files with 54 additions and 35 deletions
|
@ -3,7 +3,7 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class BirdCommand extends Command {
|
||||
async run() {
|
||||
this.message.channel.sendTyping();
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
const imageData = await fetch("http://shibe.online/api/birds");
|
||||
const json = await imageData.json();
|
||||
return {
|
||||
|
|
|
@ -3,7 +3,7 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class CatCommand extends Command {
|
||||
async run() {
|
||||
this.message.channel.sendTyping();
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
const data = await fetch("https://projectlounge.pw/cta/", { redirect: "manual" });
|
||||
return {
|
||||
embed: {
|
||||
|
|
|
@ -3,7 +3,7 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class DogCommand extends Command {
|
||||
async run() {
|
||||
this.message.channel.sendTyping();
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
const imageData = await fetch("https://dog.ceo/api/breeds/image/random");
|
||||
const json = await imageData.json();
|
||||
return {
|
||||
|
|
|
@ -4,7 +4,7 @@ const Command = require("../../classes/command.js");
|
|||
class MCCommand extends Command {
|
||||
async run() {
|
||||
if (this.args.length === 0) return `${this.message.author.mention}, you need to provide some text to generate a Minecraft achievement!`;
|
||||
this.message.channel.sendTyping();
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
const request = await fetch(`https://www.minecraftskinstealer.com/achievement/a.php?i=13&h=Achievement+get%21&t=${encodeURIComponent(this.args.join("+"))}`);
|
||||
return {
|
||||
file: await request.buffer(),
|
||||
|
|
|
@ -5,7 +5,7 @@ const Command = require("../../classes/command.js");
|
|||
class RetroCommand extends Command {
|
||||
async run() {
|
||||
if (this.args.length === 0) return `${this.message.author.mention}, you need to provide some text to generate some retro text!`;
|
||||
this.message.channel.sendTyping();
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
let [line1, line2, line3] = this.args.join(" ").replaceAll("&", "\\&").replaceAll(">", "\\>").replaceAll("<", "\\<").replaceAll("\"", "\\"").replaceAll("'", "\\'").replaceAll("%", "\\%").split(",").map(elem => elem.trim());
|
||||
if (!line2 && line1.length > 15) {
|
||||
const [split1, split2, split3] = wrap(line1, { width: 15, indent: "" }).split("\n");
|
||||
|
|
|
@ -3,7 +3,7 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class WikihowCommand extends Command {
|
||||
async run() {
|
||||
this.message.channel.sendTyping();
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
const request = await fetch("https://hargrimm-wikihow-v1.p.rapidapi.com/images?count=1", {
|
||||
headers: {
|
||||
"X-RapidAPI-Key": process.env.MASHAPE,
|
||||
|
|
|
@ -4,7 +4,7 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class LengthenCommand extends Command {
|
||||
async run() {
|
||||
this.message.channel.sendTyping();
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
if (this.args.length === 0 || !urlCheck(this.args[0])) return `${this.message.author.mention}, you need to provide a short URL to lengthen!`;
|
||||
if (urlCheck(this.args[0])) {
|
||||
const url = await fetch(encodeURI(this.args[0]), { redirect: "manual" });
|
||||
|
|
|
@ -2,7 +2,7 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class PingCommand extends Command {
|
||||
async run() {
|
||||
const pingMessage = await this.message.channel.createMessage("🏓 Ping?");
|
||||
const pingMessage = await this.client.createMessage(this.message.channel.id, "🏓 Ping?");
|
||||
return pingMessage.edit(`🏓 Pong!\n\`\`\`\nLatency: ${pingMessage.timestamp - this.message.timestamp}ms${this.message.channel.guild ? `\nShard Latency: ${Math.round(this.client.shards.get(this.client.guildShardMap[this.message.channel.guild.id]).latency)}ms` : ""}\n\`\`\``);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ const Command = require("../../classes/command.js");
|
|||
class QrCreateCommand extends Command {
|
||||
async run() {
|
||||
if (this.args.length === 0) return `${this.message.author.mention}, you need to provide some text to generate a QR code!`;
|
||||
this.message.channel.sendTyping();
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
const writable = new stream.PassThrough();
|
||||
qrcode.toFileStream(writable, this.content, { margin: 1 });
|
||||
const file = await this.streamToBuf(writable);
|
||||
|
|
|
@ -8,7 +8,7 @@ class QrReadCommand extends Command {
|
|||
async run() {
|
||||
const image = await require("../../utils/imagedetect.js")(this.client, this.message);
|
||||
if (image === undefined) return `${this.message.author.mention}, you need to provide an image with a QR code to read!`;
|
||||
this.message.channel.sendTyping();
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
const data = await (await fetch(image.path)).buffer();
|
||||
const rawData = await sharp(data).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
||||
const qrBuffer = jsqr(rawData.data, rawData.info.width, rawData.info.height);
|
||||
|
|
|
@ -1,16 +1,23 @@
|
|||
const handler = require("../../utils/handler.js");
|
||||
const collections = require("../../utils/collections.js");
|
||||
const Command = require("../../classes/command.js");
|
||||
|
||||
class ReloadCommand extends Command {
|
||||
async run() {
|
||||
if (this.message.author.id !== process.env.OWNER) return `${this.message.author.mention}, only the bot owner can reload commands!`;
|
||||
if (this.args.length === 0) return `${this.message.author.mention}, you need to provide a command to reload!`;
|
||||
const result = await handler.unload(this.args[0]);
|
||||
if (result) return result;
|
||||
const result2 = await handler.load(collections.paths.get(this.args[0]));
|
||||
if (result2) return result2;
|
||||
return `${this.message.author.mention}, the command \`${this.args[0]}\` has been reloaded.`;
|
||||
// quite possibly one of the hackiest commands in the bot
|
||||
run() {
|
||||
return new Promise((resolve) => {
|
||||
if (this.message.author.id !== process.env.OWNER) resolve(`${this.message.author.mention}, only the bot owner can reload commands!`);
|
||||
if (this.args.length === 0) resolve(`${this.message.author.mention}, you need to provide a command to reload!`);
|
||||
this.ipc.broadcast("reload", { cmd: this.args[0] });
|
||||
this.ipc.register("reloadSuccess", () => {
|
||||
this.ipc.unregister("reloadSuccess");
|
||||
this.ipc.unregister("reloadFail");
|
||||
resolve(`${this.message.author.mention}, the command \`${this.args[0]}\` has been reloaded.`);
|
||||
});
|
||||
this.ipc.register("reloadFail", (message) => {
|
||||
this.ipc.unregister("reloadSuccess");
|
||||
this.ipc.unregister("reloadFail");
|
||||
resolve(message);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
static description = "Reloads a command";
|
||||
|
|
|
@ -5,11 +5,11 @@ const Command = require("../../classes/command.js");
|
|||
class RestartCommand extends Command {
|
||||
async run() {
|
||||
if (this.message.author.id !== process.env.OWNER) return `${this.message.author.mention}, only the bot owner can restart me!`;
|
||||
await this.message.channel.createMessage(`${this.message.author.mention}, esmBot is restarting.`);
|
||||
await this.client.createMessage(this.message.channel.id, `${this.message.author.mention}, esmBot is restarting.`);
|
||||
for (const command of collections.commands) {
|
||||
await handler.unload(command);
|
||||
}
|
||||
process.exit(1);
|
||||
this.ipc.broadcast("restart");
|
||||
}
|
||||
|
||||
static description = "Restarts me";
|
||||
|
|
|
@ -54,7 +54,7 @@ class StatsCommand extends Command {
|
|||
},
|
||||
{
|
||||
"name": "Shard",
|
||||
"value": this.client.guildShardMap[this.message.channel.guild.id],
|
||||
"value": this.message.channel.guild ? this.client.guildShardMap[this.message.channel.guild.id] : "N/A",
|
||||
"inline": true
|
||||
}
|
||||
]
|
||||
|
|
|
@ -6,7 +6,7 @@ const Command = require("../../classes/command.js");
|
|||
class YouTubeCommand extends Command {
|
||||
async run() {
|
||||
if (this.args.length === 0) return `${this.message.author.mention}, you need to provide something to search for!`;
|
||||
this.message.channel.sendTyping();
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
const messages = [];
|
||||
const request = await fetch(`https://www.googleapis.com/youtube/v3/search?part=snippet&q=${encodeURIComponent(this.args.join(" "))}&key=${process.env.GOOGLE}&maxResults=50`);
|
||||
const result = await request.json();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue