Compare commits

..

7 Commits

Author SHA1 Message Date
7a1f02ebd0 name fix docker-compose
All checks were successful
release-tag / release-image (push) Successful in 22s
2025-06-02 11:29:56 +02:00
f6bceb215c pomodoro fix
All checks were successful
release-tag / release-image (push) Successful in 17s
2025-06-02 10:38:08 +02:00
9914cd2bfb add version command
All checks were successful
release-tag / release-image (push) Successful in 18s
2025-06-02 10:28:37 +02:00
fd2d5f5bff changed name to mo
All checks were successful
release-tag / release-image (push) Successful in 1m33s
2025-06-02 10:18:07 +02:00
762bb989a2 version
All checks were successful
release-tag / release-image (push) Successful in 19s
2025-05-10 00:38:06 +02:00
4031291c38 fixed bug when switching from one pomodoro channel to other
All checks were successful
release-tag / release-image (push) Successful in 18s
2025-05-10 00:36:29 +02:00
fca6927b08 changed version nr
All checks were successful
release-tag / release-image (push) Successful in 18s
2025-05-10 00:21:29 +02:00
12 changed files with 103 additions and 38 deletions

View File

@@ -1,7 +1,6 @@
name: release-tag name: release-tag
on: on: push
push
jobs: jobs:
release-image: release-image:
@@ -45,5 +44,5 @@ jobs:
linux/arm64 linux/arm64
push: true push: true
tags: | # replace it with your local IP and tags tags: | # replace it with your local IP and tags
git.unom.io/moriese/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }} git.unom.io/mo/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}
git.unom.io/moriese/${{ steps.meta.outputs.REPO_NAME }}:latest git.unom.io/mo/${{ steps.meta.outputs.REPO_NAME }}:latest

View File

@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2024 moriese Copyright (c) 2024 mo (mo@unom.io)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View File

@@ -1,7 +1,7 @@
services: services:
avocadi-bot: avocadi-bot:
container_name: avocadi-bot container_name: avocadi-bot
image: git.unom.io/moriese/avocadi-bot:latest image: git.unom.io/mo/avocadi-bot:latest
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- ./.env:/usr/src/app/.env - ./.env:/usr/src/app/.env

View File

@@ -0,0 +1,48 @@
import { type CommandsType, Commands } from "commands";
import config from "config";
import type { CacheType, ChatInputCommandInteraction, Interaction } from "discord.js";
import { checkPermission } from "permissions";
export class DebugService {
async handleInteraction(
interaction: Interaction<CacheType>
) {
if (interaction.isChatInputCommand()) {
await this.handleChatInputCommand(interaction);
return;
}
}
async handleChatInputCommand(interaction: ChatInputCommandInteraction<CacheType>) {
const commandName = interaction.commandName as CommandsType;
switch (commandName) {
case Commands.Enum.version:
await this.version(interaction);
return;
default:
break;
}
}
async version(interaction: ChatInputCommandInteraction<CacheType>) {
try {
console.log("version command");
if (await checkPermission(interaction.member) !== true) {
await interaction.reply({
content: "du hast keine rechte fuer diesen befehl",
ephemeral: true,
});
return;
}
await interaction.reply({
content: "version: " + config.discord.version,
});
}
catch (error) {
console.error("error while sending version msg:", error);
}
}
}

View File

