74 lines
1.8 KiB
TypeScript
74 lines
1.8 KiB
TypeScript
import config from "config";
|
|
import client from "lib/client";
|
|
import { getRandomInt } from "lib/utils";
|
|
import { greetContent, sleepContent } from "./greeting.components.ts";
|
|
|
|
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() {
|
|
client.user?.setActivity("guten morgen! :3", { type: 4 });
|
|
console.log("set activity: awake");
|
|
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: this.getContent(false) });
|
|
}
|
|
}
|
|
|
|
async sleep() {
|
|
client.user?.setActivity("zzzzZZ..", { type: 4 });
|
|
console.log("set activity: asleep");
|
|
client.user?.setPresence({
|
|
status: "dnd",
|
|
});
|
|
|
|
const channels = client.channels;
|
|
|
|
const channel = channels.cache.get(config.discord.channelId);
|
|
|
|
if (channel?.isTextBased && channel?.isSendable()) {
|
|
await channel.send({ content: this.getContent(true) });
|
|
}
|
|
}
|
|
|
|
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) {
|
|
if (asleep) {
|
|
return sleepContent[getRandomInt(0, sleepContent.length - 1)];
|
|
}
|
|
return greetContent[getRandomInt(0, greetContent.length - 1)];
|
|
}
|
|
}
|