Skip to content

Commit

Permalink
Prevent quoting the quote message
Browse files Browse the repository at this point in the history
  • Loading branch information
twobiers committed Dec 14, 2024
1 parent 023b68d commit 06998b1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/handler/quoteHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import type { BotContext, QuoteConfig } from "@/context.js";
import type { ReactionHandler } from "./ReactionHandler.js";
import log from "@log";

const quoteMessage = "Ihr quoted echt jeden Scheiß, oder?";

const isChannelAnonymous = async (context: BotContext, channel: Channel) => {
const anonChannels = context.commandConfig.quote.anonymousChannelIds;

Expand Down Expand Up @@ -78,6 +80,8 @@ const hasMessageEnoughQuotes = (
const isQuoterQuotingHimself = (quoter: GuildMember, messageAuthor: GuildMember) =>
quoter.id === messageAuthor.id;

const isQuoterQuotingQuoteMessage = (message: Message) => message.content === quoteMessage;

const generateRandomColor = () => Math.floor(Math.random() * 0xffffff);

const getTargetChannel = (
Expand Down Expand Up @@ -227,6 +231,14 @@ export default {
return;
}

if (
quotedMessage.author.id !== context.client.user.id &&
isQuoterQuotingQuoteMessage(quotedMessage)
) {
await event.users.remove(quoter);
return;
}

if (isQuoterQuotingHimself(quoter, quotedUser)) {
await context.textChannels.hauptchat.send({
embeds: [
Expand Down Expand Up @@ -304,7 +316,7 @@ export default {
quotedMessage.channel.isTextBased() &&
quotedMessage.channel.type === ChannelType.GuildText
) {
await quotedMessage.reply("Ihr quoted echt jeden Scheiß, oder?");
await quotedMessage.reply(quoteMessage);
}
},
} satisfies ReactionHandler;

0 comments on commit 06998b1

Please sign in to comment.