small update with changes i did in the last 6 months
All checks were successful
release-tag / release-image (push) Successful in 38s
All checks were successful
release-tag / release-image (push) Successful in 38s
This commit is contained in:
@@ -25,7 +25,7 @@ export class DmService {
|
|||||||
await client.users.send(member, content);
|
await client.users.send(member, content);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const channels = client.channels;
|
const channels = client.channels;
|
||||||
const channel = channels.cache.get(config.discord.channelIdNotification);
|
const channel = channels.cache.get(config.discord.channelIdLog);
|
||||||
if (channel?.isTextBased() && channel?.isSendable()) {
|
if (channel?.isTextBased() && channel?.isSendable()) {
|
||||||
await channel.send(`konnte keine private nachricht an <@${member.user.id}> senden`);
|
await channel.send(`konnte keine private nachricht an <@${member.user.id}> senden`);
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ export class DmService {
|
|||||||
await client.users.send(member, dmWelcomeContent);
|
await client.users.send(member, dmWelcomeContent);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const channels = client.channels;
|
const channels = client.channels;
|
||||||
const channel = channels.cache.get(config.discord.channelIdNotification);
|
const channel = channels.cache.get(config.discord.channelIdLog);
|
||||||
if (channel?.isTextBased() && channel?.isSendable()) {
|
if (channel?.isTextBased() && channel?.isSendable()) {
|
||||||
await channel.send(`konnte keine private nachricht an <@${member.user.id}> senden`);
|
await channel.send(`konnte keine private nachricht an <@${member.user.id}> senden`);
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ export class DmService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const channels = client.channels;
|
const channels = client.channels;
|
||||||
const channel = channels.cache.get(config.discord.channelIdNotification);
|
const channel = channels.cache.get(config.discord.channelIdLog);
|
||||||
if (channel?.isTextBased() && channel?.isSendable()) {
|
if (channel?.isTextBased() && channel?.isSendable()) {
|
||||||
await channel.send(context);
|
await channel.send(context);
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ export class DmService {
|
|||||||
await client.users.send(member, dmAcceptedContent);
|
await client.users.send(member, dmAcceptedContent);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const channels = client.channels;
|
const channels = client.channels;
|
||||||
const channel = channels.cache.get(config.discord.channelIdNotification);
|
const channel = channels.cache.get(config.discord.channelIdLog);
|
||||||
if (channel?.isTextBased() && channel?.isSendable()) {
|
if (channel?.isTextBased() && channel?.isSendable()) {
|
||||||
await channel.send(`konnte keine private nachricht an <@${member.user.id}> senden`);
|
await channel.send(`konnte keine private nachricht an <@${member.user.id}> senden`);
|
||||||
}
|
}
|
||||||
@@ -94,7 +94,7 @@ export class DmService {
|
|||||||
client.users.send(member, contentRoleMentionDm);
|
client.users.send(member, contentRoleMentionDm);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const channels = client.channels;
|
const channels = client.channels;
|
||||||
const channel = channels.cache.get(config.discord.channelIdNotification);
|
const channel = channels.cache.get(config.discord.channelIdLog);
|
||||||
if (channel?.isTextBased() && channel?.isSendable()) {
|
if (channel?.isTextBased() && channel?.isSendable()) {
|
||||||
await channel.send(`konnte keine private nachricht an <@${member.user.id}> senden`);
|
await channel.send(`konnte keine private nachricht an <@${member.user.id}> senden`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { MedicationService } from "actions/medication/medication.service";
|
|||||||
|
|
||||||
const medicationService = new MedicationService();
|
const medicationService = new MedicationService();
|
||||||
|
|
||||||
new CronJob(
|
/*new CronJob(
|
||||||
"0 0 19 * * *", // cronTime
|
"0 0 19 * * *", // cronTime
|
||||||
async () => {
|
async () => {
|
||||||
console.log("askMedication()");
|
console.log("askMedication()");
|
||||||
@@ -12,4 +12,4 @@ new CronJob(
|
|||||||
null, // onComplete
|
null, // onComplete
|
||||||
true, // start
|
true, // start
|
||||||
"Europe/Berlin", // timeZone
|
"Europe/Berlin", // timeZone
|
||||||
);
|
);*/
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
export default {
|
export default {
|
||||||
discord: {
|
discord: {
|
||||||
version: 250602.10,
|
version: 251218,
|
||||||
// avocadi
|
// avocadi
|
||||||
serverID: process.env.DISCORD_SERVER_ID || "",
|
serverID: process.env.DISCORD_SERVER_ID || "",
|
||||||
// texxt channel
|
// text channel
|
||||||
|
channelIdBump: process.env.DISCORD_CHANNEL_ID_BUMP || "",
|
||||||
channelIdBot: process.env.DISCORD_CHANNEL_ID_BOT || "",
|
channelIdBot: process.env.DISCORD_CHANNEL_ID_BOT || "",
|
||||||
channelIdFeedback: process.env.DISCORD_CHANNEL_ID_FEEDBACK || "",
|
channelIdFeedback: process.env.DISCORD_CHANNEL_ID_FEEDBACK || "",
|
||||||
channelIdNotification: process.env.DISCORD_CHANNEL_ID_NOTIFICATION || "",
|
channelIdLog: process.env.DISCORD_CHANNEL_ID_NOTIFICATION || "",
|
||||||
channelIdWelcome: process.env.DISCORD_CHANNEL_ID_WELCOME || "",
|
channelIdWelcome: process.env.DISCORD_CHANNEL_ID_WELCOME || "",
|
||||||
channelIdRules: process.env.DISCORD_CHANNEL_ID_RULE || "",
|
channelIdRules: process.env.DISCORD_CHANNEL_ID_RULE || "",
|
||||||
channelIdNews: process.env.DISCORD_CHANNEL_ID_NEWS || "",
|
channelIdNews: process.env.DISCORD_CHANNEL_ID_NEWS || "",
|
||||||
@@ -22,6 +23,7 @@ export default {
|
|||||||
vchannelIdPomodoro25: process.env.DISCORD_VCHANNEL_ID_POMODORO_25_5 || "",
|
vchannelIdPomodoro25: process.env.DISCORD_VCHANNEL_ID_POMODORO_25_5 || "",
|
||||||
vchannelIdPomodoro50: process.env.DISCORD_VCHANNEL_ID_POMODORO_50_10 || "",
|
vchannelIdPomodoro50: process.env.DISCORD_VCHANNEL_ID_POMODORO_50_10 || "",
|
||||||
// roles
|
// roles
|
||||||
|
roleBot: process.env.BOT || "",
|
||||||
roleStudy: process.env.PEOPLE || "",
|
roleStudy: process.env.PEOPLE || "",
|
||||||
roleMod: process.env.MOD || "",
|
roleMod: process.env.MOD || "",
|
||||||
roleAdmin: process.env.ADMIN || "",
|
roleAdmin: process.env.ADMIN || "",
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import {
|
|||||||
type ChatInputCommandInteraction,
|
type ChatInputCommandInteraction,
|
||||||
type Interaction,
|
type Interaction,
|
||||||
type ModalSubmitInteraction,
|
type ModalSubmitInteraction,
|
||||||
|
ActivityType,
|
||||||
|
type Channel,
|
||||||
} from "discord.js";
|
} from "discord.js";
|
||||||
import client from "lib/client";
|
import client from "lib/client";
|
||||||
import EventEmitter from "node:events";
|
import EventEmitter from "node:events";
|
||||||
@@ -70,10 +72,44 @@ export default class DiscordController extends EventEmitter {
|
|||||||
|
|
||||||
// log when running
|
// log when running
|
||||||
client.once("ready", async () => {
|
client.once("ready", async () => {
|
||||||
await this.setActivity();
|
const channels = client.channels;
|
||||||
|
const logChannel = channels.cache.get(config.discord.channelIdLog);
|
||||||
|
|
||||||
|
if (logChannel?.isTextBased() && logChannel?.isSendable()) {
|
||||||
|
try {
|
||||||
|
console.log("bot is online");
|
||||||
|
await logChannel.send("wieder online!!!");
|
||||||
|
} catch (error) {
|
||||||
|
console.error("failed to send online message:", error);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.error("log channel is not valid or sendable.");
|
||||||
|
}
|
||||||
|
await this.setActivity(100);
|
||||||
console.log("ready");
|
console.log("ready");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
process.on("exit", async () => {
|
||||||
|
const channels = client.channels;
|
||||||
|
const logChannel = channels.cache.get(config.discord.channelIdLog);
|
||||||
|
await this.handleShutdown(logChannel);
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on("SIGINT", async () => {
|
||||||
|
const channels = client.channels;
|
||||||
|
const logChannel = channels.cache.get(config.discord.channelIdLog);
|
||||||
|
await this.handleShutdown(logChannel);
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on("SIGTERM", async () => {
|
||||||
|
const channels = client.channels;
|
||||||
|
const logChannel = channels.cache.get(config.discord.channelIdLog);
|
||||||
|
await this.handleShutdown(logChannel);
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
|
||||||
// listen for interactions
|
// listen for interactions
|
||||||
client.on("interactionCreate", this.handleInteraction.bind(this));
|
client.on("interactionCreate", this.handleInteraction.bind(this));
|
||||||
|
|
||||||
@@ -144,14 +180,40 @@ export default class DiscordController extends EventEmitter {
|
|||||||
console.log(`----------------\nversion ${config.discord.version}\n----------------`);
|
console.log(`----------------\nversion ${config.discord.version}\n----------------`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async setActivity() {
|
async setActivity(state: number) {
|
||||||
client.user?.setActivity(":3", { type: 4 });
|
switch (state) {
|
||||||
console.log("set activity");
|
case 0:
|
||||||
client.user?.setPresence({
|
client.user?.setActivity(" ", { type: 0 });
|
||||||
status: "online",
|
console.log("set activity");
|
||||||
});
|
client.user?.setPresence({
|
||||||
|
status: "invisible",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
client.user?.setActivity("spielt sudoku", { type: 0 });
|
||||||
|
console.log("set activity");
|
||||||
|
client.user?.setPresence({
|
||||||
|
status: "online",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async handleShutdown(logChannel: Channel | undefined) {
|
||||||
|
if (logChannel?.isTextBased() && logChannel?.isSendable()) {
|
||||||
|
try {
|
||||||
|
await logChannel.send("bot is going offline...");
|
||||||
|
} catch (error) {
|
||||||
|
console.error("failed to send offline message:", error);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.error("log channel is not valid or sendable.");
|
||||||
|
}
|
||||||
|
await this.setActivity(0);
|
||||||
|
console.log("bot is offline.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
await this.discordService.init();
|
await this.discordService.init();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user