rai if you are reading this im getting you a monster

This commit is contained in:
DeSqBlocki
2026-08-14 22:54:03 +02:00
parent 912b1b6ceb
commit c76680293e
34 changed files with 1478 additions and 3338 deletions
+844
View File
@@ -0,0 +1,844 @@
const {
SlashCommandBuilder,
EmbedBuilder
} = require("discord.js");
const { mClient } = require("../..");
const DATABASE = "neo-db";
const COOKIE_COLLECTION = "items_cookies";
const COOLDOWN_COLLECTION = "cooldowns_cookies";
const COLLECT_COOLDOWN = 60 * 60; // 1 hour
const STEAL_COOLDOWN = 15 * 60; // 15 minutes
const STEAL_SUCCESS_CHANCE = 0.50;
const ABRA_ID = "378135175059603457";
const ABRA_MULTIPLIER = 1.5;
module.exports = {
data: new SlashCommandBuilder()
.setName("cookies")
.setDescription("The ShaiBot cookie economy.")
.addSubcommand(subcommand =>
subcommand
.setName("collect")
.setDescription("Collect a fresh batch of cookies.")
)
.addSubcommand(subcommand =>
subcommand
.setName("steal")
.setDescription("Attempt to steal another user's cookies.")
.addUserOption(option =>
option
.setName("target")
.setDescription("The unfortunate victim.")
.setRequired(true)
)
)
.addSubcommand(subcommand =>
subcommand
.setName("check")
.setDescription("Check a cookie balance.")
.addUserOption(option =>
option
.setName("target")
.setDescription("The user whose cookies you want to check.")
)
)
.addSubcommand(subcommand =>
subcommand
.setName("give")
.setDescription("Give some of your cookies to another user.")
.addUserOption(option =>
option
.setName("target")
.setDescription("The recipient.")
.setRequired(true)
)
.addIntegerOption(option =>
option
.setName("amount")
.setDescription("How many cookies to give.")
.setRequired(true)
.setMinValue(1)
)
)
.addSubcommand(subcommand =>
subcommand
.setName("leaderboard")
.setDescription("Show the richest cookie collectors.")
),
async execute(interaction) {
switch (interaction.options.getSubcommand()) {
case "collect":
return collect(interaction);
case "steal":
return steal(interaction);
case "check":
return check(interaction);
case "give":
return give(interaction);
case "leaderboard":
return leaderboard(interaction);
default:
return interaction.reply({
content: "Unknown subcommand.",
ephemeral: true
});
}
}
};
/*
* DATABASE
*/
function getCollections() {
const db = mClient.db(DATABASE);
return {
cookies: db.collection(COOKIE_COLLECTION),
cooldowns: db.collection(COOLDOWN_COLLECTION)
};
}
/*
* COOKIE HELPERS
*/
async function getCookieBalance(userId) {
const { cookies } = getCollections();
const result = await cookies.findOne(
{
userId
},
{
projection: {
_id: 0,
cookies: 1
}
}
);
return result?.cookies ?? 0;
}
async function changeCookies(userId, amount, session = undefined) {
const { cookies } = getCollections();
return cookies.updateOne(
{
userId
},
{
$inc: {
cookies: amount
},
$setOnInsert: {
userId
}
},
{
upsert: true,
session
}
);
}
/*
* COOKIE TRANSFER
*
* This uses a transaction so both balances update together.
*
* MongoDB transactions require Atlas or a replica set.
*/
async function transferCookies(fromUserId, toUserId, amount) {
const { cookies } = getCollections();
const session = mClient.startSession();
try {
await session.withTransaction(async () => {
/*
* Only debit if the sender still has enough cookies.
*
* This protects against two commands being executed
* at almost the same time.
*/
const debit = await cookies.updateOne(
{
userId: fromUserId,
cookies: {
$gte: amount
}
},
{
$inc: {
cookies: -amount
}
},
{
session
}
);
if (debit.modifiedCount !== 1) {
throw new Error("INSUFFICIENT_COOKIES");
}
await cookies.updateOne(
{
userId: toUserId
},
{
$inc: {
cookies: amount
},
$setOnInsert: {
userId: toUserId
}
},
{
upsert: true,
session
}
);
});
} finally {
await session.endSession();
}
}
/*
* COOLDOWN HELPERS
*
* cooldowns_cookies:
*
* {
* userId: "...",
* guildId: "...",
* collect: 1786741200,
* steal: 1786738500
* }
*/
async function getCooldown(userId, guildId, type) {
const { cooldowns } = getCollections();
const result = await cooldowns.findOne(
{
userId,
guildId
},
{
projection: {
_id: 0,
[type]: 1
}
}
);
return result?.[type] ?? 0;
}
async function setCooldown(userId, guildId, type, duration) {
const { cooldowns } = getCollections();
const now = getUnixTime();
const next = now + duration;
await cooldowns.updateOne(
{
userId,
guildId
},
{
$set: {
[type]: next
},
$setOnInsert: {
userId,
guildId
}
},
{
upsert: true
}
);
return next;
}
/*
* /cookies collect
*/
async function collect(interaction) {
const userId = interaction.user.id;
const guildId = interaction.guildId;
const now = getUnixTime();
const cooldown = await getCooldown(
userId,
guildId,
"collect"
);
if (cooldown > now) {
return interaction.reply({
content:
`The batch is still cooking. Come back <t:${cooldown}:R> 🍪`,
ephemeral: true
});
}
let amount = randomInteger(1, 20);
/*
* Legacy Abra bonus.
*/
if (userId === ABRA_ID) {
amount = Math.ceil(
amount * ABRA_MULTIPLIER
);
}
await changeCookies(
userId,
amount
);
await setCooldown(
userId,
guildId,
"collect",
COLLECT_COOLDOWN
);
return interaction.reply({
content: randomCollectResponse(
amount,
interaction.user
)
});
}
/*
* /cookies steal
*/
async function steal(interaction) {
const user = interaction.user;
const target = interaction.options.getUser(
"target",
true
);
/*
* Can't rob yourself.
*/
if (target.id === user.id) {
return interaction.reply({
content:
"C'mon, don't embarrass yourself. You can't steal from yourself.",
ephemeral: true
});
}
/*
* Don't let people farm bot accounts.
*/
if (target.bot) {
return interaction.reply({
content:
"Bots have highly sophisticated cookie security systems.",
ephemeral: true
});
}
const now = getUnixTime();
/*
* Check steal cooldown before doing anything expensive.
*/
const cooldown = await getCooldown(
user.id,
interaction.guildId,
"steal"
);
if (cooldown > now) {
return interaction.reply({
content:
`Lay low for a while. You can steal again <t:${cooldown}:R>.`,
ephemeral: true
});
}
/*
* Fetch both balances concurrently.
*/
const [
yourCookies,
theirCookies
] = await Promise.all([
getCookieBalance(user.id),
getCookieBalance(target.id)
]);
if (yourCookies < 1) {
return interaction.reply({
content:
"You need at least **1 Cookie** to attempt a robbery.",
ephemeral: true
});
}
if (theirCookies < 1) {
return interaction.reply({
content:
`Shame on you! ${target} doesn't have any Cookies. D:`,
ephemeral: true
});
}
/*
* Chaos mode:
* fixed 50% steal chance.
*/
const success =
Math.random() < STEAL_SUCCESS_CHANCE;
/*
* Successful robbery.
*/
if (success) {
const maxSteal = Math.max(
1,
Math.ceil(theirCookies / 4)
);
const amount = Math.min(
theirCookies,
randomInteger(
1,
maxSteal
)
);
try {
await transferCookies(
target.id,
user.id,
amount
);
} catch (error) {
if (error.message === "INSUFFICIENT_COOKIES") {
return interaction.reply({
content:
`${target}'s Cookie balance changed before you could finish the robbery.`,
ephemeral: true
});
}
throw error;
}
const nextSteal = await setCooldown(
user.id,
interaction.guildId,
"steal",
STEAL_COOLDOWN
);
return interaction.reply({
content:
`${randomStealSuccessResponse(amount, target)}\n` +
`**Success Chance:** ${formatPercentage(STEAL_SUCCESS_CHANCE)} • ` +
`Next robbery <t:${nextSteal}:R>`
});
}
/*
* Failed robbery.
*
* Lose between 1 and roughly 1/6 of your balance.
*/
const maxPenalty = Math.max(
1,
Math.ceil(yourCookies / 6)
);
const penalty = Math.min(
yourCookies,
randomInteger(
1,
maxPenalty
)
);
try {
await transferCookies(
user.id,
target.id,
penalty
);
} catch (error) {
if (error.message === "INSUFFICIENT_COOKIES") {
return interaction.reply({
content:
"Your Cookie balance changed before the robbery could finish.",
ephemeral: true
});
}
throw error;
}
const nextSteal = await setCooldown(
user.id,
interaction.guildId,
"steal",
STEAL_COOLDOWN
);
return interaction.reply({
content:
`${randomStealFailResponse(penalty, target)}\n` +
`**Success Chance:** ${formatPercentage(STEAL_SUCCESS_CHANCE)} • ` +
`Next robbery <t:${nextSteal}:R>`
});
}
/*
* /cookies check
*/
async function check(interaction) {
const target =
interaction.options.getUser("target")
?? interaction.user;
const balance =
await getCookieBalance(target.id);
const mood =
balance === 0
? "😔"
: "🍪";
return interaction.reply({
content:
`${target} has **${balance.toLocaleString()} Cookie${balance === 1 ? "" : "s"}**! ${mood}`
});
}
/*
* /cookies give
*/
async function give(interaction) {
const user = interaction.user;
const target = interaction.options.getUser(
"target",
true
);
const amount = interaction.options.getInteger(
"amount",
true
);
if (target.id === user.id) {
return interaction.reply({
content:
"You cannot give Cookies to yourself.",
ephemeral: true
});
}
if (target.bot) {
return interaction.reply({
content:
"Bots don't need Cookies. Allegedly.",
ephemeral: true
});
}
try {
await transferCookies(
user.id,
target.id,
amount
);
} catch (error) {
if (error.message === "INSUFFICIENT_COOKIES") {
return interaction.reply({
content:
"We don't run a charity here. You don't have enough Cookies!",
ephemeral: true
});
}
throw error;
}
return interaction.reply({
content:
`${user} shared **${amount.toLocaleString()} Cookie${amount === 1 ? "" : "s"}** with ${target} 🍪`
});
}
/*
* /cookies leaderboard
*/
async function leaderboard(interaction) {
const { cookies } = getCollections();
const results = await cookies
.find({
cookies: {
$gt: 0
}
})
.sort({
cookies: -1
})
.limit(10)
.toArray();
const description = results.length
? results
.map((record, index) => {
const medal = getLeaderboardMedal(index);
return (
`${medal} <@${record.userId}> — ` +
`**${record.cookies.toLocaleString()}** 🍪`
);
})
.join("\n")
: "Nobody has collected any Cookies yet.";
const embed = new EmbedBuilder()
.setTitle("🍪 Cookie Leaderboard")
.setDescription(description)
.setTimestamp();
if (interaction.guild?.iconURL()) {
embed.setThumbnail(
interaction.guild.iconURL({
size: 256
})
);
}
return interaction.reply({
embeds: [embed]
});
}
/*
* COLLECT RESPONSES
*/
function randomCollectResponse(amount, user) {
const cookies =
`**${amount.toLocaleString()} Cookie${amount === 1 ? "" : "s"}**`;
const responses = [
`${user}, I made you ${cookies} 🍪`,
`${user}, here's your ${cookies} 🍪 I ate the rest, sorry >.<`,
`Only ${cookies} 🍪 for you today ${user}... Abra stole the rest :c`,
`${user}, would you like a glass of milk with your ${cookies}? 🥛`,
`${cookies} 🍪 Careful, ${user}! They're still warm :3`,
`${cookies} 🍪 Best batch yet!`,
`${user}, these ${cookies} I bequeath unto thine own self upon this day.`,
`${user}, your ${cookies} are fresh out of the oven. Try not to burn your tongue!`,
`${user}, I bribed the Cookie Monster to spare these ${cookies} just for you.`,
`${user}, Santa came early! You got ${cookies}. Milk not included.`,
`${user}, your ${cookies} are artisanal, gluten-free, and slightly cursed.`,
`A wild baker appeared! They hand ${user} ${cookies} 🍪`,
`${user}, Abra said these ${cookies} are "totally not stolen"... 🤔`,
`${user}, here's your ${cookies} — watch out, they may be booby-trapped.`
];
return randomItem(responses);
}
/*
* STEAL SUCCESS RESPONSES
*/
function randomStealSuccessResponse(amount, target) {
const cookies =
`**${amount.toLocaleString()} Cookie${amount === 1 ? "" : "s"}**`;
const responses = [
`You've successfully stolen ${cookies} from ${target}!`,
`Ninja mode activated. You snatched ${cookies} from ${target} without leaving a crumb behind.`,
`Abra taught you well — ${cookies} from ${target} are now yours!`,
`Like a phantom in the night, you took ${cookies} from ${target}.`,
`You just pulled the sweetest heist: ${cookies} from ${target}!`,
`Mission complete. ${target} is ${cookies} poorer.`,
`You distracted ${target} with a dance and swiped ${cookies}.`,
`Clean getaway! ${target} won't notice the missing ${cookies} until it's too late.`,
`The Cookie Vault has been breached. ${cookies} taken from ${target}.`,
`You emerged from the shadows carrying ${cookies} from ${target}.`
];
return randomItem(responses);
}
/*
* STEAL FAILURE RESPONSES
*/
function randomStealFailResponse(amount, target) {
const cookies =
`**${amount.toLocaleString()} Cookie${amount === 1 ? "" : "s"}**`;
const responses = [
`You were caught red-handed by ${target} and lost ${cookies} as a penalty!`,
`Fail! ${target} caught you mid-bite — you dropped ${cookies}.`,
`Not your best moment... You lost ${cookies} to ${target} in the struggle.`,
`Stealth level: 0. You handed ${cookies} to ${target} as an apology.`,
`The Cookie jar was booby-trapped! You gave ${cookies} to ${target} while running away.`,
`Ouch. The guard dog barked, and now ${target} has your ${cookies}.`,
`You tripped over your own shoelace — ${target} picked up ${cookies}.`,
`Caught by the Cookie Police! ${cookies} confiscated and given to ${target}.`,
`Your pockets had holes... ${target} found the ${cookies} you dropped.`
];
return randomItem(responses);
}
/*
* GENERIC HELPERS
*/
function getUnixTime() {
return Math.floor(
Date.now() / 1000
);
}
function randomInteger(min, max) {
return Math.floor(
Math.random() * (max - min + 1)
) + min;
}
function randomItem(items) {
return items[
Math.floor(
Math.random() * items.length
)
];
}
function formatPercentage(value) {
return `${Math.round(value * 100)}%`;
}
function getLeaderboardMedal(index) {
switch (index) {
case 0:
return "🥇";
case 1:
return "🥈";
case 2:
return "🥉";
default:
return `**${index + 1}.**`;
}
}
-312
View File
@@ -1,312 +0,0 @@
// cookies.js — rewritten & rebalanced
const { MongoClient, ServerApiVersion } = require('mongodb');
require('dotenv').config();
const cookieSchema = require("../schemas/cookieSchema"); // expected to support findOne, findOneAndUpdate, updateOne, find
const cooldownSchema = require("../schemas/cooldownSchema"); // expected to support findOne, findOneAndUpdate
const Discord = require('discord.js');
const URI = process.env.URI;
if (!URI) throw new Error("Missing process.env.URI for MongoDB");
// single client reused
const client = new MongoClient(URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
serverApi: ServerApiVersion.v1
});
client.connect().catch(err => {
console.error("Mongo connect error:", err);
});
// util
const msToTime = (duration) => {
const ms = Math.floor((duration % 1000) / 100);
const s = Math.floor((duration / 1000) % 60);
const m = Math.floor((duration / (1000 * 60)) % 60);
const h = Math.floor((duration / (1000 * 60 * 60)) % 24);
const pad = n => (n < 10 ? "0" + n : "" + n);
return `${pad(h)}:${pad(m)}:${pad(s)}`;
};
const delay = ms => new Promise(r => setTimeout(r, ms));
// --- Helpers ---
async function getCookies(userId) {
const rec = await cookieSchema.findOne({ _id: userId });
return rec && typeof rec.cookies === 'number' ? rec.cookies : 0;
}
async function changeCookies(userId, delta, username = null) {
// upsert and set username if provided
const update = { $inc: { cookies: delta } };
if (username) update.$set = { user: username };
return cookieSchema.findOneAndUpdate(
{ _id: userId },
update,
{ upsert: true, returnDocument: 'after' }
);
}
async function getCooldown(uniqueId) {
const rec = await cooldownSchema.findOne({ _id: uniqueId });
return rec && rec.cooldown ? rec.cooldown : 0;
}
async function setCooldown(uniqueId, command, subcommand, msTimestamp) {
await cooldownSchema.findOneAndUpdate(
{ _id: uniqueId },
{ _id: uniqueId, command, subcommand, cooldown: msTimestamp },
{ upsert: true }
);
}
function cooldownId(guildId, userId, command, subcommand) {
return `${guildId}-${userId}-${command}-${subcommand}`;
}
// --- Game logic & rebalances ---
// Notes about balancing:
// - Collect: 1..20 cookies (consistent reward); Abra (special user id) gets 1.5x.
// - Steal:
// * successChance = attacker / (attacker + defender), clamped to [0.10, 0.90]
// * steal amount: random 1..ceil(defender/4)
// * failure penalty: attacker loses random 1..ceil(attacker/6) (transferred to defender)
// - Cooldowns: collect = 1 hour, steal = 15 minutes
const ABRA_ID = "378135175059603457"; // kept from original for bonus
async function collect(interaction, user) {
const sub = interaction.options._subcommand;
const id = cooldownId(interaction.guildId, interaction.user.id, interaction.commandName, sub);
const now = Date.now();
const existing = await getCooldown(id);
if (existing > now) {
return interaction.reply({
content: `The batch is still cooking, come back in **${msToTime(existing - now)}**`,
ephemeral: true
});
}
// set cooldown (1 hour)
const cooldownUntil = now + 60 * 60 * 1000;
await setCooldown(id, interaction.commandName, sub, cooldownUntil);
// balanced collect amount: 1..20
let amount = Math.floor(Math.random() * 20) + 1;
if (user.id === ABRA_ID) amount = Math.ceil(amount * 1.5);
// update DB
await changeCookies(user.id, amount, user.username);
// playful responses (kept / adapted)
const collectResponses = (amount, user) => {
const s = amount === 1 ? 'Cookie' : 'Cookies';
return [
`${user}, I made you **${amount}** ${s} 🍪`,
`${user}, here's your **${amount}** ${s} 🍪 I ate the rest, sorry >.<`,
`Only **${amount}** ${s} 🍪 for you today ${user}... Abra stole the rest :c`,
`${user}, would you like a Glass of Milk with your **${amount}** ${s}? 🍪`,
`**${amount}** ${s} 🍪 Careful, ${user}! They're still warm :3`,
`**${amount}** ${s} 🍪 Best Batch yet!`,
`**${amount}** ${s} 🍪 These, I bequeath unto thine own self upon this day. Thou must guard them safely.`,
`${user}, your **${amount}** ${s} 🍪 are fresh out of the oven... try not to burn your tongue!`,
`${user}, I bribed the Cookie Monster to spare these **${amount}** ${s} 🍪 just for you.`,
`${user}, Santa came early! You got **${amount}** ${s} 🍪 (milk not included).`,
`${user}, your **${amount}** ${s} 🍪 are artisanal, gluten-free, and slightly cursed.`,
`A wild baker appeared! They hand you **${amount}** ${s} 🍪`,
`${user}, Abra said these **${amount}** ${s} 🍪 are "totally not stolen"... 🤔`,
`${user}, here’s your **${amount}** ${s} 🍪 — watch out, they may be booby-trapped.`
];
};
const responses = collectResponses(amount, user);
const i = Math.floor(Math.random() * responses.length);
return interaction.reply({ content: responses[i] });
}
async function steal(interaction, user) {
const target = interaction.options.getUser('target');
if (!target) {
return interaction.reply({ content: `Pick someone to steal from.`, ephemeral: true });
}
if (target.id === user.id) {
return interaction.reply({
content: `C'mon, don't embarrass yourself! We all know you couldn't do that, even if you tried.`,
ephemeral: true
});
}
// pull balances
const your = await getCookies(user.id);
const their = await getCookies(target.id);
if (your <= 0) {
return interaction.reply({ content: `You need at least 1 Cookie to attempt a Robbery`, ephemeral: true });
}
if (their <= 0) {
return interaction.reply({ content: `Shame on you! ${target.username} doesn't have any Cookies D:`, ephemeral: true });
}
// steal cooldown (15 minutes)
const sub = interaction.options._subcommand;
const id = cooldownId(interaction.guildId, interaction.user.id, interaction.commandName, sub);
const now = Date.now();
const existing = await getCooldown(id);
const chaos = true // 50% Stela Chance Mode
if (existing > now) {
return interaction.reply({
content: `Hold up — try stealing again in **${msToTime(existing - now)}**`,
ephemeral: true
});
}
await setCooldown(id, interaction.commandName, sub, now + 15 * 60 * 1000);
// success chance and clamping
let successChance = your / (your + their);
if (isNaN(successChance) || !isFinite(successChance)) successChance = 0.2;
if (chaos) {
successChance = 0.5
} else {
successChance = Math.max(0.10, Math.min(0.90, successChance));
}
const success = Math.random() < successChance;
if (success) {
const stealSuccessResponses = (amount, target) => {
const s = amount === 1 ? 'Cookie' : 'Cookies';
return [
`You've successfully stolen **${amount}** ${s} from **${target.username}**!`,
`Ninja mode: activated. You snatched **${amount}** ${s} from **${target.username}** without a crumb left behind.`,
`Abra taught you well — **${amount}** ${s} from **${target.username}** are now yours!`,
`Like a phantom in the night, you took **${amount}** ${s} from **${target.username}**.`,
`You just pulled the sweetest heist: **${amount}** ${s} from **${target.username}**!`,
`Mission complete. **${target.username}** is **${amount}** ${s} poorer, you are richer.`,
`You distracted **${target.username}** with a dance and swiped **${amount}** ${s}.`,
`Clean getaway! **${target.username}** won’t know about the missing **${amount}** ${s} until it’s too late.`,
`The Cookie Vault has been breached. **${amount}** ${s} taken from **${target.username}**.`,
`You emerged from the shadows with **${amount}** ${s} from **${target.username}**.`
];
};
const maxSteal = Math.max(1, Math.ceil(their / 4)); // steal up to ~25% of victim
let amount = Math.floor(Math.random() * maxSteal) + 1;
amount = Math.min(amount, their);
// transfer
await Promise.all([
changeCookies(user.id, amount, user.username),
changeCookies(target.id, -amount, target.username)
]);
const responses = stealSuccessResponses(amount, target);
const i = Math.floor(Math.random() * responses.length);
return interaction.reply({ content: `${responses[i]} (Chance: ${Math.round(successChance * 100, 2)}%)` });
} else {
const stealFailResponses = (penalty, target) => {
const s = penalty === 1 ? 'Cookie' : 'Cookies';
return [
`You were caught red-handed by **${target.username}** and lost **${penalty}** ${s} as a penalty!`,
`Fail! **${target.username}** caught you mid-bite — you dropped **${penalty}** ${s}.`,
`Not your best moment... You lost **${penalty}** ${s} to **${target.username}** in the struggle.`,
`Stealth level: 0. You handed **${penalty}** ${s} to **${target.username}** as an apology.`,
`The cookie jar was booby-trapped! You gave **${penalty}** ${s} to **${target.username}** while running away.`,
`Ouch. The guard dog barked, and now **${target.username}** has your **${penalty}** ${s}.`,
`You tripped over your own shoelace — **${target.username}** reclaimed **${penalty}** ${s}.`,
`Caught by the Cookie Police! **${penalty}** ${s} confiscated and given to **${target.username}**.`,
`Your pockets had holes... **${target.username}** picked up **${penalty}** ${s} you dropped.`
];
};
// failure penalty: attacker loses a little (1..ceil(your/6)) to the victim
const maxPenalty = Math.max(1, Math.ceil(your / 6));
const penalty = Math.min(your, Math.floor(Math.random() * maxPenalty) + 1);
await Promise.all([
changeCookies(user.id, -penalty, user.username),
changeCookies(target.id, +penalty, target.username)
]);
const responses = stealFailResponses(penalty, target);
const i = Math.floor(Math.random() * responses.length);
return interaction.reply({ content: `${responses[i]} (Chance: ${Math.round(successChance * 100, 2)}%)` });
}
}
async function check(interaction, user) {
let target = interaction.options.getUser('target');
if (!target) target = user;
const cookies = await getCookies(target.id);
const mood = cookies === 0 ? '😔' : '😲';
return interaction.reply({ content: `**${target.username}** has **${cookies}** Cookies! ${mood}` });
}
async function give(interaction, user) {
const target = interaction.options.getUser('target');
const amount = interaction.options.getInteger('amount');
if (!target) return interaction.reply({ content: `You need to specify a target.`, ephemeral: true });
if (target.id === user.id) return interaction.reply({ content: 'You cannot give yourself Cookies ._."', ephemeral: true });
if (!Number.isInteger(amount) || amount < 1) {
return interaction.reply({ content: `**${user}** shared *checks notes* **${amount}** Cookie(s) with ${target}....wait a minute!!`, ephemeral: true });
}
const your = await getCookies(user.id);
if (your < amount) return interaction.reply({ content: `We don't run a charity here, get more Cookies!`, ephemeral: true });
await Promise.all([
changeCookies(user.id, -amount, user.username),
changeCookies(target.id, +amount, target.username)
]);
// small delay to mimic previous behavior
await delay(200);
return interaction.reply({ content: `**${user}** shared **${amount}** Cookie(s) with ${target}` });
}
async function leader(interaction) {
const results = await cookieSchema.find().sort({ cookies: -1 }).limit(10);
let cookieSorted = '';
results.forEach((r, i) => {
cookieSorted += `[${i + 1}] <@${r._id}> (${r.cookies})\n`;
});
const embed = new Discord.MessageEmbed()
.setColor(0x0099FF)
.setThumbnail(interaction.guild.iconURL())
.setTimestamp()
.addFields({ name: `-Cookie Leaderboard-`, value: cookieSorted || 'No cookie data yet.' });
return interaction.reply({ embeds: [embed] });
}
module.exports = {
slash: true,
description: 'collect a cookie',
category: 'Misc',
options: [
{ name: "collect", description: "want some?", type: 1 },
{ name: "steal", description: "try your luck at a lala robbery!", type: 1, options: [{ name: "target", description: "someone", required: true, type: 6 }] },
{ name: "check", description: "check your cookie stash", type: 1, options: [{ name: "target", description: "someone", type: 6 }] },
{ name: "give", description: "share your cookies with someone", type: 1, options: [{ name: "target", description: "someone", required: true, type: 6 }, { name: "amount", description: "cookies", required: true, type: 4 }] },
{ name: "leader", description: "show Top 10 Cookie Clickers", type: 1 }
],
callback: ({ interaction, user }) => {
const sub = interaction.options._subcommand;
switch (sub) {
case "collect": return collect(interaction, user);
case "steal": return steal(interaction, user);
case "check": return check(interaction, user);
case "give": return give(interaction, user);
case "leader": return leader(interaction);
default: return interaction.reply({ content: 'Unknown subcommand', ephemeral: true });
}
}
};
-448
View File
@@ -1,448 +0,0 @@
const { MongoClient, ServerApiVersion } = require('mongodb');
require('dotenv').config();
const uri = process.env.URI
const cookieSchema = require("../schemas/cookieSchema")
const cooldownSchema = require("../schemas/cooldownSchema")
const delay = ms => new Promise(resolve => setTimeout(resolve, ms))
const Discord = require('discord.js')
const client = new MongoClient(uri, {
useNewUrlParser: true,
useUnifiedTopology: true,
serverApi: ServerApiVersion.v1
});
function msToTime(duration) {
var milliseconds = parseInt((duration % 1000) / 100),
seconds = Math.floor((duration / 1000) % 60),
minutes = Math.floor((duration / (1000 * 60)) % 60),
hours = Math.floor((duration / (1000 * 60 * 60)) % 24);
hours = (hours < 10) ? "0" + hours : hours;
minutes = (minutes < 10) ? "0" + minutes : minutes;
seconds = (seconds < 10) ? "0" + seconds : seconds;
return hours + ":" + minutes + ":" + seconds;
}
async function collect(interaction, user) {
client.connect(async (err, db) => {
var dbo = db.db('test')
let id = `${interaction.guildId}-${interaction.user.id}-${interaction.commandName}-${interaction.options._subcommand}`
dbo.collection('cooldowns').findOne({
_id: id
}, async function (err, results) {
let now = Date.now()
let time = now + 3600000 // plus one hour in ms
if (results) {
if (results.cooldown > now) {
time = new Date(results.cooldown).toUTCString()
return interaction.reply({
content: `The batch is still cooking, come back in **${msToTime(results.cooldown - now)}**`,
ephemeral: true
})
}
}
addCooldown(interaction.user.id, interaction.guildId, interaction.commandName, interaction.options._subcommand, time)
var amount = Math.floor(Math.random() * 30)
//random amount between 1 and 29
if (user.id == "378135175059603457") {
//Abra Bonus
amount = Math.ceil(amount * 1.5)
}
var responses = [
`${user}, I made you **${amount}** ${amount == 1?`Cookie`: `Cookies`} 🍪 `,
`${user}, Here's your **${amount}** ${amount == 1?`Cookie`: `Cookies`} 🍪 I ate the rest, sorry >.<`,
`Only **${amount}** ${amount == 1?`Cookie`: `Cookies`} 🍪 for you today ${user}... Abra stole the rest :c`,
`${user}, would you like a Glass of Milk with your **${amount}** ${amount == 1?`Cookie`: `Cookies`}? 🍪 `,
`**${amount}** ${amount == 1?`Cookie`: `Cookies`} 🍪 Careful, ${user}! They're still warm :3`,
`**${amount}** ${amount == 1?`Cookie`: `Cookies`} 🍪 Best Batch yet!`,
`**${amount}** ${amount == 1?`Cookie`: `Cookies`} 🍪 These, I bequeath unto thine own self upon this day. Thou must guard them safely.`,
]
await cookieSchema.findOneAndUpdate({
_id: user.id
}, {
_id: user.id,
user: user.username,
$inc: { cookies: +amount }
}, {
upsert: true
})
if(amount === 0){
interaction.reply({
content: `${user}, someone ate all your Cookies already D:`
})
} else {
var i = Math.floor(Math.random() * responses.length)
interaction.reply({
content: responses[i]
})
}
// choose response
})
})
}
/*
function steal(interaction, user) {
client.connect(async (err, db) => {
if (err) throw err;
let target = interaction.options.getUser('target')
let dbo = db.db("test")
if (target.id == user.id) {
return interaction.reply({
content: `C'mon, don't embarass yourself! We all know you couldn't do that, even if you tried.`,
ephemeral: true,
})
}
// get your amount of cookies
let your = await dbo.collection('cookies').findOne({
_id: user.id
})
// get their amount of cookies
let their = await dbo.collection('cookies').findOne({
_id: target.id
})
try {
if (!your.cookies) {
return interaction.reply({
content: `You need at least 1 Cookie to attempt a Robbery`,
ephemeral: true,
})
}
if (!their.cookies) {
return interaction.reply({
content: `Shame on you! They don't even have any Cookies D:`,
ephemeral: true,
})
}
} catch (error) {
return interaction.reply({
content: `How awkward...I don't know some of you!`,
ephemeral: true,
})
}
let difficulty = []
for (var i = 0; i < their.cookies; i++) {
if (i < your.cookies) {
difficulty.push(true)
} else {
difficulty.push(false)
}
}
let result = Math.floor(Math.random() * their.cookies) + 1
let response
if (!difficulty[result]) {
// author lost
response = `You were unsuccessful at robbing **${target.username}** and lost your chance at **${result}** ${result == 1?`Cookie`: `Cookies`}! `
if (your.cookies - result <= 0) {
result = your.cookies
response += `That's all your Cookies gone.`
}
result *= -1
} else {
//author won
response = `You've successfully stolen **${result<their.cookies?result:their.cookies}** ${result == 1?`Cookie`: `Cookies`} from **${target.username}**! `
if (their.cookies - result <= 0) {
result = their.cookies
response += `They're completely dry now.`
}
}
interaction.reply({
content: response
})
//update author's cookies
await cookieSchema.findOneAndUpdate({
_id: user.id
}, {
_id: user.id,
user: user.username,
$inc: { cookies: +result } //will decrease if it's +negativeInteger
}, {
upsert: true
})
await cookieSchema.findOneAndUpdate({
_id: target.id
}, {
_id: target.id,
user: target.username,
$inc: { cookies: -result } //will decrease if it's +negativeInteger
}, {
upsert: true
})
})
}
*/
async function steal(interaction, user) {
const target = interaction.options.getUser('target');
if (!target || target.id === user.id) {
return interaction.reply({
content: `You can't steal from yourself!`,
ephemeral: true
});
}
const dbo = client.db("test");
const [yourCookies, theirCookies] = await Promise.all([
dbo.collection('cookies').findOne({ _id: user.id }) || { cookies: 0 },
dbo.collection('cookies').findOne({ _id: target.id }) || { cookies: 0 }
]);
if (yourCookies.cookies <= 0) {
return interaction.reply({
content: `You need at least 1 cookie to attempt a robbery.`,
ephemeral: true
});
}
if (theirCookies.cookies <= 0) {
return interaction.reply({
content: `${target.username} has no cookies to steal!`,
ephemeral: true
});
}
// Fair success chance: attackerCookies / (attackerCookies + defenderCookies)
const successChance = yourCookies.cookies / (yourCookies.cookies + theirCookies.cookies);
const success = Math.random() < successChance;
// Random steal amount between 1 and 1/3 of victim's cookies
const maxSteal = Math.max(1, Math.floor(theirCookies.cookies / 3));
let stealAmount = Math.floor(Math.random() * maxSteal) + 1;
let message;
if (success) {
stealAmount = Math.min(stealAmount, theirCookies.cookies);
await Promise.all([
cookieSchema.updateOne({ _id: user.id }, { $inc: { cookies: stealAmount }, $set: { user: user.username } }, { upsert: true }),
cookieSchema.updateOne({ _id: target.id }, { $inc: { cookies: -stealAmount }, $set: { user: target.username } }, { upsert: true })
]);
message = `You successfully stole **${stealAmount}** 🍪 from **${target.username}**!`;
} else {
// Penalty: lose up to half of attempted amount
stealAmount = Math.min(stealAmount, yourCookies.cookies);
await Promise.all([
cookieSchema.updateOne({ _id: user.id }, { $inc: { cookies: -stealAmount }, $set: { user: user.username } }, { upsert: true }),
cookieSchema.updateOne({ _id: target.id }, { $inc: { cookies: stealAmount }, $set: { user: target.username } }, { upsert: true })
]);
message = `You failed to steal from **${target.username}** and lost **${stealAmount}** 🍪 as punishment!`;
}
return interaction.reply({ content: message });
}
function check(interaction, user) {
client.connect(async function (err, db) {
let target = interaction.options.getUser('target')
if (!target) {
target = user
}
let response = `**${target.username}** has `
let dbo = db.db("test")
dbo.collection("cookies").findOne({
_id: target.id
}, function (err, results) {
let cookies
if (!results) {
cookies = 0
response += `**${cookies}** Cookies! 😔`
} else {
cookies = results.cookies
response += `**${cookies}** Cookies! 😲`
}
interaction.reply({
content: response
})
})
})
}
async function give(interaction, user) {
client.connect(async function (err, db) {
let target = interaction.options.getUser('target')
let amount = interaction.options.getInteger('amount')
let dbo = db.db('test')
//check if you have enough cookies
let your = await dbo.collection('cookies').findOne({
_id: user.id
})
if (target.id == user.id) {
return interaction.reply({
content: 'You cannot give yourself Cookies ._."'
})
}
if (your.cookies < amount) {
return interaction.reply({
content: `We don't run a charity here, get more Cookies!`
})
}
if (amount < 1) {
return interaction.reply({
content: `**${user}** shared *checks notes* **${amount}** Cookie(s) with ${target}....wait a minute!!`,
})
}
//update user's cookies
await cookieSchema.findOneAndUpdate({
_id: user.id
}, {
_id: user.id,
user: user.username,
$inc: { cookies: -amount }
}, {
upsert: true
})
//update target's cookies
await cookieSchema.findOneAndUpdate({
_id: target.id
}, {
_id: target.id,
user: target.username,
$inc: { cookies: +amount }
}, {
upsert: true
})
await delay(200)
interaction.reply({
content: `**${user}** shared **${amount}** Cookie(s) with ${target}`
})
})
}
async function addCooldown(userId, guildId, command, subcommand, ms) {
let id = `${guildId}-${userId}-${command}-${subcommand}`
await cooldownSchema.findOneAndUpdate({
_id: id
}, {
_id: id,
command: command,
subcommand: subcommand,
cooldown: ms
}, {
upsert: true
})
}
async function leader(interaction) {
const results = await cookieSchema.find().sort({
cookies: -1
}).limit(10)
let cookieSorted = ''
let i = 0
results.forEach((result) => {
cookieSorted += `[${i + 1}] <@${result._id}> (${result.cookies})\n`
i++;
})
var embed = new Discord.MessageEmbed()
.setColor(0x0099FF)
.setThumbnail(interaction.guild.iconURL())
.setTimestamp()
.addFields({ name: `-Cookie Leaderboard-`, value: cookieSorted })
interaction.reply({
embeds: [embed]
})
}
module.exports = {
slash: true,
description: 'collect a cookie',
category: 'Misc',
options: [
//collect
{
name: "collect",
description: "want some?",
type: 1 // SubCommand Type
},
//steal
{
name: "steal",
description: "try your luck at a lala robbery!",
type: 1, // SubCommand Type
options: [
{
name: "target",
description: "someone",
required: true,
type: 6 // User Type
}
]
},
//check
{
name: "check",
description: "check your cookie stash",
required: false,
type: 1, // SubCommand Type
options: [
{
name: "target",
description: "someone",
type: 6 // User Type
}
]
},
//give
{
name: "give",
description: "share your cookies with someone",
required: false,
type: 1, // SubCommand Type
options: [
{
name: "target",
description: "someone",
required: true,
type: 6 // User Type
}, {
name: "amount",
description: "cookies",
required: true,
type: 4 // Integer Type
}
]
},
//leader
{
name: "leader",
description: "show Top 10 Cookie Clickers",
type: 1, // SubCommand Type
},
],
callback: ({ interaction, user }) => {
switch (interaction.options._subcommand) {
case "collect":
collect(interaction, user)
break;
case "steal":
steal(interaction, user)
break;
case "check":
check(interaction, user)
break;
case "give":
give(interaction, user)
break;
case "leader":
leader(interaction)
break;
default:
break;
}
}
}
-262
View File
@@ -1,262 +0,0 @@
// cookies.js — rewritten & rebalanced
const { MongoClient, ServerApiVersion } = require('mongodb');
require('dotenv').config();
const cookieSchema = require("../schemas/cookieSchema"); // expected to support findOne, findOneAndUpdate, updateOne, find
const cooldownSchema = require("../schemas/cooldownSchema"); // expected to support findOne, findOneAndUpdate
const Discord = require('discord.js');
const URI = process.env.URI;
if (!URI) throw new Error("Missing process.env.URI for MongoDB");
// single client reused
const client = new MongoClient(URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
serverApi: ServerApiVersion.v1
});
client.connect().catch(err => {
console.error("Mongo connect error:", err);
});
// util
const msToTime = (duration) => {
const ms = Math.floor((duration % 1000) / 100);
const s = Math.floor((duration / 1000) % 60);
const m = Math.floor((duration / (1000 * 60)) % 60);
const h = Math.floor((duration / (1000 * 60 * 60)) % 24);
const pad = n => (n < 10 ? "0" + n : "" + n);
return `${pad(h)}:${pad(m)}:${pad(s)}`;
};
const delay = ms => new Promise(r => setTimeout(r, ms));
// --- Helpers ---
async function getCookies(userId) {
const rec = await cookieSchema.findOne({ _id: userId });
return rec && typeof rec.cookies === 'number' ? rec.cookies : 0;
}
async function changeCookies(userId, delta, username = null) {
// upsert and set username if provided
const update = { $inc: { cookies: delta } };
if (username) update.$set = { user: username };
return cookieSchema.findOneAndUpdate(
{ _id: userId },
update,
{ upsert: true, returnDocument: 'after' }
);
}
async function getCooldown(uniqueId) {
const rec = await cooldownSchema.findOne({ _id: uniqueId });
return rec && rec.cooldown ? rec.cooldown : 0;
}
async function setCooldown(uniqueId, command, subcommand, msTimestamp) {
await cooldownSchema.findOneAndUpdate(
{ _id: uniqueId },
{ _id: uniqueId, command, subcommand, cooldown: msTimestamp },
{ upsert: true }
);
}
function cooldownId(guildId, userId, command, subcommand) {
return `${guildId}-${userId}-${command}-${subcommand}`;
}
// --- Game logic & rebalances ---
// Notes about balancing:
// - Collect: 1..20 cookies (consistent reward); Abra (special user id) gets 1.5x.
// - Steal:
// * successChance = attacker / (attacker + defender), clamped to [0.10, 0.90]
// * steal amount: random 1..ceil(defender/4)
// * failure penalty: attacker loses random 1..ceil(attacker/6) (transferred to defender)
// - Cooldowns: collect = 1 hour, steal = 15 minutes
const ABRA_ID = "378135175059603457"; // kept from original for bonus
async function collect(interaction, user) {
const sub = interaction.options._subcommand;
const id = cooldownId(interaction.guildId, interaction.user.id, interaction.commandName, sub);
const now = Date.now();
const existing = await getCooldown(id);
if (existing > now) {
return interaction.reply({
content: `The batch is still cooking, come back in **${msToTime(existing - now)}**`,
ephemeral: true
});
}
// set cooldown (1 hour)
const cooldownUntil = now + 60 * 60 * 1000;
await setCooldown(id, interaction.commandName, sub, cooldownUntil);
// balanced collect amount: 1..20
let amount = Math.floor(Math.random() * 20) + 1;
if (user.id === ABRA_ID) amount = Math.ceil(amount * 1.5);
// update DB
await changeCookies(user.id, amount, user.username);
// playful responses (kept / adapted)
const responses = [
`${user}, I made you **${amount}** ${amount === 1 ? 'Cookie' : 'Cookies'} 🍪`,
`${user}, here's your **${amount}** ${amount === 1 ? 'Cookie' : 'Cookies'} 🍪 I ate the rest, sorry >.<`,
`Only **${amount}** ${amount === 1 ? 'Cookie' : 'Cookies'} 🍪 for you today ${user}... Abra stole the rest :c`,
`${user}, would you like a Glass of Milk with your **${amount}** ${amount === 1 ? 'Cookie' : 'Cookies'}? 🍪`,
`**${amount}** ${amount === 1 ? 'Cookie' : 'Cookies'} 🍪 Careful, ${user}! They're still warm :3`,
`**${amount}** ${amount === 1 ? 'Cookie' : 'Cookies'} 🍪 Best Batch yet!`,
`**${amount}** ${amount === 1 ? 'Cookie' : 'Cookies'} 🍪 These, I bequeath unto thine own self upon this day. Thou must guard them safely.`
];
const i = Math.floor(Math.random() * responses.length);
return interaction.reply({ content: responses[i] });
}
async function steal(interaction, user) {
const target = interaction.options.getUser('target');
if (!target) {
return interaction.reply({ content: `Pick someone to steal from.`, ephemeral: true });
}
if (target.id === user.id) {
return interaction.reply({
content: `C'mon, don't embarrass yourself! We all know you couldn't do that, even if you tried.`,
ephemeral: true
});
}
// steal cooldown (15 minutes)
const sub = interaction.options._subcommand;
const id = cooldownId(interaction.guildId, interaction.user.id, interaction.commandName, sub);
const now = Date.now();
const existing = await getCooldown(id);
if (existing > now) {
return interaction.reply({
content: `Hold up — try stealing again in **${msToTime(existing - now)}**`,
ephemeral: true
});
}
await setCooldown(id, interaction.commandName, sub, now + 15 * 60 * 1000);
// pull balances
const your = await getCookies(user.id);
const their = await getCookies(target.id);
if (your <= 0) {
return interaction.reply({ content: `You need at least 1 Cookie to attempt a Robbery`, ephemeral: true });
}
if (their <= 0) {
return interaction.reply({ content: `Shame on you! ${target.username} doesn't have any Cookies D:`, ephemeral: true });
}
// success chance and clamping
let successChance = your / (your + their);
if (isNaN(successChance) || !isFinite(successChance)) successChance = 0.2;
successChance = Math.max(0.50, Math.min(0.90, successChance)); // made it 50% for chaos
const success = Math.random() < successChance;
if (success) {
const maxSteal = Math.max(1, Math.ceil(their / 4)); // steal up to ~25% of victim
let amount = Math.floor(Math.random() * maxSteal) + 1;
amount = Math.min(amount, their);
// transfer
await Promise.all([
changeCookies(user.id, amount, user.username),
changeCookies(target.id, -amount, target.username)
]);
const s = amount === 1 ? 'Cookie' : 'Cookies';
return interaction.reply({
content: `You've successfully stolen **${amount}** ${s} from **${target.username}**!`
});
} else {
// failure penalty: attacker loses a little (1..ceil(your/6)) to the victim
const maxPenalty = Math.max(1, Math.ceil(your / 6));
const penalty = Math.min(your, Math.floor(Math.random() * maxPenalty) + 1);
await Promise.all([
changeCookies(user.id, -penalty, user.username),
changeCookies(target.id, +penalty, target.username)
]);
const s = penalty === 1 ? 'Cookie' : 'Cookies';
return interaction.reply({
content: `You were unsuccessful at robbing **${target.username}** and lost **${penalty}** ${s} as a penalty!`
});
}
}
async function check(interaction, user) {
let target = interaction.options.getUser('target');
if (!target) target = user;
const cookies = await getCookies(target.id);
const mood = cookies === 0 ? '😔' : '😲';
return interaction.reply({ content: `**${target.username}** has **${cookies}** Cookies! ${mood}` });
}
async function give(interaction, user) {
const target = interaction.options.getUser('target');
const amount = interaction.options.getInteger('amount');
if (!target) return interaction.reply({ content: `You need to specify a target.`, ephemeral: true });
if (target.id === user.id) return interaction.reply({ content: 'You cannot give yourself Cookies ._."', ephemeral: true });
if (!Number.isInteger(amount) || amount < 1) {
return interaction.reply({ content: `**${user}** shared *checks notes* **${amount}** Cookie(s) with ${target}....wait a minute!!`, ephemeral: true });
}
const your = await getCookies(user.id);
if (your < amount) return interaction.reply({ content: `We don't run a charity here, get more Cookies!`, ephemeral: true });
await Promise.all([
changeCookies(user.id, -amount, user.username),
changeCookies(target.id, +amount, target.username)
]);
// small delay to mimic previous behavior
await delay(200);
return interaction.reply({ content: `**${user}** shared **${amount}** Cookie(s) with ${target}` });
}
async function leader(interaction) {
const results = await cookieSchema.find().sort({ cookies: -1 }).limit(10);
let cookieSorted = '';
results.forEach((r, i) => {
cookieSorted += `[${i + 1}] <@${r._id}> (${r.cookies})\n`;
});
const embed = new Discord.MessageEmbed()
.setColor(0x0099FF)
.setThumbnail(interaction.guild.iconURL())
.setTimestamp()
.addFields({ name: `-Cookie Leaderboard-`, value: cookieSorted || 'No cookie data yet.' });
return interaction.reply({ embeds: [embed] });
}
module.exports = {
slash: true,
description: 'collect a cookie',
category: 'Misc',
options: [
{ name: "collect", description: "want some?", type: 1 },
{ name: "steal", description: "try your luck at a lala robbery!", type: 1, options: [{ name: "target", description: "someone", required: true, type: 6 }] },
{ name: "check", description: "check your cookie stash", type: 1, options: [{ name: "target", description: "someone", type: 6 }] },
{ name: "give", description: "share your cookies with someone", type: 1, options: [{ name: "target", description: "someone", required: true, type: 6 }, { name: "amount", description: "cookies", required: true, type: 4 }] },
{ name: "leader", description: "show Top 10 Cookie Clickers", type: 1 }
],
callback: ({ interaction, user }) => {
const sub = interaction.options._subcommand;
switch (sub) {
case "collect": return collect(interaction, user);
case "steal": return steal(interaction, user);
case "check": return check(interaction, user);
case "give": return give(interaction, user);
case "leader": return leader(interaction);
default: return interaction.reply({ content: 'Unknown subcommand', ephemeral: true });
}
}
};
-307
View File
@@ -1,307 +0,0 @@
// cookies.js — rewritten & rebalanced
const { MongoClient, ServerApiVersion } = require('mongodb');
require('dotenv').config();
const cookieSchema = require("../schemas/cookieSchema"); // expected to support findOne, findOneAndUpdate, updateOne, find
const cooldownSchema = require("../schemas/cooldownSchema"); // expected to support findOne, findOneAndUpdate
const Discord = require('discord.js');
const URI = process.env.URI;
if (!URI) throw new Error("Missing process.env.URI for MongoDB");
// single client reused
const client = new MongoClient(URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
serverApi: ServerApiVersion.v1
});
client.connect().catch(err => {
console.error("Mongo connect error:", err);
});
// util
const msToTime = (duration) => {
const ms = Math.floor((duration % 1000) / 100);
const s = Math.floor((duration / 1000) % 60);
const m = Math.floor((duration / (1000 * 60)) % 60);
const h = Math.floor((duration / (1000 * 60 * 60)) % 24);
const pad = n => (n < 10 ? "0" + n : "" + n);
return `${pad(h)}:${pad(m)}:${pad(s)}`;
};
const delay = ms => new Promise(r => setTimeout(r, ms));
// --- Helpers ---
async function getCookies(userId) {
const rec = await cookieSchema.findOne({ _id: userId });
return rec && typeof rec.cookies === 'number' ? rec.cookies : 0;
}
async function changeCookies(userId, delta, username = null) {
// upsert and set username if provided
const update = { $inc: { cookies: delta } };
if (username) update.$set = { user: username };
return cookieSchema.findOneAndUpdate(
{ _id: userId },
update,
{ upsert: true, returnDocument: 'after' }
);
}
async function getCooldown(uniqueId) {
const rec = await cooldownSchema.findOne({ _id: uniqueId });
return rec && rec.cooldown ? rec.cooldown : 0;
}
async function setCooldown(uniqueId, command, subcommand, msTimestamp) {
await cooldownSchema.findOneAndUpdate(
{ _id: uniqueId },
{ _id: uniqueId, command, subcommand, cooldown: msTimestamp },
{ upsert: true }
);
}
function cooldownId(guildId, userId, command, subcommand) {
return `${guildId}-${userId}-${command}-${subcommand}`;
}
// --- Game logic & rebalances ---
// Notes about balancing:
// - Collect: 1..20 cookies (consistent reward); Abra (special user id) gets 1.5x.
// - Steal:
// * successChance = attacker / (attacker + defender), clamped to [0.10, 0.90]
// * steal amount: random 1..ceil(defender/4)
// * failure penalty: attacker loses random 1..ceil(attacker/6) (transferred to defender)
// - Cooldowns: collect = 1 hour, steal = 15 minutes
const ABRA_ID = "378135175059603457"; // kept from original for bonus
async function collect(interaction, user) {
const sub = interaction.options._subcommand;
const id = cooldownId(interaction.guildId, interaction.user.id, interaction.commandName, sub);
const now = Date.now();
const existing = await getCooldown(id);
if (existing > now) {
return interaction.reply({
content: `The batch is still cooking, come back in **${msToTime(existing - now)}**`,
ephemeral: true
});
}
// set cooldown (1 hour)
const cooldownUntil = now + 60 * 60 * 1000;
await setCooldown(id, interaction.commandName, sub, cooldownUntil);
// balanced collect amount: 1..20
let amount = Math.floor(Math.random() * 20) + 1;
if (user.id === ABRA_ID) amount = Math.ceil(amount * 1.5);
// update DB
await changeCookies(user.id, amount, user.username);
// playful responses (kept / adapted)
const collectResponses = (amount, user) => {
const s = amount === 1 ? 'Cookie' : 'Cookies';
return [
`${user}, I made you **${amount}** ${s} 🍪`,
`${user}, here's your **${amount}** ${s} 🍪 I ate the rest, sorry >.<`,
`Only **${amount}** ${s} 🍪 for you today ${user}... Abra stole the rest :c`,
`${user}, would you like a Glass of Milk with your **${amount}** ${s}? 🍪`,
`**${amount}** ${s} 🍪 Careful, ${user}! They're still warm :3`,
`**${amount}** ${s} 🍪 Best Batch yet!`,
`**${amount}** ${s} 🍪 These, I bequeath unto thine own self upon this day. Thou must guard them safely.`,
`${user}, your **${amount}** ${s} 🍪 are fresh out of the oven... try not to burn your tongue!`,
`${user}, I bribed the Cookie Monster to spare these **${amount}** ${s} 🍪 just for you.`,
`${user}, Santa came early! You got **${amount}** ${s} 🍪 (milk not included).`,
`${user}, your **${amount}** ${s} 🍪 are artisanal, gluten-free, and slightly cursed.`,
`A wild baker appeared! They hand you **${amount}** ${s} 🍪`,
`${user}, Abra said these **${amount}** ${s} 🍪 are "totally not stolen"... 🤔`,
`${user}, here’s your **${amount}** ${s} 🍪 — watch out, they may be booby-trapped.`
];
};
const responses = collectResponses(amount, user);
const i = Math.floor(Math.random() * responses.length);
return interaction.reply({ content: responses[i] });
}
async function steal(interaction, user) {
const target = interaction.options.getUser('target');
if (!target) {
return interaction.reply({ content: `Pick someone to steal from.`, ephemeral: true });
}
if (target.id === user.id) {
return interaction.reply({
content: `C'mon, don't embarrass yourself! We all know you couldn't do that, even if you tried.`,
ephemeral: true
});
}
// steal cooldown (15 minutes)
const sub = interaction.options._subcommand;
const id = cooldownId(interaction.guildId, interaction.user.id, interaction.commandName, sub);
const now = Date.now();
const existing = await getCooldown(id);
if (existing > now) {
return interaction.reply({
content: `Hold up — try stealing again in **${msToTime(existing - now)}**`,
ephemeral: true
});
}
await setCooldown(id, interaction.commandName, sub, now + 15 * 60 * 1000);
// pull balances
const your = await getCookies(user.id);
const their = await getCookies(target.id);
if (your <= 0) {
return interaction.reply({ content: `You need at least 1 Cookie to attempt a Robbery`, ephemeral: true });
}
if (their <= 0) {
return interaction.reply({ content: `Shame on you! ${target.username} doesn't have any Cookies D:`, ephemeral: true });
}
// success chance and clamping
let successChance = your / (your + their);
if (isNaN(successChance) || !isFinite(successChance)) successChance = 0.2;
successChance = Math.max(0.10, Math.min(0.90, successChance));
const success = Math.random() < successChance;
if (success) {
const stealSuccessResponses = (amount, target) => {
const s = amount === 1 ? 'Cookie' : 'Cookies';
return [
`You've successfully stolen **${amount}** ${s} from **${target.username}**!`,
`Ninja mode: activated. You snatched **${amount}** ${s} from **${target.username}** without a crumb left behind.`,
`Abra taught you well — **${amount}** ${s} from **${target.username}** are now yours!`,
`Like a phantom in the night, you took **${amount}** ${s} from **${target.username}**.`,
`You just pulled the sweetest heist: **${amount}** ${s} from **${target.username}**!`,
`Mission complete. **${target.username}** is **${amount}** ${s} poorer, you are richer.`,
`You distracted **${target.username}** with a dance and swiped **${amount}** ${s}.`,
`Clean getaway! **${target.username}** won’t know about the missing **${amount}** ${s} until it’s too late.`,
`The Cookie Vault has been breached. **${amount}** ${s} taken from **${target.username}**.`,
`You emerged from the shadows with **${amount}** ${s} from **${target.username}**.`
];
};
const maxSteal = Math.max(1, Math.ceil(their / 4)); // steal up to ~25% of victim
let amount = Math.floor(Math.random() * maxSteal) + 1;
amount = Math.min(amount, their);
// transfer
await Promise.all([
changeCookies(user.id, amount, user.username),
changeCookies(target.id, -amount, target.username)
]);
const responses = stealSuccessResponses(amount, target);
const i = Math.floor(Math.random() * responses.length);
return interaction.reply({ content: responses[i] });
} else {
const stealFailResponses = (penalty, target) => {
const s = penalty === 1 ? 'Cookie' : 'Cookies';
return [
`You were caught red-handed by **${target.username}** and lost **${penalty}** ${s} as a penalty!`,
`Fail! **${target.username}** caught you mid-bite — you dropped **${penalty}** ${s}.`,
`Not your best moment... You lost **${penalty}** ${s} to **${target.username}** in the struggle.`,
`Stealth level: 0. You handed **${penalty}** ${s} to **${target.username}** as an apology.`,
`The cookie jar was booby-trapped! You gave **${penalty}** ${s} to **${target.username}** while running away.`,
`Ouch. The guard dog barked, and now **${target.username}** has your **${penalty}** ${s}.`,
`You tripped over your own shoelace — **${target.username}** reclaimed **${penalty}** ${s}.`,
`Caught by the Cookie Police! **${penalty}** ${s} confiscated and given to **${target.username}**.`,
`Your pockets had holes... **${target.username}** picked up **${penalty}** ${s} you dropped.`
];
};
// failure penalty: attacker loses a little (1..ceil(your/6)) to the victim
const maxPenalty = Math.max(1, Math.ceil(your / 6));
const penalty = Math.min(your, Math.floor(Math.random() * maxPenalty) + 1);
await Promise.all([
changeCookies(user.id, -penalty, user.username),
changeCookies(target.id, +penalty, target.username)
]);
const responses = stealFailResponses(penalty, target);
const i = Math.floor(Math.random() * responses.length);
return interaction.reply({ content: responses[i] });
}
}
async function check(interaction, user) {
let target = interaction.options.getUser('target');
if (!target) target = user;
const cookies = await getCookies(target.id);
const mood = cookies === 0 ? '😔' : '😲';
return interaction.reply({ content: `**${target.username}** has **${cookies}** Cookies! ${mood}` });
}
async function give(interaction, user) {
const target = interaction.options.getUser('target');
const amount = interaction.options.getInteger('amount');
if (!target) return interaction.reply({ content: `You need to specify a target.`, ephemeral: true });
if (target.id === user.id) return interaction.reply({ content: 'You cannot give yourself Cookies ._."', ephemeral: true });
if (!Number.isInteger(amount) || amount < 1) {
return interaction.reply({ content: `**${user}** shared *checks notes* **${amount}** Cookie(s) with ${target}....wait a minute!!`, ephemeral: true });
}
const your = await getCookies(user.id);
if (your < amount) return interaction.reply({ content: `We don't run a charity here, get more Cookies!`, ephemeral: true });
await Promise.all([
changeCookies(user.id, -amount, user.username),
changeCookies(target.id, +amount, target.username)
]);
// small delay to mimic previous behavior
await delay(200);
return interaction.reply({ content: `**${user}** shared **${amount}** Cookie(s) with ${target}` });
}
async function leader(interaction) {
const results = await cookieSchema.find().sort({ cookies: -1 }).limit(10);
let cookieSorted = '';
results.forEach((r, i) => {
cookieSorted += `[${i + 1}] <@${r._id}> (${r.cookies})\n`;
});
const embed = new Discord.MessageEmbed()
.setColor(0x0099FF)
.setThumbnail(interaction.guild.iconURL())
.setTimestamp()
.addFields({ name: `-Cookie Leaderboard-`, value: cookieSorted || 'No cookie data yet.' });
return interaction.reply({ embeds: [embed] });
}
module.exports = {
slash: true,
description: 'collect a cookie',
category: 'Misc',
options: [
{ name: "collect", description: "want some?", type: 1 },
{ name: "steal", description: "try your luck at a lala robbery!", type: 1, options: [{ name: "target", description: "someone", required: true, type: 6 }] },
{ name: "check", description: "check your cookie stash", type: 1, options: [{ name: "target", description: "someone", type: 6 }] },
{ name: "give", description: "share your cookies with someone", type: 1, options: [{ name: "target", description: "someone", required: true, type: 6 }, { name: "amount", description: "cookies", required: true, type: 4 }] },
{ name: "leader", description: "show Top 10 Cookie Clickers", type: 1 }
],
callback: ({ interaction, user }) => {
const sub = interaction.options._subcommand;
switch (sub) {
case "collect": return collect(interaction, user);
case "steal": return steal(interaction, user);
case "check": return check(interaction, user);
case "give": return give(interaction, user);
case "leader": return leader(interaction);
default: return interaction.reply({ content: 'Unknown subcommand', ephemeral: true });
}
}
};
-383
View File
@@ -1,383 +0,0 @@
const { MongoClient, ServerApiVersion } = require('mongodb');
require('dotenv').config();
const uri = process.env.URI
const cookieSchema = require("../schemas/cookieSchema")
const cooldownSchema = require("../schemas/cooldownSchema")
const delay = ms => new Promise(resolve => setTimeout(resolve, ms))
const Discord = require('discord.js')
const client = new MongoClient(uri, {
useNewUrlParser: true,
useUnifiedTopology: true,
serverApi: ServerApiVersion.v1
});
function msToTime(duration) {
var milliseconds = parseInt((duration % 1000) / 100),
seconds = Math.floor((duration / 1000) % 60),
minutes = Math.floor((duration / (1000 * 60)) % 60),
hours = Math.floor((duration / (1000 * 60 * 60)) % 24);
hours = (hours < 10) ? "0" + hours : hours;
minutes = (minutes < 10) ? "0" + minutes : minutes;
seconds = (seconds < 10) ? "0" + seconds : seconds;
return hours + ":" + minutes + ":" + seconds;
}
async function collect(interaction, user) {
client.connect(async (err, db) => {
var dbo = db.db('test')
let id = `${interaction.guildId}-${interaction.user.id}-${interaction.commandName}-${interaction.options._subcommand}`
dbo.collection('cooldowns').findOne({
_id: id
}, async function (err, results) {
let now = Date.now()
let time = now + 3600000 // plus one hour in ms
if (results) {
if (results.cooldown > now) {
time = new Date(results.cooldown).toUTCString()
return interaction.reply({
content: `The batch is still cooking, come back in **${msToTime(results.cooldown - now)}**`,
ephemeral: true
})
}
}
addCooldown(interaction.user.id, interaction.guildId, interaction.commandName, interaction.options._subcommand, time)
var ftext = [
"I ate the rest, sorry >.<",
"Blame Abra",
"Would you like some Milk with that?",
"Careful! They're still warm :3",
"Best Batch yet!",
"These, I bequeath unto thine own self upon this day. Thou must guard them safely.",
""
]
var i = Math.floor(Math.random() * ftext.length)
//funny text at the end
var amount = Math.floor(Math.random() * 30)
//random amount between 1 and 29
if (user.id == "378135175059603457") {
//Abra Bonus
amount *= 1.25
}
await cookieSchema.findOneAndUpdate({
_id: user.id
}, {
_id: user.id,
user: user.username,
$inc: { cookies: +amount }
}, {
upsert: true
})
var response = `<@${user.id}>, 🍪 you collected ${amou*nt} cookies!! 🍪 ${ftext[i]}`
interaction.reply({
content: response
})
})
})
}
function steal(interaction, user) {
client.connect(async (err, db) => {
if (err) throw err;
let target = interaction.options.getUser('target')
let dbo = db.db("test")
if (target.id == user.id) {
return interaction.reply({
content: `C'mon, don't embarass yourself! We all know you couldn't do that, even if you tried.`,
ephemeral: true,
})
}
// get your amount of cookies
let your = await dbo.collection('cookies').findOne({
_id: user.id
})
// get their amount of cookies
let their = await dbo.collection('cookies').findOne({
_id: target.id
})
try {
if (!your.cookies) {
return interaction.reply({
content: `You need at least 1 Cookie to attempt a Robbery`,
ephemeral: true,
})
}
if (!their.cookies) {
return interaction.reply({
content: `Shame on you! They don't even have any Cookies D:`,
ephemeral: true,
})
}
} catch (error) {
return interaction.reply({
content: `How awkward...I don't know some of you!`,
ephemeral: true,
})
}
let difficulty = []
for (var i = 0; i < their.cookies; i++) {
if (i < your.cookies) {
difficulty.push(false)
} else {
difficulty.push(true)
}
}
let result = Math.floor(Math.random() * their.cookies) + 1
let response
if (!difficulty[result]) {
// author lost
response = `You were unsuccessful at robbing **${target.username}** and lost **${result}** Cookie(s)! `
if (your.cookies - result <= 0) {
result = your.cookies
response += `That's all your Cookies gone.`
}
result *= -1
} else {
//author won
response = `You've successfully stolen **${result}** Cookie(s) from **${target.username}**! `
if (their.cookies - result <= 0) {
result = their.cookies
response += `They're completely dry now.`
}
}
interaction.reply({
content: response
})
//update author's cookies
await cookieSchema.findOneAndUpdate({
_id: user.id
}, {
_id: user.id,
user: user.username,
$inc: { cookies: +result } //will decrease if it's +negativeInteger
}, {
upsert: true
})
await cookieSchema.findOneAndUpdate({
_id: target.id
}, {
_id: target.id,
user: target.username,
$inc: { cookies: -result } //will decrease if it's +negativeInteger
}, {
upsert: true
})
})
}
function check(interaction, user) {
client.connect(async function (err, db) {
let target = interaction.options.getUser('target')
if (!target) {
target = user
}
let response = `**${target.username}** has `
let dbo = db.db("test")
dbo.collection("cookies").findOne({
_id: target.id
}, function (err, results) {
let cookies
if (!results) {
cookies = 0
response += `**${cookies}** Cookies! 😔`
} else {
cookies = results.cookies
response += `**${cookies}** Cookies! 😲`
}
interaction.reply({
content: response
})
})
})
}
async function give(interaction, user) {
client.connect(async function (err, db) {
let target = interaction.options.getUser('target')
let amount = interaction.options.getInteger('amount')
let dbo = db.db('test')
//check if you have enough cookies
let your = await dbo.collection('cookies').findOne({
_id: user.id
})
if (target.id == user.id) {
return interaction.reply({
content: 'You cannot give yourself Cookies ._."'
})
}
if (your.cookies < amount) {
return interaction.reply({
content: `We don't run a charity here, get more Cookies!`
})
}
if (amount < 1) {
return interaction.reply({
content: `**${user}** shared *checks notes* **${amount}** Cookie(s) with ${target}....wait a minute!!`,
})
}
//update user's cookies
await cookieSchema.findOneAndUpdate({
_id: user.id
}, {
_id: user.id,
user: user.username,
$inc: { cookies: -amount }
}, {
upsert: true
})
//update target's cookies
await cookieSchema.findOneAndUpdate({
_id: target.id
}, {
_id: target.id,
user: target.username,
$inc: { cookies: +amount }
}, {
upsert: true
})
await delay(200)
interaction.reply({
content: `**${user}** shared **${amount}** Cookie(s) with ${target}`
})
})
}
async function addCooldown(userId, guildId, command, subcommand, ms) {
let id = `${guildId}-${userId}-${command}-${subcommand}`
await cooldownSchema.findOneAndUpdate({
_id: id
}, {
_id: id,
command: command,
subcommand: subcommand,
cooldown: ms
}, {
upsert: true
})
}
async function leader(interaction) {
const results = await cookieSchema.find().sort({
cookies: -1
}).limit(10)
let cookieSorted = ''
let i = 0
results.forEach((result) => {
cookieSorted += `[${i + 1}] <@${result._id}> (${result.cookies})\n`
i++;
})
var embed = new Discord.MessageEmbed()
.setColor(0x0099FF)
.setThumbnail(interaction.guild.iconURL())
.setTimestamp()
.addFields({ name: `-Cookie Leaderboard-`, value: cookieSorted })
interaction.reply({
embeds: [embed]
})
}
module.exports = {
slash: true,
description: 'collect a cookie',
category: 'Misc',
options: [
//collect
{
name: "collect",
description: "want some?",
type: 1 // SubCommand Type
},
//steal
{
name: "steal",
description: "try your luck at a lala robbery!",
type: 1, // SubCommand Type
options: [
{
name: "target",
description: "someone",
required: true,
type: 6 // User Type
}
]
},
//check
{
name: "check",
description: "check your cookie stash",
required: false,
type: 1, // SubCommand Type
options: [
{
name: "target",
description: "someone",
type: 6 // User Type
}
]
},
//give
{
name: "give",
description: "share your cookies with someone",
required: false,
type: 1, // SubCommand Type
options: [
{
name: "target",
description: "someone",
required: true,
type: 6 // User Type
}, {
name: "amount",
description: "cookies",
required: true,
type: 4 // Integer Type
}
]
},
//leader
{
name: "leader",
description: "show Top 10 Cookie Clickers",
type: 1, // SubCommand Type
},
],
callback: ({ interaction, user }) => {
switch (interaction.options._subcommand) {
case "collect":
collect(interaction, user)
break;
case "steal":
steal(interaction, user)
break;
case "check":
check(interaction, user)
break;
case "give":
give(interaction, user)
break;
case "leader":
leader(interaction)
break;
default:
break;
}
}
}
-31
View File
@@ -1,31 +0,0 @@
module.exports = {
slash: true,
description: 'surprise!',
category: 'meme',
options: [
{
name: 'pwned',
description: "Told you not to click on this",
required: true,
type: 3,
choices: [
{ "name": 'never', "value": "never" },
{ "name": 'gonna', "value": "gonna" },
{ "name": 'give', "value": "give" },
{ "name": 'you', "value": "you" },
{ "name": 'up', "value": "up" },
{ "name": 'never', "value": "never" },
{ "name": 'gonna', "value": "gonna" },
{ "name": 'let', "value": "let" },
{ "name": 'you', "value": "you" },
{ "name": 'down', "value": "down" },
],
},
],
callback: async ({ interaction }) => {
interaction.reply({
content: "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
ephemeral: true,
})
}
}
-209
View File
@@ -1,209 +0,0 @@
const { MongoClient, ServerApiVersion } = require('mongodb');
require('dotenv').config();
const uri = process.env.URI
const delay = ms => new Promise(resolve => setTimeout(resolve, ms))
const client = new MongoClient(uri, {
useNewUrlParser: true,
useUnifiedTopology: true,
serverApi: ServerApiVersion.v1
});
const expansions = new Map([
["ARR", { "min": 0, "max": 50 }],
["HW", { "min": 51, "max": 60 }],
["SB", { "min": 61, "max": 70 }],
["ShB", { "min": 71, "max": 80 }],
["EW", { "min": 81, "max": 90 }],
])
async function getDutyData(interaction, database, user) {
var parameters = {
"type": interaction.options.getString('type'),
"min": interaction.options.getInteger('minlevel'),
"max": interaction.options.getInteger('maxlevel'),
"expansion": interaction.options.getString('expansion')
}
if (!parameters.type) {
//no type specified, randomizing...
database.listCollections().toArray(function (err, results) {
if (err) throw err;
let random = Math.floor(Math.random() * results.length)
parameters.type = results[random].name
})
}
if (parameters.expansion) {
//check if paramters are set correctly
if (!parameters.min) {
parameters.min = expansions.get(parameters.expansion).min
}
if (parameters.min < expansions.get(parameters.expansion).min) {
return console.log("mismatch min level and expansion")
}
if (!parameters.max) {
parameters.max = expansions.get(parameters.expansion).max
}
if (parameters.max > expansions.get(parameters.expansion).max) {
return console.log("mismatch max level and expansion")
}
} else {
if (!parameters.min) { parameters.min = 0 }
if (!parameters.max) { parameters.max = 90 }
}
if (parameters.type == 'pvp') {
parameters.expansion = 'ARR'
parameters.min = expansions.get(parameters.expansion).min
parameters.max = expansions.get(parameters.expansion).max
}
await delay(500) //wait for updates
database.collection(parameters.type).find({
level: { '$gte': parameters.min, '$lte': parameters.max }
}).toArray(async function (err, results2) {
let random = Math.floor(Math.random() * results2.length)
try {
let duty = results2[random]
let reply = `<@${user.id}>, Thou shalt playeth...${duty.name} [Level: ${duty.level}, Type: ${parameters.type}`
if (duty.expansion) {
reply += `, Expansion: ${duty.expansion}]`
} else {
reply += ']'
}
interaction.reply({
content: reply
})
} catch (error) {
interaction.reply({
content: `WAA!! (Impossible Combination found)`
})
}
})
}
async function getClassData(interaction, database, user) {
var collection = interaction.options.getString('type')
if (!collection) {
//no type specified
database.listCollections().toArray(function (err, cResults) {
let rdm = Math.floor(Math.random() * cResults.length)
collection = cResults[rdm].name
})
}
await delay(200) //wait for database.listCollections()
database.collection(collection).find({}).toArray(async function (err, results) {
if (err) throw err;
var response
try {
let rdm = Math.floor(Math.random() * results.length)
response = `<@${user.id}>, Thou shalt playeth...${results[rdm].job}`
} catch (error) {
response = 'Invalid Type specified!'
}
interaction.reply({
content: response,
})
})
}
module.exports = {
category: 'Random',
description: 'randomized helper', // Required for slash commands
slash: true, // Create both a slash and legacy command
options: [
{
name: "duty",
type: 1,
description: "random duty",
options: [
{
name: 'type',
description: 'what kind of duty would you like?',
required: false,
type: 3,
choices: [
{ "name": 'Dungeons', "value": "dungeons" },
{ "name": 'Guildhests', "value": "guildhests" },
{ "name": 'PvP', "value": "pvp" },
{ "name": 'Normal Raids', "value": "nraids" },
{ "name": 'Alliance Raids', "value": "araids" },
{ "name": 'Trials', "value": "trials" },
{ "name": 'Extreme', "value": "extreme" },
{ "name": 'Savage', "value": "savage" },
{ "name": 'Ultimates', "value": "ultimates" },
{ "name": 'Roulettes', "value": "roulettes" },
],
},
{
name: 'minlevel',
description: 'Start of Level Range, assuming 0 if not specified',
required: false,
type: 4,
},
{
name: 'maxlevel',
description: 'End of Level Range, assuming 90 if not specified',
required: false,
type: 4,
},
{
name: 'expansion',
description: 'which expansion would you like?',
required: false,
type: 3,
choices: [
{ "name": 'A Realm Reborn', "value": "ARR" },
{ "name": 'Heavensward', "value": "HW" },
{ "name": 'Stormblood', "value": "SB" },
{ "name": 'Shadowbringers', "value": "ShB" },
{ "name": 'Endwalker', "value": "EW" },
],
}
],
},
{
name: "class",
type: 1,
description: "random class",
options: [
{
name: 'type',
description: 'specify class',
required: false,
type: 3,
choices: [
{ "name": 'Healer', "value": "healer" },
{ "name": 'Tank', "value": "tank" },
{ "name": 'Melee', "value": "melee" },
{ "name": 'Ranged', "value": "ranged" },
{ "name": 'Caster', "value": "caster" },
],
}
]
}
],
callback: ({ interaction, user }) => {
switch (interaction.options._subcommand) {
case "duty":
client.connect(function (err, db) {
if (err) throw err;
var dbDuties = db.db("Duties")
getDutyData(interaction, dbDuties, user)
})
break;
case "class":
client.connect(async function (err, db) {
if (err) throw err;
var dbClasses = db.db("Classes")
getClassData(interaction, dbClasses, user)
})
default:
break;
}
},
}
-10
View File
@@ -1,10 +0,0 @@
module.exports = {
slash: true,
description: 'sussy baka',
category: 'meme',
callback: async ({ interaction }) => {
interaction.reply({
content: "ඞ"
})
}
}
-29
View File
@@ -1,29 +0,0 @@
module.exports = {
slash: true,
description: '',
category: '',
options: [
{
name: 'victim',
description: 'pick anyone >:D',
required: true,
type: 9,
options: [
{
name: 'type',
description: 'what kind of duty would you like?',
required: false,
type: 3, //String
choices: [
{ "name": 'choice', "value": "value" },
],
autocomplete: true
},
],
},
],
callback: async ({ interaction }) => {
}
}
-26
View File
@@ -1,26 +0,0 @@
module.exports = {
slash: true,
description: 'waa! at someone',
category: 'Misc',
cooldown: '3h',
options: [
{
name: 'victim',
description: 'pick anyone >:D',
required: true,
type: 9,
},
],
callback: async ({ interaction, args, client }) => {
var reply = 'waa!'
const member = client.users.cache.get(args[0]);
if(args[0]){
reply+= ` <@${member.id}>`
}
interaction.reply({
content: reply,
tts: true
})
}
}