From 6c0f6fcb8b8eb550450873be365351fcb8e7d78e Mon Sep 17 00:00:00 2001 From: Ryan Cao <70191398+ryanccn@users.noreply.github.com> Date: Thu, 25 Aug 2022 20:42:37 +0800 Subject: [PATCH] add `deferReply` to long-duration commands --- src/commands/members.ts | 4 +++- src/commands/stars.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/commands/members.ts b/src/commands/members.ts index 7c02c3e..11d730e 100644 --- a/src/commands/members.ts +++ b/src/commands/members.ts @@ -3,10 +3,12 @@ import type { CacheType, CommandInteraction } from 'discord.js'; import { COLORS } from '../constants'; export const membersCommand = async (i: CommandInteraction) => { + await i.deferReply(); + const memes = await i.guild?.members.fetch().then((r) => r.toJSON()); if (!memes) return; - await i.reply({ + await i.editReply({ embeds: [ { title: `${memes.length} total members!`, diff --git a/src/commands/stars.ts b/src/commands/stars.ts index e6c5a47..753e3c8 100644 --- a/src/commands/stars.ts +++ b/src/commands/stars.ts @@ -2,11 +2,13 @@ import type { CacheType, CommandInteraction } from 'discord.js'; import { COLORS } from '../constants'; export const starsCommand = async (i: CommandInteraction) => { + await i.deferReply(); + const count = await fetch('https://api.github.com/repos/PolyMC/PolyMC') .then((r) => r.json() as Promise<{ stargazers_count: number }>) .then((j) => j.stargazers_count); - await i.reply({ + await i.editReply({ embeds: [ { title: `⭐ ${count} total stars!`,