Added timed messages

This commit is contained in:
2024-10-27 11:43:31 +01:00
parent 60644c2f78
commit ce1892eb82
5 changed files with 105 additions and 3 deletions

View File

@ -96,8 +96,8 @@ module.exports = client => {
{text: "[help"},
{text: "[help"},
{text: "Like ur cut G"},
{text: "une dernière fois Daft Punk", type: "LISTENING"}
{text: "Doki doki blue skies"}
{text: "une dernière fois Daft Punk", type: "LISTENING"},
{text: "Doki doki blue skies"},
]
var status, lastStatus = ""

43
handlers/timedMessages.js Normal file
View File

@ -0,0 +1,43 @@
const { readdirSync } = require("fs");
const ascii = require("ascii-table");
let table = new ascii("Timed messages");
table.setHeading("Name", "Load status");
module.exports = (client) => {
try{
const timesMessagesFiles = readdirSync(`./timedMessages/`).filter((file) => file.endsWith(".js")); // Get all the js files
for (let file of timesMessagesFiles) {
let pull = require(`../timedMessages/${file}`);
if (pull.name && pull.time) {
([hour, second] = pull.time.split(":"))
function getNextRunETA(hour, second) {
var todayDate = new Date();
var nextRunDate = new Date();
nextRunDate.setHours(hour, second, 0)
if (nextRunDate <= todayDate) {
nextRunDate.setDate(todayDate.getDate() + 1)
}
return nextRunDate - todayDate;
}
function runMessage(hour, second) {
pull.run(client)
setTimeout(runMessage, getNextRunETA(hour, second), hour, second)
}
setTimeout(runMessage, getNextRunETA(hour, second), hour, second)
table.addRow(pull.name, "Ready");
} else {
table.addRow(file, `error->missing a name or time or is not a string.`);
continue;
}
}
console.log(table.toString().cyan);
}catch (e){
console.log(String(e.stack).bgRed)
}
};
/** Template by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template */

View File

@ -28,7 +28,7 @@ client.keywords = new Discord.Collection(); // all the keywords the bot will rea
client.dmCommands = new Discord.Collection(); // all the private commands
//Loading files, with the client variable like Command Handler, Event Handler, ...
["command", "dmCommand", "events", "keywords"].forEach(handler => {
["command", "dmCommand", "events", "keywords", "timedMessages"].forEach(handler => {
require(`./handlers/${handler}`)(client);
});

30
timedMessages/hellcase.js Normal file
View File

@ -0,0 +1,30 @@
const { MessageEmbed, Message } = require("discord.js");
const config = require("../botconfig/config.json");
const ee = require("../botconfig/embed.json");
const { sendNinluc } = require("../handlers/functions");
const RAPPEL_CHANNEL_ID = "1296051297262370866";
module.exports = {
name: "Hellcase",
time: "21:30",
run: async (client) => {
try {
client.channels.fetch(RAPPEL_CHANNEL_ID)
.then(channel => channel.send({
embeds: [
new MessageEmbed()
.setColor(ee.color)
.setFooter({ text: ee.footertext, iconURL: ee.footericon })
.setTitle(`Rappel : Caisse gratuite Hellcase`)
.setDescription("[Hellcase](https://hellcase.com/)")
],
})
);
} catch (e) {
console.log(String(e.stack).bgRed);
}
},
};
/** Template by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template */

29
timedMessages/snap.js Normal file
View File

@ -0,0 +1,29 @@
const { MessageEmbed, Message } = require("discord.js");
const config = require("../botconfig/config.json");
const ee = require("../botconfig/embed.json");
const { sendNinluc } = require("../handlers/functions");
const RAPPEL_CHANNEL_ID = "1296051297262370866";
module.exports = {
name: "Shop Marvel Snap",
time: "21:00",
run: async (client) => {
try {
client.channels.fetch(RAPPEL_CHANNEL_ID)
.then(channel => channel.send({
embeds: [
new MessageEmbed()
.setColor(ee.color)
.setFooter({ text: ee.footertext, iconURL: ee.footericon })
.setTitle(`Rappel : Shop Marvel Snap`)
],
})
);
} catch (e) {
console.log(String(e.stack).bgRed);
}
},
};
/** Template by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template */