mirror of
https://github.com/Ninluc/Dat_Boi.git
synced 2025-08-09 23:26:13 +02:00
Added timed messages
This commit is contained in:
@ -96,8 +96,8 @@ module.exports = client => {
|
|||||||
{text: "[help"},
|
{text: "[help"},
|
||||||
{text: "[help"},
|
{text: "[help"},
|
||||||
{text: "Like ur cut G"},
|
{text: "Like ur cut G"},
|
||||||
{text: "une dernière fois Daft Punk", type: "LISTENING"}
|
{text: "une dernière fois Daft Punk", type: "LISTENING"},
|
||||||
{text: "Doki doki blue skies"}
|
{text: "Doki doki blue skies"},
|
||||||
]
|
]
|
||||||
var status, lastStatus = ""
|
var status, lastStatus = ""
|
||||||
|
|
||||||
|
43
handlers/timedMessages.js
Normal file
43
handlers/timedMessages.js
Normal 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 */
|
2
index.js
2
index.js
@ -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
|
client.dmCommands = new Discord.Collection(); // all the private commands
|
||||||
|
|
||||||
//Loading files, with the client variable like Command Handler, Event Handler, ...
|
//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);
|
require(`./handlers/${handler}`)(client);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
30
timedMessages/hellcase.js
Normal file
30
timedMessages/hellcase.js
Normal 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
29
timedMessages/snap.js
Normal 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 */
|
Reference in New Issue
Block a user