reset convo

This commit is contained in:
Skye 2023-03-10 23:57:41 +09:00
parent 7d928a549a
commit 4dbe5e1f4d
Signed by: me
GPG key ID: 0104BC05F41B77B8

View file

@ -35,10 +35,13 @@ client.on("ready", () => {
console.log(`Logged in as ${client.user?.tag}!`); console.log(`Logged in as ${client.user?.tag}!`);
}); });
let resetTime = 0;
client.on("messageCreate", async (message) => { client.on("messageCreate", async (message) => {
if (message.channelId != process.env.CHANNEL) return; if (message.channelId != process.env.CHANNEL) return;
if (message.webhookId) return; if (message.webhookId) return;
if (message.author.bot) return; if (message.author.bot) return;
if (message.content == "\\reset") resetTime = Date.now();
if (message.content.startsWith("\\")) return; if (message.content.startsWith("\\")) return;
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);
@ -59,7 +62,7 @@ client.on("messageCreate", async (message) => {
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: Math.max(Date.now() - 5 * 60 * 1000, resetTime),
}).toString(), }).toString(),
before: SnowflakeUtil.generate({ before: SnowflakeUtil.generate({
timestamp: recieved + 500, timestamp: recieved + 500,