Skip to content

Commit

Permalink
fix: clear history
Browse files Browse the repository at this point in the history
  • Loading branch information
Googlefan committed May 19, 2024
1 parent 47fc4cc commit ac853e5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/commands/clear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
SlashCommandBuilder,
} from "discord.js";
import { Command } from ".";
import { clearHistory } from "../queue";

export const clear: Command = {
builder: new SlashCommandBuilder()
Expand All @@ -13,6 +14,7 @@ export const clear: Command = {
execute: function (
i: ChatInputCommandInteraction<CacheType>,
): void | Promise<void> {
throw new Error("Function not implemented.");
clearHistory(i.channelId);
i.reply("Chat history cleared");
},
};
8 changes: 8 additions & 0 deletions src/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ function addHistory(channelId: string, chat: Chat) {
]);
}

export function clearHistory(channelId: string) {
channelSpecificHistory.set(channelId, []);
chatQueue.set(channelId, {
queue: [],
processing: false,
});
}

setInterval(() => {
for (const [channelId, { queue, processing }] of chatQueue) {
if (processing) continue;
Expand Down

0 comments on commit ac853e5

Please sign in to comment.