koishi-plugin-monetary-admin 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +12 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -56,7 +56,12 @@ function apply(ctx) {
|
|
|
56
56
|
return '请输入金额。';
|
|
57
57
|
if (amount <= 0)
|
|
58
58
|
return '金额必须为正数。';
|
|
59
|
-
|
|
59
|
+
// 直接使用数据库 upsert,避免 monetary.gain() 的 bug
|
|
60
|
+
await ctx.database.upsert('monetary', (row) => [{
|
|
61
|
+
uid,
|
|
62
|
+
currency,
|
|
63
|
+
value: koishi_1.$.add(row.value, amount),
|
|
64
|
+
}], ['uid', 'currency']);
|
|
60
65
|
return `成功给用户 ${name} (UID: ${uid}) 添加了 ${amount} ${currency}。`;
|
|
61
66
|
}
|
|
62
67
|
catch (e) {
|
|
@@ -86,7 +91,12 @@ function apply(ctx) {
|
|
|
86
91
|
return '请输入金额。';
|
|
87
92
|
if (amount <= 0)
|
|
88
93
|
return '金额必须为正数。';
|
|
89
|
-
|
|
94
|
+
// 直接使用数据库 upsert,避免 monetary.gain() 的 bug
|
|
95
|
+
await ctx.database.upsert('monetary', (row) => [{
|
|
96
|
+
uid,
|
|
97
|
+
currency,
|
|
98
|
+
value: koishi_1.$.sub(row.value, amount),
|
|
99
|
+
}], ['uid', 'currency']);
|
|
90
100
|
return `成功从用户 ${name} (UID: ${uid}) 扣除了 ${amount} ${currency}。`;
|
|
91
101
|
}
|
|
92
102
|
catch (e) {
|