Skip to content

Commit 8608e25

Browse files
committed
Fixed discord delete logic
1 parent cfa2e3f commit 8608e25

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

common/src/main/kotlin/com/lambda/command/commands/DiscordCommand.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ import com.lambda.brigadier.execute
2424
import com.lambda.brigadier.required
2525
import com.lambda.command.LambdaCommand
2626
import com.lambda.module.modules.client.Discord.partyCreate
27+
import com.lambda.module.modules.client.Discord.partyDelete
2728
import com.lambda.module.modules.client.Discord.partyJoin
2829
import com.lambda.module.modules.client.Discord.partyLeave
2930
import com.lambda.module.modules.client.Discord.rpc
31+
import com.lambda.network.api.v1.endpoints.deleteParty
3032
import com.lambda.network.api.v1.endpoints.leaveParty
3133
import com.lambda.threading.runConcurrent
3234
import com.lambda.threading.runSafe
@@ -52,7 +54,7 @@ object DiscordCommand : LambdaCommand(
5254

5355
required(literal("delete")) {
5456
execute {
55-
runSafe { partyCreate() }
57+
runSafe { partyDelete() }
5658
}
5759
}
5860

common/src/main/kotlin/com/lambda/module/modules/client/Discord.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,20 @@ object Discord : Module(
140140
currentParty = null
141141
}
142142

143+
/**
144+
* Deletes the current party
145+
*/
146+
fun SafeContext.partyDelete() {
147+
if (!isDiscordLinked) return warn("You did not link your discord account")
148+
if (!player.isInParty) return warn("You are not in a party")
149+
150+
val (_, error) = deleteParty()
151+
if (error != null) return warn("Failed to delete the party: ${error.errorData}")
152+
153+
currentParty = null
154+
155+
}
156+
143157
private suspend fun start() {
144158
if (rpc.connected) return
145159

0 commit comments

Comments
 (0)