why am im getting error on my javascript
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const BEG = 30;
let message = context.params.event.content;
let start = 0;
let begPrompts = [5, 1000, 8, 100, 70, 430]; //can be changed
let begChoice = Math.floor(Math.random() * begPrompts.length);
let beg = begPrompts[begChoice];
let beggarPrompts = [
'Oh you poor little beggar heres your coins',
'Im not that rich but heres coins',
'Im poor too but heres some coins',
]; //can be changed
let beggarChoice = Math.floor(Math.random() * beggarPrompts.length);
let beggar = beggarPrompts[beggarChoice];
let result = await lib.utils.kv['@0.1.16'].get({
key: `BALANCE-${context.params.event.author.id}`,
defaultValue: `${start}`,
});
let inv = await lib.utils.kv['@0.1.16'].get({
key: `INV-${context.params.event.author.id}`,
defaultValue: ``,
});
if (message.toLowerCase() === `${process.env.prefix}beg`) {
let key = `beg${context.params.event.author.id}`; //to this
let lastUsedAt = await lib.utils.kv['@0.1.16'].get({
key: key,
});
if (lastUsedAt) {
let elapsedTimeSeconds = (new Date() - new Date(lastUsedAt)) / 1000;
let timeRemaining = BEG - elapsedTimeSeconds;
let timeRemainingHours = Math.floor(timeRemaining / 3600);
let timeRemainingHoursString = timeRemainingHours
? timeRemainingHours + (timeRemainingHours === 1 ? ' hour' : ' hours')
: '';
let timeRemainingMinutes = Math.floor((timeRemaining % 3600) / 60);
let timeRemainingMinutesString = timeRemainingMinutes
? timeRemainingMinutes +
(timeRemainingMinutes === 1 ? ' minute' : ' minutes')
: '';
let timeRemainingSeconds = Math.floor(timeRemaining % 60);
let timeRemainingSecondsString = timeRemainingSeconds
? timeRemainingSeconds +
(timeRemainingSeconds === 1 ? ' second' : ' seconds')
: '';
let timeRemainingString = [
timeRemainingHoursString,
timeRemainingMinutesString,
timeRemainingSecondsString,
]
.filter((v) => !!v)
.join(', ');
return lib.discord.channels['@0.2.1'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: ``,
embed: {
title: `Spam isn't cool`,
description: `Stop begging so much, it makes you look like a little baby.\n You can have more coins in **${timeRemainingString}** \n The default cooldown is \`${BEG}s\``,
},
});
} else {
await lib.utils.kv['@0.1.16'].set({
key: key,
value: new Date().toISOString(),
ttl: BEG,
});
await lib.utils.kv['@0.1.16'].set({
key: `BALANCE-${context.params.event.author.id}`,
value: result + beg,
});
await lib.discord.channels[`@0.1.1`].messages.create({
channel_id: context.params.event.channel_id,
content: ``,
embed: {
title: `${beggar}`,
description: `You got a total of **⏣${parseInt(beg).toLocaleString('en-US')}** from begging!`,
color: 0x2add4d, // may be changed
},
});
}
}