nodbot/dot-commands/joint.js

37 lines
1.4 KiB
JavaScript
Raw Permalink Normal View History

2022-06-20 23:00:42 +00:00
const fn = require('../functions.js');
const { emoji } = require('../strings.json');
module.exports = {
name: 'joint',
description: 'Send a random weed-themed phrase.',
usage: '.joint',
alias: ['bong', 'blunt', 'bowl', 'pipe', 'dab', 'vape', 'dabs', 'shatter', 'edible', 'edibles', 'doobie', 'spliff', 'gummy', 'gummies', 'hash', 'toke', 'big doinks'],
2022-06-20 23:00:42 +00:00
execute(message, commandData) {
let joints = [];
2023-12-14 15:54:05 +00:00
// Create a simple array of the joint texts
2022-06-20 23:00:42 +00:00
for (const entry of message.client.joints.map(joint => joint.content)) {
joints.push(entry);
}
2023-12-14 15:54:05 +00:00
// Generate a random number between 0 and the length of the joints array
let randIndex = Math.floor(Math.random() * joints.length);
2023-12-14 15:54:05 +00:00
// Grab the joint text from the array
let joint = joints[randIndex];
// Check if the joint has already been smoked
while (message.client.roaches.has(joint)) {
2023-12-14 15:54:05 +00:00
// Regenerate a random number and recheck
randIndex = Math.floor(Math.random() * joints.length);
joint = joints[randIndex];
}
// Send the joint
2022-06-20 23:00:42 +00:00
message.reply(`${joints[randIndex]} ${emoji.joint}`);
// Check how full the roach collection is
if (message.client.roaches.size / joints.length >= 0.85) {
// If the roach collection is 85% of the joints collection
// Empty it out
message.client.roaches.clear();
}
// Add the joint to the roach collection
message.client.roaches.set(joint, "baked");
2022-06-20 23:00:42 +00:00
}
}