Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647import { Events, type Message } from "discord.js";
import type { FeatureContext } from "@/features/context";import type { FeatureDefinition } from "@/features/definition";
type Transform = { from: string; to: string;};
function transform(content: string, transforms: Transform[]) { return transforms.reduce((acc, t) => acc.replaceAll(t.from, t.to), content);}
async function react(ctx: FeatureContext, ev: Message) { const content = ev.cleanContent;
ctx.cfg.react.reactions.forEach((r) => { const transformed = transform(content, r.transform);
r.match.forEach((m) => { if (transformed.search(m.regex) !== -1) { ctx.logger.info( { feature: "react", message: ev.id, name: r.name, }, "Reacted!", );
ev.react(r.reactionId); } }); });}
/*Responds with a given emoji, if a message matches some pattern.*/export const feature = { name: "react", events: { [Events.MessageCreate]: react, },} satisfies FeatureDefinition;