better
This commit is contained in:
parent
9b2b141af6
commit
b572ed3111
1 changed files with 19 additions and 4 deletions
15
index.ts
15
index.ts
|
@ -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) {
|
||||
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: [
|
||||
|
|
Loading…
Reference in a new issue