Skip to content

Commit

Permalink
Update Cozy for the merge
Browse files Browse the repository at this point in the history
  • Loading branch information
gdude2002 committed May 9, 2023
1 parent f0bd8dd commit b8cc752
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 258 deletions.
10 changes: 6 additions & 4 deletions src/main/kotlin/org/quiltmc/community/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,17 @@ suspend fun setupQuilt() = ExtensibleBot(DISCORD_TOKEN) {
}

rolesync {
roleToSync(
roleToSync( // Devs: Community -> Toolchain
COMMUNITY_DEVELOPER_ROLE,
TOOLCHAIN_DEVELOPER_ROLE,
COMMUNITY_DEVELOPER_ROLE
)
roleToSync(

roleToSync( // Collabs: Collab -> Toolchain
COLLAB_VERIFIED_ROLE,
TOOLCHAIN_COLLAB_ROLE
)
roleToSync(

roleToSync( // Collabs: Collab -> Community
COLLAB_VERIFIED_ROLE,
COMMUNITY_COLLAB_ROLE
)
Expand Down
40 changes: 0 additions & 40 deletions src/main/kotlin/org/quiltmc/community/_Checks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,46 +80,6 @@ suspend fun CheckContext<*>.notInCommunity() {
}
}

suspend fun CheckContext<*>.inToolchain() {
anyGuild()

if (!passed) {
return
}

val logger = KotlinLogging.logger("org.quiltmc.community.inToolchain")

val collection = getKoin().get<ServerSettingsCollection>()
val settings = collection.getToolchain()

if (settings == null) {
logger.failed("Toolchain server hasn't been configured yet.")
fail("Toolchain server hasn't been configured yet.")
} else {
inGuild(settings._id)
}
}

suspend fun CheckContext<*>.notInToolchain() {
anyGuild()

if (!passed) {
return
}

val logger = KotlinLogging.logger("org.quiltmc.community.notInToolchain")

val collection = getKoin().get<ServerSettingsCollection>()
val settings = collection.getToolchain()

if (settings == null) {
logger.passed("Toolchain server hasn't been configured yet.")
pass()
} else {
notInGuild(settings._id)
}
}

suspend fun CheckContext<*>.inCollab() {
anyGuild()

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/quiltmc/community/_Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ internal val TOOLCHAIN_GUILD = Snowflake(
)

internal val COLLAB_GUILD = Snowflake(
envOrNull("TOOLCHAIN_GUILD_ID")?.toLong()
envOrNull("COLLAB_GUILD_ID")?.toLong()
?: 905216141650198530
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ class ServerSettingsCollection : KordExKoinComponent {
suspend fun getCommunity() =
col.findOne(ServerSettings::quiltServerType eq QuiltServerType.COMMUNITY)

suspend fun getToolchain() =
col.findOne(ServerSettings::quiltServerType eq QuiltServerType.TOOLCHAIN)

suspend fun getCollab() =
col.findOne(ServerSettings::quiltServerType eq QuiltServerType.COLLAB)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ data class GlobalSettings(

val quiltGuilds: MutableSet<Snowflake> = mutableSetOf(
Snowflake(817576132726620200U), // Community
Snowflake(833872081585700874U), // Toolchain
// Snowflake(833872081585700874U), // Toolchain
),

var suggestionChannel: Snowflake? = Snowflake(832353359074689084U),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import dev.kord.core.entity.Member
import dev.kord.core.entity.Role
import dev.kord.rest.builder.message.create.allowedMentions
import org.koin.core.component.inject
import org.quiltmc.community.TOOLCHAIN_GUILD
import org.quiltmc.community.database.collections.TeamCollection
import org.quiltmc.community.database.entities.Team

Expand All @@ -36,8 +35,6 @@ class SubteamsExtension : Extension() {

allowInDms = false

guild(TOOLCHAIN_GUILD)

publicSubCommand(::TeamArguments) {
name = "add"
description = "Add someone to your team or any subteam"
Expand Down Expand Up @@ -99,8 +96,6 @@ class SubteamsExtension : Extension() {

allowInDms = false

guild(TOOLCHAIN_GUILD)

check { hasPermission(Permission.Administrator) }

ephemeralSubCommand(::ManageTeamAllowArguments) {
Expand Down Expand Up @@ -155,40 +150,30 @@ class SubteamsExtension : Extension() {
val role by role {
name = "team"
description = "Which team to add"

requiredGuild = { TOOLCHAIN_GUILD }
}

val targetUser by member {
name = "user"
description = "Who to add to the team"

requiredGuild = { TOOLCHAIN_GUILD }
}
}

inner class ManageTeamAllowArguments : Arguments() {
val superior by role {
name = "superior"
description = "The superior role"

requiredGuild = { TOOLCHAIN_GUILD }
}

val inferior by role {
name = "inferior"
description = "The inferior role"

requiredGuild = { TOOLCHAIN_GUILD }
}
}

inner class ManageTeamDisallowArguments : Arguments() {
val role by role {
name = "role"
description = "Role to disallow managing for"

requiredGuild = { TOOLCHAIN_GUILD }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import dev.kord.core.behavior.channel.*
import dev.kord.core.behavior.channel.threads.edit
import dev.kord.core.behavior.edit
import dev.kord.core.entity.Guild
import dev.kord.core.entity.channel.ForumChannel
import dev.kord.core.entity.channel.GuildMessageChannel
import dev.kord.core.entity.channel.TextChannel
import dev.kord.core.entity.channel.thread.ThreadChannel
Expand Down Expand Up @@ -220,32 +221,52 @@ class UtilityExtension : Extension() {

// Work around a Discord API race condition - yes, really!
// Specifically: "Cannot message this thread until after the post author has sent an initial message."
delay(1.seconds)
delay(2.seconds)

val parentForum = event.channel.parent.asChannelOfOrNull<ForumChannel>()

val message = event.channel.createMessage {
content = "Oh hey, that's a nice thread you've got there! Let me just get the mods in on this " +
"sweet discussion..."
content = "One moment - let me get the team in..."
}

event.channel.withTyping {
delay(2.seconds)
delay(1.seconds)
}

message.edit {
content = "Hey, ${role.mention}, you've gotta check this thread out!"
}
if (parentForum != null) {
message.edit {
content = if (parentForum.categoryId == COMMUNITY_DEVELOPER_CATEGORY) {
"Hey, ${role.mention} and <@&$COMMUNITY_DEVELOPER_ROLE>, you've gotta check this " +
"post out!"
} else {
"Hey, ${role.mention}, you've gotta check this post out!"
}
}

event.channel.withTyping {
delay(2.seconds)
}
event.channel.getFirstMessage()?.pin("First message in the forum post.")

message.edit {
content = "Welcome to your new thread, ${owner.mention}! This message is at the " +
"start of the thread. Remember, you're welcome to use the `/thread` commands to manage " +
"your thread as needed."
}
event.channel.withTyping {
delay(1.seconds)
}

message.delete()
} else {
message.edit {
content = "Hey, ${role.mention}, you've gotta check this thread out!"
}

event.channel.withTyping {
delay(1.seconds)
}

message.edit {
content = "Welcome to your new thread, ${owner.mention}! This message is at the " +
"start of the thread. Remember, you're welcome to use the `/thread` commands to manage " +
"your thread as needed."
}

message.pin("First message in the thread.")
message.pin("First message in the thread.")
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private val LINK_REGEX = "<a href=\"(?<url>[^\"]+)\"[^>]*>(?<text>[^<]+)</a>".to
private val CHANNELS: List<Snowflake> = listOf(
// Snowflake(828218532671389736L), // Testing
Snowflake(838805249271267398L), // Community
Snowflake(834195264629243904L), // Toolchain
// Snowflake(834195264629243904L), // Toolchain
)

class MinecraftExtension : Extension() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class SettingsExtension : Extension() {
name = "github-log-channel"
description = "Set or get the channel used for logging GitHub command actions"

check { inToolchain() }
check { inQuiltGuild() }

action {
val settings = globalSettings.get()!!
Expand Down
11 changes: 1 addition & 10 deletions yaml-files/welcome-community.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@
We hope you enjoy your time with us!
- title: Quilt Development

thumbnail:
url: https://raw.githubusercontent.com/QuiltMC/art/master/brand/1024png/quilt_toolchain_logo_dark.png

description: >
If you're interested in seeing how Quilt is developed, or helping us by contributing to Quilt yourself, then
please feel free to join [the Toolchain Discord server](https://discord.gg/afZYcQpbwv)!
- type: text
text: https://cdn.discordapp.com/attachments/863707104903561216/964999315233857557/community-rules.png

Expand Down Expand Up @@ -182,4 +173,4 @@
QuiltMC Forum: https://forum.quiltmc.org
QuiltMC on GitHub: https://github.com/QuiltMC
QuiltMC Website: https://quiltmc.org/
Toolchain Server: https://discord.gg/afZYcQpbwv
Toolchain Server (defunct): https://discord.gg/afZYcQpbwv
Loading

0 comments on commit b8cc752

Please sign in to comment.