@@ -18,6 +18,7 @@ import {
} from "discord.js"; } from "discord.js";
import { DmService } from "actions/dm/dm.service.ts"; import { DmService } from "actions/dm/dm.service.ts";
import { Commands, type CommandsType } from "commands/index.ts"; import { Commands, type CommandsType } from "commands/index.ts";
import { checkPermission } from "permissions/index.ts";
export class GreetingService { export class GreetingService {
dmService: DmService; dmService: DmService;
@@ -82,7 +83,7 @@ export class GreetingService {
//console.log(input); //console.log(input);
// permission check // permission check
if (await this.checkPermission(interaction.member) !== true) { if (await checkPermission(interaction.member) !== true) {
await interaction.reply({ await interaction.reply({
content: "du hast keine rechte fuer diesen befehl", content: "du hast keine rechte fuer diesen befehl",
ephemeral: true, ephemeral: true,
@@ -202,7 +203,7 @@ export class GreetingService {
try { try {
// permission check // permission check
if (await this.checkPermission(interaction.member) !== true) { if (await checkPermission(interaction.member) !== true) {
await interaction.reply({ await interaction.reply({
content: "du hast keine rechte fuer diesen befehl", content: "du hast keine rechte fuer diesen befehl",
ephemeral: true, ephemeral: true,
@@ -274,7 +275,7 @@ export class GreetingService {
return; return;
} }
if (await this.checkPermission(interaction.member) !== true) { if (await checkPermission(interaction.member) !== true) {
await interaction.reply({ await interaction.reply({
content: "du hast keine rechte fuer diesen befehl", content: "du hast keine rechte fuer diesen befehl",
ephemeral: true, ephemeral: true,
@@ -325,17 +326,6 @@ export class GreetingService {
} }
} }
async checkPermission(member: GuildMember | APIInteractionGuildMember | null) {
let permission = false;
if (member?.roles instanceof GuildMemberRoleManager) {
if (member.roles.cache.has(config.discord.roleAdmin) || member.roles.cache.has(config.discord.roleMod)) {
console.log("user has permission");
permission = true;
}
}
return permission;
}
async checkRole(member: GuildMember) { async checkRole(member: GuildMember) {
let hasRole = false; let hasRole = false;
if (member?.roles instanceof GuildMemberRoleManager) { if (member?.roles instanceof GuildMemberRoleManager) {

View File

@@ -8,7 +8,7 @@ export default function createEmbed() { // ({ embeds: [exampleEmbed] })
.setColor(0x004400) .setColor(0x004400)
//.setTitle("/hilfe") //.setTitle("/hilfe")
//.setURL("") //.setURL("")
.setAuthor({ name: "avocadi - befehle", iconURL: "https://media.discordapp.net/attachments/1321933410188656693/1323447010380222474/mo_Avocadi_Avatar_Closeup_2.png?ex=67748b93&is=67733a13&hm=f48efb3523bca5f50e79144c7b41a127c94670e693e3da3dc2e6ffe62ad8a769&=&format=webp&quality=lossless&width=1524&height=1524", url: 'https://git.unom.io/moriese/avocadi-bot' }) .setAuthor({ name: "avocadi - befehle", iconURL: "https://media.discordapp.net/attachments/1321933410188656693/1323447010380222474/mo_Avocadi_Avatar_Closeup_2.png?ex=67748b93&is=67733a13&hm=f48efb3523bca5f50e79144c7b41a127c94670e693e3da3dc2e6ffe62ad8a769&=&format=webp&quality=lossless&width=1524&height=1524", url: 'https://git.unom.io/mo/avocadi-bot' })
.setDescription(" ") .setDescription(" ")
.addFields( .addFields(
{ name: `/${Commands.Enum.giessen}`, value: CommandsMeta.giessen.description }, { name: `/${Commands.Enum.giessen}`, value: CommandsMeta.giessen.description },

View File

@@ -115,6 +115,7 @@ export class MedicationService {
await interaction.reply({ await interaction.reply({
content: content:
"es gab einen fehler beim verarbeiten deiner anfrage :( versuch es bitte spaeter nochmal, oki? c:", "es gab einen fehler beim verarbeiten deiner anfrage :( versuch es bitte spaeter nochmal, oki? c:",
ephemeral: true,
}); });
return; return;
} }

View File

@@ -20,9 +20,16 @@ export default class PomodoroController extends EventEmitter {
oldState.channelId !== newState.channelId; oldState.channelId !== newState.channelId;
const leftPomodoroVC = oldState.channelId != null && this.pomodoroChannels.includes(oldState.channelId) && const leftPomodoroVC = oldState.channelId != null && this.pomodoroChannels.includes(oldState.channelId) &&
newState.channelId !== config.discord.vchannelIdPomodoro25; newState.channelId !== oldState.channelId;
if (leftPomodoroVC && this.activePomodoros.has(userId)) {
console.log("pomodoro left");
this.pomodoroService.stopPomodoro(userId);
this.activePomodoros.delete(userId);
}
if (joinedPomodoroVC && !this.activePomodoros.has(userId)) { if (joinedPomodoroVC && !this.activePomodoros.has(userId)) {
console.log("pomodoro join");
const member = newState.member; const member = newState.member;
const vchannel = newState.channel; const vchannel = newState.channel;
if (!member || !vchannel) return; if (!member || !vchannel) return;
@@ -30,12 +37,6 @@ export default class PomodoroController extends EventEmitter {
this.activePomodoros.add(userId); this.activePomodoros.add(userId);
this.pomodoroService.startPomodoroLoop(member, vchannel); this.pomodoroService.startPomodoroLoop(member, vchannel);
} }
if (leftPomodoroVC && this.activePomodoros.has(userId)) {
this.pomodoroService.stopPomodoro(userId);
this.activePomodoros.delete(userId);
}
}); });
} }
} }

View File

@@ -1,7 +1,7 @@
import { SlashCommandBuilder, userMention } from "discord.js"; import { SlashCommandBuilder, userMention } from "discord.js";
import { z } from "zod"; import { z } from "zod";
export const Commands = z.enum(["giessen", "medikamente", "hilfe", "support", "kofi", "disboard", "discadia", "accept", "welcome", "embed", "message", "reminder"]); export const Commands = z.enum(["giessen", "medikamente", "hilfe", "support", "kofi", "disboard", "discadia", "accept", "welcome", "embed", "message", "reminder", "version"]);
export const CommandsMeta: Record<z.output<typeof Commands>, { description: string }> = { export const CommandsMeta: Record<z.output<typeof Commands>, { description: string }> = {
giessen: { giessen: {
@@ -39,6 +39,9 @@ export const CommandsMeta: Record<z.output<typeof Commands>, { description: stri
}, },
reminder: { reminder: {
description: "admin use only" description: "admin use only"
},
version: {
description: "admin use only"
} }
} }
@@ -110,6 +113,9 @@ export default function getCommands() {
option.setName('input') option.setName('input')
.setDescription('input for bot') .setDescription('input for bot')
.setRequired(true)), .setRequired(true)),
new SlashCommandBuilder()
.setName(Commands.Enum.version)
.setDescription(CommandsMeta.version.description),
].map((command) => command.toJSON()); ].map((command) => command.toJSON());

View File

@@ -1,6 +1,6 @@
export default { export default {
discord: { discord: {
version: 250508.2150, version: 250602.10,
// avocadi // avocadi
serverID: process.env.DISCORD_SERVER_ID || "", serverID: process.env.DISCORD_SERVER_ID || "",
// texxt channel // texxt channel

View File

@@ -23,6 +23,7 @@ import { ActivityService } from "actions/activity/activity.service";
import { DmService } from "actions/dm/dm.service"; import { DmService } from "actions/dm/dm.service";
import { CustomMessageService } from "actions/customMessage/customMessage.service"; import { CustomMessageService } from "actions/customMessage/customMessage.service";
import { DynamicVChannelService } from "actions/dynamicVChannel/dynamicVChannel.service"; import { DynamicVChannelService } from "actions/dynamicVChannel/dynamicVChannel.service";
import { DebugService } from "actions/debug/debug.service";
import { ReactRolesService } from "actions/reactRole/reactRoles.service"; import { ReactRolesService } from "actions/reactRole/reactRoles.service";
import config from "config"; import config from "config";
@@ -36,8 +37,10 @@ export default class DiscordController extends EventEmitter {
private activityService: ActivityService; private activityService: ActivityService;
private dmService: DmService; private dmService: DmService;
private customMessageService: CustomMessageService; private customMessageService: CustomMessageService;
private channelListeners = new Map();
private dynamicVChannelService: DynamicVChannelService; private dynamicVChannelService: DynamicVChannelService;
private debugService: DebugService;
private channelListeners = new Map();
private reactRolesService: ReactRolesService; private reactRolesService: ReactRolesService;
@@ -54,6 +57,7 @@ export default class DiscordController extends EventEmitter {
this.dmService = new DmService(); this.dmService = new DmService();
this.customMessageService = new CustomMessageService(); this.customMessageService = new CustomMessageService();
this.dynamicVChannelService = new DynamicVChannelService(); this.dynamicVChannelService = new DynamicVChannelService();
this.debugService = new DebugService();
this.reactRolesService = new ReactRolesService(); this.reactRolesService = new ReactRolesService();
client.on("messageReactionAdd", async (reaction, user) => { client.on("messageReactionAdd", async (reaction, user) => {
@@ -215,6 +219,9 @@ export default class DiscordController extends EventEmitter {
case Commands.Enum.reminder: case Commands.Enum.reminder:
await this.greetingService.handleChatInputCommand(interaction); await this.greetingService.handleChatInputCommand(interaction);
return; return;
case Commands.Enum.version:
await this.debugService.handleChatInputCommand(interaction);
return;
default: default:
break; break;
} }

13
src/permissions/index.ts Normal file
View File

@@ -0,0 +1,13 @@
import config from "config";
import { GuildMember, GuildMemberRoleManager, type APIInteractionGuildMember } from "discord.js";
export async function checkPermission(member: GuildMember | APIInteractionGuildMember | null) {
let permission = false;
if (member?.roles instanceof GuildMemberRoleManager) {
if (member.roles.cache.has(config.discord.roleAdmin) || member.roles.cache.has(config.discord.roleMod)) {
permission = true;
}
}
console.log("user permission == " + permission);
return permission;
}