Skip to content

Commit

Permalink
Attempting to fix the double @ announcement bug yet again
Browse files Browse the repository at this point in the history
  • Loading branch information
NovaFox161 committed Dec 10, 2024
1 parent 1526096 commit b6bec26
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ data class Announcement(
val channelId: Snowflake,


val subscribers: Subscribers = Subscribers(),
val subscribers: Subscribers = Subscribers(guildId = guildId),
val eventId: String? = null,
val eventColor: EventColor = EventColor.NONE,

Expand All @@ -41,6 +41,7 @@ data class Announcement(
subscribers = Subscribers(
roles = data.subscribersRole.asStringListFromDatabase().toSet(),
users = data.subscribersUser.asStringListFromDatabase().map(Snowflake::of).toSet(),
guildId = data.guildId.asSnowflake(),
),
eventId = if (data.eventId.isBlank() || data.eventId.equals("N/a", ignoreCase = true)) null else data.eventId,
eventColor = EventColor.fromNameOrHexOrId(data.eventColor),
Expand All @@ -62,14 +63,15 @@ data class Announcement(
data class Subscribers(
val roles: Set<String> = setOf(),
val users: Set<Snowflake> = setOf(),
val guildId: Snowflake,
) {
fun buildMentions(): String {
if (users.isEmpty() && roles.isEmpty()) return ""

val userMentions = users.map { "<@${it.asLong()}> " }

val roleMentions = roles.map {
if (it.equals("everyone", true)) "@everyone "
if (it.equals("everyone", true)) "<@&${guildId.asString()}> "
else if (it.equals("here", true)) "@here "
else "<@&$it> "
}
Expand Down

0 comments on commit b6bec26

Please sign in to comment.