Repository navigation
Expand file tree
/
Copy pathindex.js
More file actions
4038 lines (3111 loc) · 110 KB
/
Copy pathindex.js
File metadata and controls
4038 lines (3111 loc) · 110 KB
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
require('dotenv').config();
const mongoose = require('mongoose');
const cooldowns = new Map();
const {Client, REST, Routes, Partials, SlashCommandBuilder, GatewayIntentBits, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, ModalBuilder, TextInputBuilder, TextInputStyle, AttachmentBuilder, AllowedMentionsTypes } = require('discord.js');
const cards = require('./data/cards');
const rarities = require('./data/rarities');
const User = require('./models/User');
let currentShopMessages = [];
let shopEndTime = null;
let countdownInterval = null;
let shopHeaderMessage = null;
const BOT_VERSION = "2.11";
const IMAGE_COMMIT = "367d596"; // replace with newest git log --oneline
const ALLOWED_CHANNELS = [
'1471357861526241350',
'1470496897721565419'
];
const CLIENT_ID = process.env.CLIENT_ID;
const GUILD_ID = process.env.GUILD_ID;
const SHOP_CHANNEL_ID = process.env.SHOP_CHANNEL_ID;
const OFFLINE_IMAGES = false;
const {DM_REPLIES,RARE_DM_REPLIES} = require("./replies/dmReplies");
const fs = require("fs");
const path = require("path");
const UNIQUE_UNLOCKS = require("./data/uniqueUnlocks");
const { checkUnlocks } = require("./helpers/unlocks");
//Game Constants
const MAX_BIBBLES_TOKENS = 20;
const DAILY_TOKEN_AMOUNT = 10;
const COINFLIP_BETS = [50, 100, 200];
const GRAVEROBBERY_BETS = [50, 100, 200];
const {startBlackjack, handleBlackjackButton} = require("./games/blackjackGame");
const BLACKJACK_BETS = [50, 100, 200];
const HIGHLOW_BETS = [25, 50, 100];
const {startHigherLower, handleHigherLowerButton} = require("./games/higherLowerGame");
const {startBoneDig, handleBoneDigButton} = require("./games/boneDigGame");
const BONEDIG_BETS = [100, 200, 500];
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.DirectMessages
],
partials: [
Partials.Channel
]
});
HEWWO MY NAME IS JEFF!!!;;;;!!!()(){}{}
async function clearShopChannel(channel) {
try {
const messages = await channel.messages.fetch({ limit: 100 });
if (messages.size > 0) {
await channel.bulkDelete(messages, true);
}
console.log("Shop channel cleared.");
} catch (err) {
console.error("Failed to clear shop channel:", err);
}
}
client.once('clientReady', async () => {
console.log(`Logged in as ${client.user.tag}`);
setInterval(sendDailyResetPings, 60 * 1000);
try {
const shopChannel = await client.channels.fetch(SHOP_CHANNEL_ID);
// 🔥 Clear entire channel first
await clearShopChannel(shopChannel);
// Post fresh shop
await postShop(shopChannel);
// Update!
await shopChannel.send(`Update ${BOT_VERSION} is live!`);
// Rotate every 60 minutes (30 for testing)
setInterval(async () => {
await postShop(shopChannel);
}, 30 * 60 * 1000);
} catch (err) {
console.error("Shop boot error:", err);
}
});
console.log("Attempting MongoDB connection...");
//mongoose.connect('mongodb://127.0.0.1:27017/bonebot')
mongoose.connect(process.env.MONGO_URI)
.then(() => console.log('Connected to MongoDB'))
.catch(err => console.error('Mongo Error:', err.message));
//client.login('token');
client.login(process.env.TOKEN);
async function getOrCreateUser(userId) {
let user = await User.findOne({ userId });
if (!user) {
user = new User({
userId,
bones: 500, // 👈 Starting bonus
inventory: [],
dailyStreak: 0,
cappedStreak: 0,
dailyLastClaim: null,
lastRefundAt: null
});
await user.save();
}
await applyDailyTokenGrant(user);
return user;
}
//Enable Slash Commands
const commands = [
new SlashCommandBuilder()
.setName('inventory')
.setDescription('View a card collection')
.addUserOption(option =>
option
.setName('user')
.setDescription('User to view')
.setRequired(false)
),
new SlashCommandBuilder()
.setName("achievements")
.setDescription("View Unique card achievement progress")
.addUserOption(option =>
option
.setName("user")
.setDescription("User to view")
.setRequired(false)
),
new SlashCommandBuilder()
.setName("help")
.setDescription("Learn how BoneBot works"),
new SlashCommandBuilder()
.setName("commands")
.setDescription("View BoneBot help and commands"),
new SlashCommandBuilder()
.setName("games")
.setDescription("Play Bones Games using tokens!"),
new SlashCommandBuilder()
.setName('pings')
.setDescription('Set your Shop Pings'),
new SlashCommandBuilder()
.setName('daily')
.setDescription('Claim your daily <:BBones:1518220991938170910> reward'),
new SlashCommandBuilder()
.setName("index")
.setDescription("Check your BoneBot card index")
.addIntegerOption(option =>
option
.setName("season")
.setDescription("Season to check")
.setRequired(true)
.addChoices(
{ name: "Season 1", value: 1 },
{ name: "Season 2", value: 2 }
)
)
.addUserOption(option =>
option
.setName("user")
.setDescription("Whose index to view")
.setRequired(false)
),
new SlashCommandBuilder()
.setName("leaderboard")
.setDescription("View BoneBot leaderboards")
.addStringOption(option =>
option
.setName("type")
.setDescription("Which leaderboard to view")
.setRequired(true)
.addChoices(
{ name: "Bones Spent", value: "spent" },
{ name: "All Time Balance", value: "earned" },
{ name: "Daily Streak", value: "daily" },
{ name: "High Low Streak", value: "highlow" }
)
),
new SlashCommandBuilder()
.setName('balance')
.setDescription('Check a Bone balance')
.addUserOption(option =>
option
.setName('user')
.setDescription('User to view')
.setRequired(false)
)
].map(command => command.toJSON());
const rest = new REST({ version: '10' }).setToken(process.env.TOKEN);
(async () => {
try {
console.log('Registering slash commands...');
await rest.put(
Routes.applicationGuildCommands(
CLIENT_ID, // CLIENT ID
GUILD_ID // SERVER/GUILD ID
),
{ body: commands }
);
console.log('Slash commands registered.');
} catch (error) {
console.error(error);
}
})();
function buildPingsMessage(user, viewerId) {
const pingEmbeds = [];
const files = [];
user.pingCards.forEach((cardId, index) => {
const slotNumber = index + 1;
const card = findCardById(cardId);
const embed = new EmbedBuilder()
.setColor(0x2B2D31)
.setTitle(`📡 Ping Slot ${slotNumber}`);
if (!card) {
embed.setDescription("Not Set");
} else {
embed.setDescription(
`**${card.name}**\n` +
`SN: \`${card.season}\`\n` +
`ID: \`${getCardId(card)}\``
);
if (OFFLINE_IMAGES) {
const fileName = `ping_${slotNumber}_${card.id}.png`;
const attachment = new AttachmentBuilder(getCardImagePath(card), {
name: fileName
});
if (isCardGif(card)) {
embed.setImage(`attachment://${fileName}`);
} else {
embed.setImage(`attachment://${fileName}`);
}
files.push(attachment);
} else {
if (isCardGif(card)) {
embed.setImage(getCardImageUrl(card));
} else {
embed.setImage(getCardImageUrl(card));
}
}
}
pingEmbeds.push(embed);
});
const setRow = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId(`pingslot_0_${viewerId}`)
.setLabel("Set Slot 1")
.setStyle(ButtonStyle.Secondary),
new ButtonBuilder()
.setCustomId(`pingslot_1_${viewerId}`)
.setLabel("Set Slot 2")
.setStyle(ButtonStyle.Secondary),
new ButtonBuilder()
.setCustomId(`pingslot_2_${viewerId}`)
.setLabel("Set Slot 3")
.setStyle(ButtonStyle.Secondary)
);
const clearRow = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId(`clearping_0_${viewerId}`)
.setLabel("Clear Slot 1")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`clearping_1_${viewerId}`)
.setLabel("Clear Slot 2")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`clearping_2_${viewerId}`)
.setLabel("Clear Slot 3")
.setStyle(ButtonStyle.Danger)
);
const dailyPingRow = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId(`daily_ping_toggle_${viewerId}`)
.setLabel(user.dailyPingEnabled ? "Daily Ping: ON" : "Daily Ping: OFF")
.setEmoji(user.dailyPingEnabled ? "🔔" : "🔕")
.setStyle(user.dailyPingEnabled ? ButtonStyle.Success : ButtonStyle.Secondary)
);
return {
embeds: pingEmbeds,
files,
components: [setRow, clearRow, dailyPingRow],
flags: 64
};
}
function getCardId(card) {
return Number(card.season) === 1 ? card.id : `${card.season}${card.id}`;
}
function getCardImageUrl(card) {
return `https://cdn.jsdelivr.net/gh/MrBibbles3/bonebot-test@${IMAGE_COMMIT}/images/S${card.season}/${getCardImageFileName(card)}?v=${BOT_VERSION}`;
}
function findCardById(cardId) {
if (!cardId) return null;
const wanted = cardId.toLowerCase();
const allCards = Object.values(cards).flat();
return allCards.find(card =>
getCardId(card).toLowerCase() === wanted ||
card.id.toLowerCase() === wanted
);
}
function getCardImagePath(card) {
return `./images/S${card.season}/${getCardImageFileName(card)}`;
}
function getCardImageUrl(card) {
return `https://cdn.jsdelivr.net/gh/MrBibbles3/bonebot-test@${IMAGE_COMMIT}/images/S${card.season}/${getCardImageFileName(card)}?v=${BOT_VERSION}`;
}
function getInventorySortData(itemId) {
const seasonMatch = itemId.match(/^(\d+)/);
const season = seasonMatch ? parseInt(seasonMatch[1]) : 1;
const numberMatch = itemId.match(/(\d+)$/);
const number = numberMatch ? parseInt(numberMatch[1]) : 0;
return { season, number };
}
function sortInventoryCards(a, b) {
const aData = getInventorySortData(a.itemId);
const bData = getInventorySortData(b.itemId);
if (aData.season !== bData.season) {
return aData.season - bData.season;
}
return aData.number - bData.number;
}
function buildHelpEmbed(section = "main") {
const embed = new EmbedBuilder()
.setColor(0xEFBF04)
.setTitle("📖 BoneBot Help");
if (section === "main") {
embed.setDescription(
`# 👋 Welcome to BoneBot!\n\n` +
`**@BoneBot** is a Discord bot programmed by **MrBibbles** himself! (aided by **KevTsuboi and testers)**\n\n` +
`BoneBot provides a shop where you can purchase cards for your collection! These cards feature **MrBibbles' Server characters (real users)** and **inside jokes** that have happened throughout the server's lifespan.\n\n` +
`Purchase cards in <#1471356398989480103> using **BONES** <:BBones:1518220991938170910>, which you earn by:\n` +
`• 💬 Chatting\n` +
`• 📅 Claiming your Daily Reward\n` +
`• 🎮 Playing Games\n\n` +
`━━━━━━━━━━━━━━━━━━\n\n` +
`### 🎴 Why collect cards?\n\n` +
`Collecting cards will reward you with **badges** and **roles** in a future update. For now, they're a fun collection game to enjoy with other members of the server!\n\n` +
`There's even more to do:\n` +
`• 👑 Unlock **Achievements**\n` +
`• 🎲 Play **Gambling Games**\n` +
`• 🏆 Compete on the **Leaderboards**\n\n` +
`*More complicated games and features will be added in future updates!*\n\n` +
`━━━━━━━━━━━━━━━━━━\n\n` +
`## 📖 Click a button below to learn more!\n\n` +
`**1️⃣** • How to get Bones\n\n` +
`**2️⃣** • How to buy Cards\n\n` +
`**3️⃣** • Commands List\n\n` +
`**4️⃣** • Why??`
);
}
if (section === "bones") {
embed
.setTitle("1️⃣ How to get Bones")
.setDescription(
`**Bones** <:BBones:1518220991938170910> are the main currency BoneBot runs on!\n\n` +
`You can earn Bones by:\n` +
`• 💬 Sending messages anywhere in the server *(30 second cooldown)*\n` +
`• 📅 Using **/daily** *(includes an infinite streak with bonus rewards up to 30!)*\n` +
`• 🎮 Playing games with **/games**\n\n` +
`━━━━━━━━━━━━━━━━━━\n\n` +
`### 💰 Useful Commands\n\n` +
`**/balance** - Check your Bones balance *(or someone else's!)*\n\n` +
`**/leaderboard** - View the Bones leaderboard\n\n` +
`Once you've earned enough Bones, spend them in:\n` +
`• 🛒 <#1471356398989480103> *(Bone Shop)*\n` +
`• 🎲 **/games** *(Gambling Games)*\n\n` +
`*Spend wisely... or don't. Gamba is always an option.*`
);
}
if (section === "cards") {
embed
.setTitle("2️⃣ How to buy Cards")
.setDescription(
`Purchase **Bone Cards** in the Bone Shop:\n` +
`🛒 <#1471356398989480103>\n\n` +
`The Bone Shop refreshes **every hour**, offering random cards from multiple rarities!\n\n` +
`Current chances include:\n` +
`• 🌙 Nightmare Cards - **50%**\n` +
`• 💠 Apex Cards - **10%**\n` +
`• ❓ ...and there may be one more card that can appear... *shhh* 😉\n\n` +
`━━━━━━━━━━━━━━━━━━\n\n` +
`### 🎴 Building Your Collection\n\n` +
`Each shop card lets you:\n` +
`• ✅ Check if you already own it\n` +
`• 🛒 Purchase **1** or **5** copies\n\n` +
`Use these commands to manage your collection:\n\n` +
`**/index** - View every card in the game *(yours or another player's!)*\n\n` +
`**/inventory** - Browse your card collection *(or someone else's!)*\n\n` +
`🏆 Completing the **Season 1** or **Season 2** Index unlocks special rewards!\n\n` +
`Track your progress anytime using **/achievements**.`
);
}
if (section === "commands") {
embed
.setTitle("3️⃣ Commands List")
.setDescription(
`BoneBot currently has **10 commands** available!\n\n` +
`🏆 **/achievements**\n` +
`View every achievement and your progress *(or another player's!)*\n\n` +
`💰 **/balance**\n` +
`Check your Bones balance *(or another player's!)*\n\n` +
`📖 **/commands** or **/help**\n` +
`Open this help menu.\n\n` +
`📅 **/daily**\n` +
`Claim your daily Bones! Your streak is **infinite**, but bonus rewards stop increasing after **30**.\n\n` +
`🎲 **/games**\n` +
`Play gambling games using your Bones!\n\n` +
`🎴 **/index**\n` +
`View your card index progress *(or another player's!)*\n\n` +
`📦 **/inventory**\n` +
`Browse your card collection *(or another player's!)*\n\n` +
`🏅 **/leaderboard**\n` +
`View multiple leaderboards.\n\n` +
`🔔 **/pings**\n` +
`Set DM notifications for cards you're chasing, and enable Daily Pings!\n\n` +
`*You must have DMs from server members enabled for this feature to work.*`
);
}
if (section === "why") {
embed
.setTitle("4️⃣ Why??")
.setDescription(
`# 🎲 BECAUSE IT IS FUN! AND GAMBA!\n\n` +
`I *(MrBibbles)* have spent months working on this project on and off to prove to myself that I could!\n\n` +
`I've always wanted a real-life card collecting game, and this is **my game**. ❤️\n\n` +
`More features will continue to be added whenever I have spare time, including more advanced web-based games.\n\n` +
`For now, I hope you enjoy the games I've made and all of the amazing artwork submitted by members of the server!\n\n` +
`🎨 **Credits:**\n` +
`<#1474982495123411149>\n\n` +
`If you've created any artwork *(or even relevant memes!)* that you'd like to be considered, feel free to submit them here:\n\n` +
`🖼️ <#1481167502372245505>`
);
}
return embed;
}
function buildHelpButtons(userId) {
return new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId(`help_bones_${userId}`)
.setLabel("1️⃣")
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId(`help_cards_${userId}`)
.setLabel("2️⃣")
.setStyle(ButtonStyle.Success),
new ButtonBuilder()
.setCustomId(`help_commands_${userId}`)
.setLabel("3️⃣")
.setStyle(ButtonStyle.Secondary),
new ButtonBuilder()
.setCustomId(`help_why_${userId}`)
.setLabel("4️⃣")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`help_main_${userId}`)
.setLabel("Menu")
.setEmoji("🏠")
.setStyle(ButtonStyle.Success)
);
}
async function applyDailyTokenGrant(user) {
const today = getBrisbaneToday();
if (user.lastGlobalTokenDaily === today) {
return user;
}
user.bibblesTokens = Math.min(
MAX_BIBBLES_TOKENS,
(user.bibblesTokens || 0) + DAILY_TOKEN_AMOUNT
);
user.lastGlobalTokenDaily = today;
user.lastBibblesTokenRecharge = new Date();
await user.save();
return user;
}
async function spendBibblesToken(user) {
if (user.bibblesTokens <= 0) {
return false;
}
user.bibblesTokens -= 1;
await user.save();
return true;
}
async function spendBibblesToken2(user) {
if (user.bibblesTokens <= 1) {
return false;
}
user.bibblesTokens -= 2;
await user.save();
return true;
}
async function startCoinFlip(interaction, bet) {
const embed = new EmbedBuilder()
.setTitle("<:BToken:1518219006392274995> Coin Flip")
.setDescription(
`Bet: **${bet} bones**\n\n` +
"You get **3 flips**.\n" +
"Choose Heads or Tails!"
)
.addFields(
{ name: "Flips Left", value: "3", inline: true },
{ name: "Wins", value: "0", inline: true }
)
.setColor(0xf5c542);
const row = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId(`coinflip_heads_${interaction.user.id}_3_0_${bet}`)
.setLabel("Heads")
.setEmoji("<:BHeads:1519545907920765028>")
.setStyle(ButtonStyle.Secondary),
new ButtonBuilder()
.setCustomId(`coinflip_tails_${interaction.user.id}_3_0_${bet}`)
.setLabel("Tails")
.setEmoji("<:BTails:1519545923632631879>")
.setStyle(ButtonStyle.Danger)
);
return interaction.update({
embeds: [embed],
components: [row]
});
}
async function showCoinFlipBetMenu(interaction, user) {
const embed = new EmbedBuilder()
.setTitle("<:BToken:1518219006392274995> Coin Flip")
.setDescription(
"You used **1 Bibbles Token**.\n\n" +
"Choose your bet:\n\n" +
"Each game gives you **3 flips**.\n" +
"Each correct flip pays back **1x your bet**.\n" +
"Get all **3/3** for a bonus **+1x your bet**!"
)
.addFields(
{ name: "Your Bones", value: `${user.bones} <:BBones:1518220991938170910>`, inline: true }
)
.setColor(0xf5c542);
const row = new ActionRowBuilder().addComponents(
...COINFLIP_BETS.map(bet =>
new ButtonBuilder()
.setCustomId(`coinflip_bet_${bet}_${interaction.user.id}`)
.setLabel(`Bet ${bet}`)
.setEmoji("<:BBones:1518220991938170910>")
.setStyle(ButtonStyle.Primary)
.setDisabled(user.bones < bet)
)
);
return interaction.reply({
embeds: [embed],
components: [row],
flags: 64
});
}
async function showGraveRobberyBetMenu(interaction, user) {
const embed = new EmbedBuilder()
.setTitle("⚰️ Grave Robbery")
.setDescription(
"You used **1 Bibbles Token**.\n\n" +
"Choose your bet:\n\n" +
"You get **3 graves**.\n" +
"Each grave has either **treasure** or a **curse**."
)
.addFields(
{ name: "Your Bones", value: `${user.bones} <:BBones:1518220991938170910>`, inline: true }
)
.setColor(0x7b3f00);
const row = new ActionRowBuilder().addComponents(
...GRAVEROBBERY_BETS.map(bet =>
new ButtonBuilder()
.setCustomId(`graverobbery_bet_${bet}_${interaction.user.id}`)
.setLabel(`Bet ${bet}`)
.setEmoji("<:BBones:1518220991938170910>")
.setStyle(ButtonStyle.Primary)
.setDisabled(user.bones < bet)
)
);
return interaction.reply({
embeds: [embed],
components: [row],
flags: 64
});
}
async function startGraveRobbery(interaction, bet) {
const embed = new EmbedBuilder()
.setTitle("⚰️ Grave Robbery")
.setDescription(
`Bet: **${bet} bones**\n\n` +
"Pick a grave.\n" +
"You have **3 rounds**."
)
.addFields(
{ name: "Rounds Left", value: "3", inline: true },
{ name: "Treasures Found", value: "0", inline: true }
)
.setColor(0x7b3f00);
const row = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId(`graverobbery_pick_1_${interaction.user.id}_3_0_${bet}`)
.setLabel("Grave 1")
.setEmoji("⚰️")
.setStyle(ButtonStyle.Secondary),
new ButtonBuilder()
.setCustomId(`graverobbery_pick_2_${interaction.user.id}_3_0_${bet}`)
.setLabel("Grave 2")
.setEmoji("⚰️")
.setStyle(ButtonStyle.Secondary),
new ButtonBuilder()
.setCustomId(`graverobbery_pick_3_${interaction.user.id}_3_0_${bet}`)
.setLabel("Grave 3")
.setEmoji("⚰️")
.setStyle(ButtonStyle.Secondary)
);
return interaction.update({
embeds: [embed],
components: [row]
});
}
async function showBlackjackBetMenu(interaction, user) {
const embed = new EmbedBuilder()
.setTitle("🃏 Blackjack")
.setDescription(
"Choose your bet.\n\n" +
"Can you get closer to **21** than the Dealer?\n"
)
.addFields({
name: "Your Bones",
value: `${user.bones} <:BBones:1518220991938170910>`
})
.setColor(0x2ecc71);
const row = new ActionRowBuilder().addComponents(
...BLACKJACK_BETS.map(bet =>
new ButtonBuilder()
.setCustomId(`blackjack_bet_${bet}_${interaction.user.id}`)
.setLabel(`Bet ${bet}`)
.setEmoji("<:BBones:1518220991938170910>")
.setStyle(ButtonStyle.Primary)
.setDisabled(user.bones < bet)
)
);
return interaction.reply({
embeds: [embed],
components: [row],
flags: 64
});
}
async function showHigherLowerBetMenu(interaction, user) {
const embed = new EmbedBuilder()
.setTitle("⬆️ Higher or Lower")
.setDescription(
"Guess whether the next card will be higher or lower.\n\n" +
"Cash out anytime.\n" +
"One wrong guess loses everything."
)
.addFields(
{
name: "Your Bones",
value: `${user.bones} <:BBones:1518220991938170910>`,
inline: true
},
{
name: "Best Streak",
value: `${user.highlowBestStreak || 0}`,
inline: true
}
)
.setColor(0x5865f2);
const row = new ActionRowBuilder().addComponents(
...HIGHLOW_BETS.map(bet =>
new ButtonBuilder()
.setCustomId(`highlow_bet_${bet}_${interaction.user.id}`)
.setLabel(`Bet ${bet}`)
.setEmoji("<:BBones:1518220991938170910>")
.setStyle(ButtonStyle.Primary)
.setDisabled(user.bones < bet)
)
);
return interaction.reply({
embeds: [embed],
components: [row],
flags: 64
});
}
async function showBoneDigBetMenu(interaction, user) {
const embed = new EmbedBuilder()
.setTitle("⛏️ Bone Dig")
.setDescription(
"Pick rocks and dig for treasure.\n\n" +
"Find bones, treasure, or relics.\n" +
"Hit a trap and lose everything.\n" +
"Cash out anytime."
)
.addFields({
name: "Your Bones",
value: `${user.bones} <:BBones:1518220991938170910>`
})
.setColor(0xc27c2c);
const row = new ActionRowBuilder().addComponents(
...BONEDIG_BETS.map(bet =>
new ButtonBuilder()
.setCustomId(`bonedig_bet_${bet}_${interaction.user.id}`)
.setLabel(`Bet ${bet}`)
.setEmoji("<:BBones:1518220991938170910>")
.setStyle(ButtonStyle.Primary)
.setDisabled(user.bones < bet)
)
);
return interaction.reply({
embeds: [embed],
components: [row],
flags: 64
});
}
async function showGamesMenu(interaction, user, useUpdate = false) {
const embed = new EmbedBuilder()
.setTitle("🎮 Bibbles Games")
.setDescription(
`Welcome to the BoneBot arcade!\n\n` +
`<:BToken:1518219006392274995> **Game Tokens:** ${user.bibblesTokens}/${MAX_BIBBLES_TOKENS}\n` +
`⏳ **Next Token:** Gives +10 at "daily" reset time!\n\n` +
`Choose a game below:`
)
.addFields(
{
name: "<:BToken:1518219006392274995> Coin Flip",
value: "3 flips per token.",
inline: true
},
{
name: "⚰️ Grave Robbery",
value: "Rob 3 graves per token.",
inline: true
},
{
name: "🃏 Blackjack",
value: "1 hand per token.",
inline: true
},
{
name: "⬆️ Higher or Lower",
value: "Climb the multiplier.",
inline: true
},
{
name: "⛏️ Bone Dig (2 TOKENS)",
value: "Dig, cash out, or perish.",
inline: true
}
)
.setColor(0xf5c542);
const row = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId(`game_coinflip_${interaction.user.id}`)
.setLabel("Coin Flip")
.setEmoji("<:BToken:1518219006392274995>")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`game_graverobbery_${interaction.user.id}`)
.setLabel("Grave Robbery")
.setEmoji("⚰️")
.setStyle(ButtonStyle.Secondary),
new ButtonBuilder()
.setCustomId(`game_blackjack_${interaction.user.id}`)
.setLabel("Blackjack")
.setEmoji("🃏")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`game_higherlower_${interaction.user.id}`)
.setLabel("Higher/Lower")
.setEmoji("⬆️")
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId(`game_bonedig_${interaction.user.id}`)
.setLabel("Bone Dig")
.setEmoji("⛏️")
.setStyle(ButtonStyle.Success)
);
const payload = {
embeds: [embed],
components: [row]
};
if (useUpdate) {
return interaction.update(payload);
}
return interaction.reply({
...payload,
flags: 64
});
}
function createMainMenuRow(userId) {
return new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId(`games_menu_${userId}`)
.setLabel("Main Menu")
.setEmoji("🎮")
.setStyle(ButtonStyle.Primary)
);
}
async function buildLeaderboardPayload(interaction, type, page = 0) {
const PAGE_SIZE = 10;
let users = await User.find().lean();
let title;
let getValue;
let statLabel;
if (type === "spent") {
title = "🛒 Leaderboard Bones Spent";
statLabel = "bones spent";
getValue = user => user.bonesSpentTotal || 0;
} else if (type === "earned") {
title = "📜 Leaderboard All Time Balance";
statLabel = "bones earned";
getValue = user => user.bonesEarnedTotal || 0;
} else if (type === "daily") {
title = "🔥 Leaderboard Daily Streak";
statLabel = "day streak";
getValue = user => user.dailyStreak || 0;
} else {
title = "⬆️ Leaderboard High Low Streak";
statLabel = "best streak";
getValue = user => user.highlowBestStreak || 0;
}
users = users