-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpickup.js
29 lines (25 loc) · 937 Bytes
/
pickup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const fs = require('fs');
const path = require('path');
const pickupLines = require('./pickup-lines.json'); // Adjust the path as needed
async function execute(interaction) {
try {
let pickupLine = '';
const mentionedUser = interaction.options.get('user');
if (mentionedUser) {
pickupLine = pickupLines.pickupLines[Math.floor(Math.random() * pickupLines.pickupLines.length)];
pickupLine = pickupLine.replace(/@user/g, `<@${mentionedUser.value}>`);
} else {
const randomIndex = Math.floor(Math.random() * pickupLines.pickupLines.length);
pickupLine = pickupLines.pickupLines[randomIndex];
}
interaction.reply(pickupLine);
} catch (error) {
console.error('Error fetching pickup line:', error);
interaction.reply('Oops! Something went wrong while fetching a pickup line.');
}
}
module.exports = {
execute,
name: 'pickup',
description: 'Sends a lovely pickup line',
};