more logging

This commit is contained in:
mo
2026-03-01 17:52:06 +01:00
parent 93788b9873
commit f20bdde4e6
3 changed files with 20 additions and 4 deletions

View File

@@ -2,19 +2,24 @@ import type { VoiceChannelsServiceInterface } from "@avocadi/bot-core/entities/c
import { config } from "config"; import { config } from "config";
import { ChannelType, type VoiceChannel } from "discord.js"; import { ChannelType, type VoiceChannel } from "discord.js";
import client from "lib/client"; import client from "lib/client";
import { logger } from "lib/common-logger";
export class VoiceChannelsService export class VoiceChannelsService
implements VoiceChannelsServiceInterface<VoiceChannel> implements VoiceChannelsServiceInterface<VoiceChannel>
{ {
/***
*/
async getVoiceChannelById(channelId: string) { async getVoiceChannelById(channelId: string) {
const channel = await client.channels.fetch(channelId); const channel = await client.channels.fetch(channelId);
if (!channel) { if (!channel) {
throw new Error(`Channel with id ${channelId} not found`); logger.error(`Channel with id ${channelId} not found`);
return null;
} }
if (channel.type !== ChannelType.GuildVoice) { if (channel.type !== ChannelType.GuildVoice) {
throw new Error(`Channel with id ${channelId} is not a voice channel`); logger.error(`Channel with id ${channelId} is not a voice channel`);
return null;
} }
return channel; return channel;
@@ -43,6 +48,7 @@ export class VoiceChannelsService
async deleteVoiceChannel(channelId: string) { async deleteVoiceChannel(channelId: string) {
const channel = await this.getVoiceChannelById(channelId); const channel = await this.getVoiceChannelById(channelId);
if (!channel) return;
await channel.delete(); await channel.delete();
} }
} }

View File

@@ -27,14 +27,16 @@ export class ReactionRolesService {
if (!message) { if (!message) {
this.logger.error(`Message with ID ${reaction.message.id} not found.`); this.logger.error(`Message with ID ${reaction.message.id} not found.`);
throw new Error("Message not found"); return;
// throw new Error("Message not found");
} }
if (!config.reactionRoles.allowedMessageIds.includes(message.id)) { if (!config.reactionRoles.allowedMessageIds.includes(message.id)) {
this.logger.error( this.logger.error(
`Message with ID ${message.id} is not allowed for reaction roles.`, `Message with ID ${message.id} is not allowed for reaction roles.`,
); );
throw new Error("Message not allowed for reaction roles"); return;
// throw new Error("Message not allowed for reaction roles");
} }
return; return;

View File

@@ -1,19 +1,27 @@
import client from "lib/client"; import client from "lib/client";
import { logger } from "lib/common-logger";
import { handleButtonInteraction } from "./handle-button"; import { handleButtonInteraction } from "./handle-button";
import { handleChatInputCommandInteraction } from "./handle-chat-input-command"; import { handleChatInputCommandInteraction } from "./handle-chat-input-command";
import { handleModalSubmitInteraction } from "./handle-modal-submit"; import { handleModalSubmitInteraction } from "./handle-modal-submit";
client.on("interactionCreate", async (interaction) => { client.on("interactionCreate", async (interaction) => {
if (interaction.isModalSubmit()) { if (interaction.isModalSubmit()) {
logger.debug("isModalSubmit");
await handleModalSubmitInteraction(interaction); await handleModalSubmitInteraction(interaction);
return; return;
} }
if (interaction.isChatInputCommand()) { if (interaction.isChatInputCommand()) {
logger.debug("isChatInputCommand");
await handleChatInputCommandInteraction(interaction); await handleChatInputCommandInteraction(interaction);
return; return;
} }
if (interaction.isCommand()) {
logger.debug("isCommand");
return;
}
if (interaction.isButton()) { if (interaction.isButton()) {
logger.debug("isButton");
await handleButtonInteraction(interaction); await handleButtonInteraction(interaction);
return; return;
} }