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