separated commands from message event and added state control to them

This commit is contained in:
DeSqBlocki
2025-02-13 19:45:13 +01:00
parent fe0c937fb2
commit 5b07182020
6 changed files with 217 additions and 79 deletions
+44
View File
@@ -0,0 +1,44 @@
const { mClient, tClient } = require("../..");
module.exports = {
name: 'Command/donate',
once: false,
async execute(channel, userstate, message, self) {
const db = mClient.db('channels')
const coll = db.collection(channel)
const command = await coll.findOne({ name: 'donate' })
// create if not exists
if (!command) {
await coll.insertOne({
name: 'donate',
enabled: false // default
})
}
if (!command.enabled){ return }
async function sendDonationAd() {
// Function to send static donate ad
const links = [
"https://bit.ly/heltwittergoals",
"https://bit.ly/donatetohel",
"http://bit.ly/donothon_goals"
];
const messages = [
"Hel is currently celebrating her birthday with a donathon!",
`You can see goals and incentives here: ${links[0]}`,
`You can donate here: ${links[1]}`,
`Terms, conditions, rules and how rewards work are found here: ${links[2]}`,
"All donations and gifts are greatly appreciated, but please do so responsibly!"
];
for (const message of messages) {
await tClient.say(channel, message);
}
}
sendDonationAd()
}
}