Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keep track of 🟥 #173

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,13 @@ model TempRole {

@@unique([userId, roleId])
}

model RedFlag {
id String @id @default(uuid())
actorId String
flaggedUserId String
flaggedChannelId String
flaggedMessageId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
1 change: 1 addition & 0 deletions src/Bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class Bot {
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
IntentsBitField.Flags.GuildMessageReactions,
],
})
private readonly runtimeConfiguration = new RuntimeConfiguration()
Expand Down
2 changes: 2 additions & 0 deletions src/features/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import nominations from './nominations'
import ping from './ping'
import preventEmojiSpam from './preventEmojiSpam'
import profileInspector from './profileInspector'
import redFlagLogger from './redFlagLogger'
import runtimeConfig from './runtimeConfig'
import slowmode from './slowmode'
import stickyMessage from './stickyMessage'
Expand All @@ -24,6 +25,7 @@ export default [
ping,
preventEmojiSpam,
profileInspector,
redFlagLogger,
runtimeConfig,
slowmode,
stickyMessage,
Expand Down
33 changes: 33 additions & 0 deletions src/features/redFlagLogger/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Events } from 'discord.js'

import { prisma } from '@/prisma'
import { definePlugin } from '@/types/definePlugin'

export default definePlugin({
name: 'redFlagLogger',
setup: (pluginContext) => {
pluginContext.addEventHandler({
eventName: Events.MessageReactionAdd,
once: false,
execute: async (botContext, reaction, user) => {
const redFlagEmojiIdentifier = '%F0%9F%9F%A5' // 🟥
if (reaction.emoji.identifier !== redFlagEmojiIdentifier) return
const author = reaction.message.author
if (!author) return
const channel = reaction.message.channel
if (!channel) return
botContext.log.info(
`actor=${user.id} message=${reaction.message.id} messageAuthor=${author.id}`,
)
await prisma.redFlag.create({
data: {
actorId: user.id,
flaggedChannelId: reaction.message.channel.id,
flaggedMessageId: reaction.message.id,
flaggedUserId: author.id,
},
})
},
})
},
})