This commit is contained in:
Skye 2023-03-10 22:11:49 +09:00
parent 9b2b141af6
commit b572ed3111
Signed by: me
GPG key ID: 0104BC05F41B77B8

View file

@ -43,6 +43,7 @@ client.on("messageCreate", async (message) => {
if (message.channel.type != ChannelType.GuildText) return; if (message.channel.type != ChannelType.GuildText) return;
if (message.content == "die") process.exit(1); if (message.content == "die") process.exit(1);
// "adapted" from https://github.com/ryanccn/blahaj/blob/main/src/chat.ts // "adapted" from https://github.com/ryanccn/blahaj/blob/main/src/chat.ts
await message.channel.sendTyping(); await message.channel.sendTyping();
@ -51,11 +52,18 @@ client.on("messageCreate", async (message) => {
message.channel.sendTyping(); message.channel.sendTyping();
}, 5000); }, 5000);
const recieved = Date.now();
await new Promise<void>((resolve) => setTimeout(() => resolve(), 1500));
try { try {
const msgs = await message.channel.messages.fetch({ const msgs = await message.channel.messages.fetch({
after: SnowflakeUtil.generate({ after: SnowflakeUtil.generate({
timestamp: Date.now() - 5 * 60 * 1000, timestamp: Date.now() - 5 * 60 * 1000,
}).toString(), }).toString(),
before: SnowflakeUtil.generate({
timestamp: recieved + 500,
}).toString(),
}); });
const context = [ const context = [
@ -94,10 +102,17 @@ client.on("messageCreate", async (message) => {
.then(({ data }) => !data.results[0].flagged); .then(({ data }) => !data.results[0].flagged);
if (isAppropriate) { if (isAppropriate) {
await message.channel.send({ try {
content: responseMessage.content, await message.reply({
allowedMentions: { parse: ["users"] }, content: responseMessage.content,
}); allowedMentions: { parse: ["users"] },
});
} catch {
await message.channel.send({
content: responseMessage.content,
allowedMentions: { parse: ["users"] },
});
}
} else { } else {
await message.channel.send({ await message.channel.send({
embeds: [ embeds: [