forked from cdevshop/tebex-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.js
215 lines (205 loc) · 5.49 KB
/
init.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
require("dotenv").config();
(async() => {
const { SlashCommandBuilder, REST, Routes } = require('discord.js');
const { BOT_ID, GUILD_ID } = require('./src/storage/config.json');
const commands = [
new SlashCommandBuilder().setName('coupon')
.setDescription("Manage webstore coupons")
.addSubcommand(subcmd =>
subcmd
.setName("list")
.setDescription('Replies with list of active coupons. Max 25 coupons'))
.addSubcommandGroup(subcmdgr =>
subcmdgr
.setName("create")
.setDescription('Create a coupon')
.addSubcommand(subcmd =>
subcmd
.setName('percentage')
.setDescription('Using % for discount, example 10% discount')
.addNumberOption(option =>
option
.setName('percent')
.setDescription('Example: 15% discount')
.setMinValue(1)
.setMaxValue(100)
.setRequired(true)
)
.addIntegerOption(option =>
option
.setName('uses')
.setDescription('Limit of uses, enter 0 for unlimited')
.setMinValue(0)
.setRequired(true)
)
.addNumberOption(option =>
option
.setName('minimum')
.setDescription('Minimum value of basket before the coupon can be redeemed, you can put 0 if you want to')
.setMinValue(0)
.setRequired(true)
)
)
.addSubcommand(subcmd =>
subcmd
.setName('fixed')
.setDescription('Using fixed price for discount, example $10 discount')
.addNumberOption(option =>
option
.setName('amount')
.setDescription('Example: $10 discount')
.setMinValue(1)
.setRequired(true)
)
.addIntegerOption(option =>
option
.setName('uses')
.setDescription('Limit of uses, enter 0 for unlimited')
.setMinValue(0)
.setRequired(true)
)
.addNumberOption(option =>
option
.setName('minimum')
.setDescription('Minimum value of basket before the coupon can be redeemed, you can put 0 if you want to')
.setMinValue(0)
.setRequired(true)
)
)
)
.addSubcommand(subcmd =>
subcmd
.setName("get")
.setDescription('Get a coupon information')
.addStringOption(option =>
option
.setName("id")
.setDescription("The coupon ID")
.setRequired(true)
)
)
.addSubcommand(subcmd =>
subcmd
.setName("delete")
.setDescription('Delete a coupon')
.addStringOption(option =>
option
.setName("id")
.setDescription("The coupon ID")
.setRequired(true)
)
),
new SlashCommandBuilder().setName('giftcard')
.setDescription("Manage webstore gift cards")
.addSubcommand(subcmd =>
subcmd
.setName("list")
.setDescription('Replies with list of gift cards')
.addStringOption(option =>
option
.setName('type')
.setDescription('Choose the gift cards status')
.setRequired(true)
.addChoices(
{ name: "Active Gift Cards", value: "active" },
{ name: "Void Gift Card", value: "void" }
)
)
)
.addSubcommand(subcmd =>
subcmd
.setName('create')
.setDescription('Create a gift card of a specified amount.')
.addStringOption(option =>
option
.setName('expires_at')
.setDescription('Gift card\'s expiry date in the format yyyy-mm-dd hh:mm:ss')
.setMinLength(1)
.setMaxLength(100)
.setRequired(true)
)
.addStringOption(option =>
option
.setName('note')
.setDescription('The note that will be stored against the gift card')
.setMinLength(1)
.setMaxLength(1024)
.setRequired(true)
)
.addNumberOption(option =>
option
.setName('amount')
.setDescription('The currency value of the gift card should have upon creation')
.setMinValue(1)
.setRequired(true)
)
)
.addSubcommand(subcmd =>
subcmd
.setName("get")
.setDescription('Retrieve a gift card by ID')
.addStringOption(option =>
option
.setName("id")
.setDescription("The ID of the gift card")
.setRequired(true)
)
)
.addSubcommand(subcmd =>
subcmd
.setName("topup")
.setDescription('Top-up (Add more credit) to an existing gift card')
.addStringOption(option =>
option
.setName("id")
.setDescription("The ID of the gift card")
.setRequired(true)
)
.addNumberOption(option =>
option
.setName('amount')
.setDescription('The currency value the gift card should have added to it')
.setRequired(true)
)
),
new SlashCommandBuilder().setName('payments')
.setDescription("Retrieve the latest payments (up to 25 per embed)")
.addIntegerOption(option =>
option
.setName('page')
.setDescription('The page number to return (optional)')
.setMinValue(1)
),
new SlashCommandBuilder().setName('listing')
.setDescription("Get the categories and packages"),
new SlashCommandBuilder().setName('lookup')
.setDescription("Lookup information")
.addSubcommand(subcmd =>
subcmd
.setName("player")
.setDescription('Returns player lookup information')
.addStringOption(option =>
option
.setName('player')
.setDescription('Player name / UUID')
.setRequired(true)
)
)
.addSubcommand(subcmd =>
subcmd
.setName("transaction")
.setDescription('Returns transaction lookup information')
.addStringOption(option =>
option
.setName('tid')
.setDescription('Transaction ID')
.setRequired(true)
)
)
]
.map(command => command.toJSON());
const rest = new REST({ version: '10' }).setToken(process.env.BOT_TOKEN);
rest.put(Routes.applicationGuildCommands(BOT_ID, GUILD_ID), { body: commands })
.then((data) => console.log(`Registered ${data.length} slash cmds.`))
.catch(console.error);
})();