added "newYear"

This commit is contained in:
moriese 2025-01-01 18:53:33 +01:00
parent e7cd840c48
commit b46dc8d3ae
5 changed files with 53 additions and 9 deletions

View File

@ -4,6 +4,18 @@ import { getRandomInt } from "lib/utils";
import { greetContent, sleepContent } from "./greeting.components.ts"; import { greetContent, sleepContent } from "./greeting.components.ts";
export class GreetingService { export class GreetingService {
async customMessage() {
console.log("custom message");
const channels = client.channels;
const channel = channels.cache.get(config.discord.channelId);
if (channel?.isTextBased && channel?.isSendable()) {
await channel.send({ content: " " });
}
}
async greet() { async greet() {
client.user?.setActivity("guten morgen! :3", { type: 4 }); client.user?.setActivity("guten morgen! :3", { type: 4 });
console.log("set activity: awake"); console.log("set activity: awake");
@ -36,6 +48,22 @@ export class GreetingService {
} }
} }
async newYear() {
client.user?.setActivity("frohes neues! :)", { type: 4 });
console.log("set activity: happy new Year");
client.user?.setPresence({
status: "online",
});
/*const channels = client.channels;
const channel = channels.cache.get(config.discord.channelId);
if (channel?.isTextBased && channel?.isSendable()) {
await channel.send({ content: "frohes neues! @everyone" });
}*/
}
getContent(asleep: boolean) { getContent(asleep: boolean) {
if (asleep) { if (asleep) {
return sleepContent[getRandomInt(0, sleepContent.length - 1)]; return sleepContent[getRandomInt(0, sleepContent.length - 1)];

View File

@ -13,6 +13,7 @@ new CronJob(
true, // start true, // start
"Europe/Berlin", // timeZone "Europe/Berlin", // timeZone
); );
// job.start() is optional here because of the fourth parameter set to true.
new CronJob( new CronJob(
"0 30 22 * * *", "0 30 22 * * *",
@ -24,3 +25,14 @@ new CronJob(
true, true,
"Europe/Berlin", "Europe/Berlin",
); );
new CronJob(
"0 0 0 1 1 *",
async () => {
console.log("happy new year");
await greetingService.newYear();
},
null,
true,
"Europe/Berlin",
);

View File

@ -4,7 +4,7 @@ import { WaterMeService } from "actions/waterMe/waterMe.service";
const waterMeService = new WaterMeService(); const waterMeService = new WaterMeService();
new CronJob( new CronJob(
"0 * * * * *", // cronTime "0 0 20 * * *", // cronTime
async () => { async () => {
console.log("isThirsty()"); console.log("isThirsty()");
await waterMeService.isThirsty(); await waterMeService.isThirsty();

View File

@ -1,11 +1,11 @@
const test = true; const test = false;
export default { export default {
discord: { discord: {
channelId: channelId:
(test (test
? process.env.DISCORD_TEST_CHANNEL_ID ? process.env.DISCORD_TEST_CHANNEL_ID
: process.env.DISCORD_CHANNEL_ID) || "", : process.env.DISCORD_CHANNEL_ID_BOT) || "",
applicationId: process.env.DISCORD_APPLICATION_ID || "", applicationId: process.env.DISCORD_APPLICATION_ID || "",
token: process.env.DISCORD_TOKEN || "", token: process.env.DISCORD_TOKEN || "",
}, },

View File

@ -29,11 +29,7 @@ export default class DiscordController extends EventEmitter {
this.helpService = new HelpService(); this.helpService = new HelpService();
// log when running // log when running
client.once("ready", async () => { client.once("ready", async () => {
client.user?.setActivity("HALLOOO HOERT IHR MICH?", { type: 4 }); this.setActivity();
console.log("set activity");
client.user?.setPresence({
status: "idle",
});
/*const channels = client.channels; /*const channels = client.channels;
const channel = channels.cache.get(config.discord.channelId); const channel = channels.cache.get(config.discord.channelId);
@ -49,6 +45,14 @@ export default class DiscordController extends EventEmitter {
client.on("interactionCreate", this.handleInteraction.bind(this)); client.on("interactionCreate", this.handleInteraction.bind(this));
} }
async setActivity() {
client.user?.setActivity("frohes neues :3", { type: 4 });
console.log("set activity");
client.user?.setPresence({
status: "online",
});
}
async init() { async init() {
await this.discordService.init(); await this.discordService.init();
} }