shoddy sex impl
This commit is contained in:
parent
bee954f15f
commit
2f6f415c0d
56
src/index.ts
56
src/index.ts
|
@ -6,32 +6,22 @@ import { initializeCounter } from './lib/counter';
|
||||||
|
|
||||||
const morningHour = 7;
|
const morningHour = 7;
|
||||||
const eveningHour = 20;
|
const eveningHour = 20;
|
||||||
|
const sexHour = 17;
|
||||||
|
|
||||||
function getNextMorning() {
|
function getNextTime(hour: number, randomMinute = true) {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const next = new Date();
|
const next = new Date();
|
||||||
if (now.getUTCHours() >= morningHour) {
|
if (now.getUTCHours() >= hour) {
|
||||||
next.setTime(next.getTime() + 1000 * 60 * 60 * 24);
|
next.setTime(next.getTime() + 1000 * 60 * 60 * 24);
|
||||||
}
|
}
|
||||||
next.setUTCHours(morningHour);
|
next.setUTCHours(hour);
|
||||||
next.setUTCMinutes(Math.floor(Math.random() * 60));
|
if (randomMinute) {
|
||||||
next.setUTCSeconds(Math.floor(Math.random() * 60));
|
next.setUTCMinutes(Math.floor(Math.random() * 60));
|
||||||
|
next.setUTCSeconds(Math.floor(Math.random() * 60));
|
||||||
console.log('next morning set to ' + next);
|
} else {
|
||||||
|
next.setUTCMinutes(0);
|
||||||
return next.getTime();
|
next.setUTCSeconds(0);
|
||||||
}
|
|
||||||
function getNextNight() {
|
|
||||||
const now = new Date();
|
|
||||||
const next = new Date();
|
|
||||||
if (now.getUTCHours() >= eveningHour) {
|
|
||||||
next.setTime(next.getTime() + 1000 * 60 * 60 * 24);
|
|
||||||
}
|
}
|
||||||
next.setUTCHours(eveningHour);
|
|
||||||
next.setUTCMinutes(Math.floor(Math.random() * 60));
|
|
||||||
next.setUTCSeconds(Math.floor(Math.random() * 60));
|
|
||||||
|
|
||||||
console.log('next night set to ' + next);
|
|
||||||
|
|
||||||
return next.getTime();
|
return next.getTime();
|
||||||
}
|
}
|
||||||
|
@ -39,6 +29,7 @@ function getNextNight() {
|
||||||
interface DaytimeSchedule {
|
interface DaytimeSchedule {
|
||||||
morning: number;
|
morning: number;
|
||||||
night: number;
|
night: number;
|
||||||
|
sex: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
let next: DaytimeSchedule;
|
let next: DaytimeSchedule;
|
||||||
|
@ -49,10 +40,14 @@ function save() {
|
||||||
|
|
||||||
if (fs.existsSync('./next.json')) {
|
if (fs.existsSync('./next.json')) {
|
||||||
next = JSON.parse(fs.readFileSync('./next.json', 'utf8'));
|
next = JSON.parse(fs.readFileSync('./next.json', 'utf8'));
|
||||||
|
if (!next.morning) next.morning = getNextTime(morningHour);
|
||||||
|
if (!next.night) next.night = getNextTime(eveningHour);
|
||||||
|
if (!next.sex) next.sex = getNextTime(sexHour, false);
|
||||||
} else {
|
} else {
|
||||||
next = {
|
next = {
|
||||||
morning: getNextMorning(),
|
morning: getNextTime(morningHour),
|
||||||
night: getNextNight()
|
night: getNextTime(eveningHour),
|
||||||
|
sex: getNextTime(sexHour, false)
|
||||||
};
|
};
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
@ -147,6 +142,13 @@ const night = [
|
||||||
'<a:slugloafspin:1012777725301370920> Good Night!! <a:slugloafspin:1012777725301370920>',
|
'<a:slugloafspin:1012777725301370920> Good Night!! <a:slugloafspin:1012777725301370920>',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const sexRole = '<@&1088023310882836500>';
|
||||||
|
const sexMessages = [
|
||||||
|
'https://cdn.discordapp.com/attachments/838764449899872356/1088024173051387974/sex_time.png',
|
||||||
|
'sex. NO sleeping'
|
||||||
|
];
|
||||||
|
const sexChannel = '789023763396165633';
|
||||||
|
|
||||||
bot.on('ready', async () => {
|
bot.on('ready', async () => {
|
||||||
initializeCounter();
|
initializeCounter();
|
||||||
|
|
||||||
|
@ -156,7 +158,7 @@ bot.on('ready', async () => {
|
||||||
// console.log(current, next.morning, next.night);
|
// console.log(current, next.morning, next.night);
|
||||||
|
|
||||||
if (current > next.morning && !disableDaytimeAnnouncements) {
|
if (current > next.morning && !disableDaytimeAnnouncements) {
|
||||||
next.morning = getNextMorning();
|
next.morning = getNextTime(morningHour);
|
||||||
channels.forEach(c => {
|
channels.forEach(c => {
|
||||||
bot.channels.fetch(c)
|
bot.channels.fetch(c)
|
||||||
.then(channel => (channel as Discord.TextBasedChannel).send(morning[Math.floor(Math.random() * morning.length)]))
|
.then(channel => (channel as Discord.TextBasedChannel).send(morning[Math.floor(Math.random() * morning.length)]))
|
||||||
|
@ -165,7 +167,7 @@ bot.on('ready', async () => {
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
if (current > next.night && !disableDaytimeAnnouncements) {
|
if (current > next.night && !disableDaytimeAnnouncements) {
|
||||||
next.night = getNextNight();
|
next.night = getNextTime(eveningHour);
|
||||||
channels.forEach(c => {
|
channels.forEach(c => {
|
||||||
bot.channels.fetch(c)
|
bot.channels.fetch(c)
|
||||||
.then(channel => (channel as Discord.TextBasedChannel).send(night[Math.floor(Math.random() * night.length)]))
|
.then(channel => (channel as Discord.TextBasedChannel).send(night[Math.floor(Math.random() * night.length)]))
|
||||||
|
@ -173,6 +175,12 @@ bot.on('ready', async () => {
|
||||||
});
|
});
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
if (current > next.sex && !disableDaytimeAnnouncements) {
|
||||||
|
next.sex = getNextTime(sexHour, false);
|
||||||
|
bot.channels.fetch(sexChannel)
|
||||||
|
.then(channel => (channel as Discord.TextBasedChannel).send(sexRole + ' ' + sexMessages[Math.floor(Math.random() * sexMessages.length)]))
|
||||||
|
.catch(err => console.log('couldnt find channel ' + sexChannel + ': ' + err));
|
||||||
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
bot.commands = new Discord.Collection();
|
bot.commands = new Discord.Collection();
|
||||||
|
|
Loading…
Reference in New Issue