2021-08-19 00:49:06 +03:00
|
|
|
import { GuildChannel, Message, TextChannel, ThreadChannel } from "discord.js";
|
|
|
|
import { Queue } from "../Queue";
|
|
|
|
import { sleep } from "../utils";
|
|
|
|
|
|
|
|
const queue = new Queue();
|
2021-08-19 01:02:59 +03:00
|
|
|
let n = 0;
|
2021-08-19 00:49:06 +03:00
|
|
|
|
|
|
|
export function hotfixMessageFetch(channel: TextChannel | ThreadChannel, messageId: string): Promise<Message> {
|
2021-08-19 01:02:59 +03:00
|
|
|
const thisN = ++n;
|
|
|
|
|
|
|
|
// tslint:disable-next-line:no-console
|
2021-08-19 01:04:41 +03:00
|
|
|
console.trace(
|
|
|
|
`[${thisN}] Queueing to fetch message id ${messageId} from channel ${channel.id} (queue size: ${queue.length})`,
|
|
|
|
);
|
2021-08-19 00:49:06 +03:00
|
|
|
return queue.add(async () => {
|
|
|
|
await sleep(3000);
|
2021-08-19 00:59:28 +03:00
|
|
|
// tslint:disable-next-line:no-console
|
2021-08-19 01:04:41 +03:00
|
|
|
console.log(`[${thisN}] Fetching message id ${messageId} from channel ${channel.id}`);
|
2021-08-19 00:49:06 +03:00
|
|
|
return channel.messages.fetch(messageId);
|
|
|
|
});
|
|
|
|
}
|