From e3fca9f4e97da59582bdf16a4b49d4fe3f87f828 Mon Sep 17 00:00:00 2001 From: Essem Date: Fri, 13 Aug 2021 21:34:44 -0500 Subject: [PATCH] Fixed pagination and typing in DMs --- commands/general/image.js | 2 +- commands/general/imagestats.js | 2 +- commands/general/raw.js | 2 +- commands/general/soundreload.js | 2 +- utils/pagination/awaitinteractions.js | 2 +- utils/pagination/pagination.js | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/commands/general/image.js b/commands/general/image.js index 47465bc..c87c7ec 100644 --- a/commands/general/image.js +++ b/commands/general/image.js @@ -9,7 +9,7 @@ class ImageSearchCommand extends Command { if (this.message.channel.guild && !this.message.channel.permissionsOf(this.client.user.id).has("addReactions")) return "I don't have the `Add Reactions` permission!"; if (this.message.channel.guild && !this.message.channel.permissionsOf(this.client.user.id).has("embedLinks")) return "I don't have the `Embed Links` permission!"; if (this.args.length === 0) return "You need to provide something to search for!"; - await this.message.channel.sendTyping(); + this.client.sendChannelTyping(this.message.channel.id); const embeds = []; const rawImages = await fetch(`${random(searx)}/search?format=json&safesearch=2&categories=images&q=!goi%20!bii%20!ddi%20${encodeURIComponent(this.args.join(" "))}`).then(res => res.json()); if (rawImages.results.length === 0) return "I couldn't find any results!"; diff --git a/commands/general/imagestats.js b/commands/general/imagestats.js index e3e74b2..b09d91c 100644 --- a/commands/general/imagestats.js +++ b/commands/general/imagestats.js @@ -2,7 +2,7 @@ const Command = require("../../classes/command.js"); class ImageStatsCommand extends Command { async run() { - await this.message.channel.sendTyping(); + await this.client.sendChannelTyping(this.message.channel.id); const servers = await this.ipc.command("image", { type: "stats" }, true); const embed = { embed: { diff --git a/commands/general/raw.js b/commands/general/raw.js index 47be2a7..46089a9 100644 --- a/commands/general/raw.js +++ b/commands/general/raw.js @@ -3,7 +3,7 @@ const imageDetect = require("../../utils/imagedetect.js"); class RawCommand extends Command { async run() { - this.message.channel.sendTyping(); + this.client.sendChannelTyping(this.message.channel.id); const image = await imageDetect(this.client, this.message); if (image === undefined) return "You need to provide an image to get a raw URL!"; return image.path; diff --git a/commands/general/soundreload.js b/commands/general/soundreload.js index e349ccb..ac8b37a 100644 --- a/commands/general/soundreload.js +++ b/commands/general/soundreload.js @@ -5,7 +5,7 @@ class SoundReloadCommand extends Command { run() { return new Promise((resolve) => { if (this.message.author.id !== process.env.OWNER) return "Only the bot owner can reload Lavalink!"; - this.message.channel.sendTyping(); + this.client.sendChannelTyping(this.message.channel.id); this.ipc.broadcast("soundreload"); this.ipc.register("soundReloadSuccess", (msg) => { this.ipc.unregister("soundReloadSuccess"); diff --git a/utils/pagination/awaitinteractions.js b/utils/pagination/awaitinteractions.js index 1aa7e85..ee55224 100644 --- a/utils/pagination/awaitinteractions.js +++ b/utils/pagination/awaitinteractions.js @@ -10,7 +10,7 @@ class InteractionCollector extends EventEmitter { this.bot = client; this.listener = async (packet) => { if (packet.t !== "INTERACTION_CREATE") return; - await this.verify(packet.d.message, packet.d.data.custom_id, packet.d.id, packet.d.token, packet.d.member); + await this.verify(packet.d.message, packet.d.data.custom_id, packet.d.id, packet.d.token, packet.d.member ? packet.d.member.id : packet.d.user.id); }; this.bot.on("rawWS", this.listener); if (options.time) setTimeout(() => this.stop("time"), options.time); diff --git a/utils/pagination/pagination.js b/utils/pagination/pagination.js index d7f2c8a..448ea58 100644 --- a/utils/pagination/pagination.js +++ b/utils/pagination/pagination.js @@ -74,7 +74,7 @@ module.exports = async (client, message, pages, timeout = 120000) => { if (pages.length > 1) { const interactionCollector = new InteractionCollector(client, currentPage, { time: timeout }); interactionCollector.on("interaction", async (msg, interaction, id, token, member) => { - if (member.user.id === message.author.id) { + if (member === message.author.id) { switch (interaction) { case "back": await fetch(`https://discord.com/api/v8/interactions/${id}/${token}/callback`, ackOptions);