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.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) {
|
||||||
|
try {
|
||||||
|
await message.reply({
|
||||||
|
content: responseMessage.content,
|
||||||
|
allowedMentions: { parse: ["users"] },
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
await message.channel.send({
|
await message.channel.send({
|
||||||
content: responseMessage.content,
|
content: responseMessage.content,
|
||||||
allowedMentions: { parse: ["users"] },
|
allowedMentions: { parse: ["users"] },
|
||||||
});
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
await message.channel.send({
|
await message.channel.send({
|
||||||
embeds: [
|
embeds: [
|
||||||
|
|
Loading…
Reference in a new issue