Skip to content

Commit 6ab58bc

Browse files
committed
Add a tax of 6000 Cakes for marriages
1 parent 2ae4b03 commit 6ab58bc

File tree

1 file changed

+67
-6
lines changed

1 file changed

+67
-6
lines changed

foxy/src/main/kotlin/net/cakeyfox/foxy/command/vanilla/social/MarryExecutor.kt

+67-6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class MarryExecutor : FoxyCommandExecutor() {
4747
}
4848

4949
val userData = context.db.utils.user.getDiscordUser(user.id)
50+
val authorData = context.getAuthorData()
5051

5152
if (userData.marryStatus.marriedWith != null) {
5253
context.reply(true) {
@@ -69,13 +70,71 @@ class MarryExecutor : FoxyCommandExecutor() {
6970

7071
return
7172
}
73+
74+
val isUserPremium =
75+
if (userData.userPremium.premiumDate != null) {
76+
userData.userPremium.premiumDate!!.epochSeconds > System.currentTimeMillis() / 1000
77+
} else false
78+
79+
val isAuthorPremium =
80+
if (authorData.userPremium.premiumDate != null) {
81+
authorData.userPremium.premiumDate!!.epochSeconds > System.currentTimeMillis() / 1000
82+
} else false
83+
84+
if (isUserPremium || isAuthorPremium) {
85+
buildMarryMessage(context)
86+
} else {
87+
if (context.getAuthorData().userCakes.balance < 6000) {
88+
context.reply(true) {
89+
content = pretty(
90+
FoxyEmotes.FoxyCry,
91+
context.locale["marry.authorHasNoCakes"]
92+
)
93+
}
94+
95+
return
96+
97+
} else if (userData.userCakes.balance < 6000) {
98+
context.reply {
99+
content = pretty(
100+
FoxyEmotes.FoxyCry,
101+
context.locale["marry.userHasNoCakes", user.asMention]
102+
)
103+
}
104+
105+
return
106+
} else buildMarryMessage(context)
107+
}
108+
}
109+
110+
private suspend fun buildMarryMessage(context: FoxyInteractionContext) {
111+
val user = context.getOption<User>("user")!!
112+
val userData = context.db.utils.user.getDiscordUser(user.id)
113+
val authorData = context.getAuthorData()
114+
val isUserPremium =
115+
if (userData.userPremium.premiumDate != null) {
116+
userData.userPremium.premiumDate!!.epochSeconds > System.currentTimeMillis() / 1000
117+
} else false
118+
119+
val isAuthorPremium =
120+
if (authorData.userPremium.premiumDate != null) {
121+
authorData.userPremium.premiumDate!!.epochSeconds > System.currentTimeMillis() / 1000
122+
} else false
123+
72124
val marriedDate = ZonedDateTime.now(ZoneId.systemDefault()).toInstant()
73125

74126
context.reply {
75-
content = pretty(
76-
FoxyEmotes.Ring,
77-
context.locale["marry.proposal", user.asMention, context.user.asMention]
78-
)
127+
content = if (isUserPremium || isAuthorPremium) {
128+
pretty(
129+
FoxyEmotes.Ring,
130+
context.locale["marry.premiumProposal", user.asMention, context.user.asMention]
131+
)
132+
} else {
133+
pretty(
134+
FoxyEmotes.Ring,
135+
context.locale["marry.proposal", user.asMention, context.user.asMention]
136+
)
137+
}
79138

80139
actionRow(
81140
context.foxy.interactionManager.createButtonForUser(
@@ -88,15 +147,17 @@ class MarryExecutor : FoxyCommandExecutor() {
88147
context.event.user.id,
89148
mapOf(
90149
"marryStatus.marriedWith" to user.id,
91-
"marryStatus.marriedDate" to marriedDate
150+
"marryStatus.marriedDate" to marriedDate,
151+
"userCakes.balance" to authorData.userCakes.balance - 6000
92152
)
93153
)
94154

95155
context.db.utils.user.updateUser(
96156
user.id,
97157
mapOf(
98158
"marryStatus.marriedWith" to context.event.user.id,
99-
"marryStatus.marriedDate" to marriedDate
159+
"marryStatus.marriedDate" to marriedDate,
160+
"userCakes.balance" to userData.userCakes.balance - 6000
100161
)
101162
)
102163

0 commit comments

Comments
 (0)