@@ -47,6 +47,7 @@ class MarryExecutor : FoxyCommandExecutor() {
47
47
}
48
48
49
49
val userData = context.db.utils.user.getDiscordUser(user.id)
50
+ val authorData = context.getAuthorData()
50
51
51
52
if (userData.marryStatus.marriedWith != null ) {
52
53
context.reply(true ) {
@@ -69,13 +70,71 @@ class MarryExecutor : FoxyCommandExecutor() {
69
70
70
71
return
71
72
}
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
+
72
124
val marriedDate = ZonedDateTime .now(ZoneId .systemDefault()).toInstant()
73
125
74
126
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
+ }
79
138
80
139
actionRow(
81
140
context.foxy.interactionManager.createButtonForUser(
@@ -88,15 +147,17 @@ class MarryExecutor : FoxyCommandExecutor() {
88
147
context.event.user.id,
89
148
mapOf (
90
149
" marryStatus.marriedWith" to user.id,
91
- " marryStatus.marriedDate" to marriedDate
150
+ " marryStatus.marriedDate" to marriedDate,
151
+ " userCakes.balance" to authorData.userCakes.balance - 6000
92
152
)
93
153
)
94
154
95
155
context.db.utils.user.updateUser(
96
156
user.id,
97
157
mapOf (
98
158
" 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
100
161
)
101
162
)
102
163
0 commit comments