Skip to content

Commit

Permalink
feat: scuffed reaction-based removal of note views
Browse files Browse the repository at this point in the history
  • Loading branch information
mazziechai committed Dec 24, 2024
1 parent 502caab commit 5216db8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ package cafe.ferret.kosekata.extensions

import cafe.ferret.kosekata.database.collections.NoteCollection
import cafe.ferret.kosekata.i18n.Translations
import dev.kord.common.entity.Permission
import dev.kord.core.behavior.edit
import dev.kord.core.event.message.ReactionAddEvent
import dev.kordex.core.checks.anyGuild
import dev.kordex.core.commands.Arguments
import dev.kordex.core.commands.converters.impl.string
import dev.kordex.core.extensions.Extension
import dev.kordex.core.extensions.chatCommand
import dev.kordex.core.extensions.event
import dev.kordex.core.utils.hasPermission
import dev.kordex.core.utils.respond
import org.koin.core.component.inject

Expand Down Expand Up @@ -55,6 +60,33 @@ class ChatCommandsExtension : Extension() {
}
}
}

event<ReactionAddEvent> {
check {
val interaction = event.getMessage().interaction
failIf(event.guild == null)
failIf(event.messageAuthorId != bot.kordRef.selfId)
failIf(event.emoji.name != "")
if (interaction == null) {
failIf(
event.userId != event.getMessage().referencedMessage?.author?.id || event.getUserAsMember()
?.hasPermission(Permission.ManageMessages) == false
)
} else {
failIfNot(interaction.name in listOf("post", "peek", "postid", "peekid"))
failIf(
event.userId != interaction.user.id || event.getUserAsMember()
?.hasPermission(Permission.ManageMessages) == false
)
}
}

action {
event.message.edit {
content = "<removed>"
}
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/translations/kose/strings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ extensions.info.ids.description=List the IDs of notes under a name

### Modals
modals.createnote.title=Create note
modals.editnote.title
modals.editnote.title=Edit note
modals.notename=Name of the note
modals.content=Content of the note
modals.deletemultiple.title=Delete multiple notes
Expand Down

0 comments on commit 5216db8

Please sign in to comment.