diff --git a/src/actions/dynamicChannel/dynamicChannel.components.ts b/src/actions/dynamicVChannel/dynamicVChannel.components.ts similarity index 100% rename from src/actions/dynamicChannel/dynamicChannel.components.ts rename to src/actions/dynamicVChannel/dynamicVChannel.components.ts diff --git a/src/actions/dynamicChannel/dynamicChannel.service.ts b/src/actions/dynamicVChannel/dynamicVChannel.service.ts similarity index 86% rename from src/actions/dynamicChannel/dynamicChannel.service.ts rename to src/actions/dynamicVChannel/dynamicVChannel.service.ts index 3ffb3dd..c0ceb7b 100644 --- a/src/actions/dynamicChannel/dynamicChannel.service.ts +++ b/src/actions/dynamicVChannel/dynamicVChannel.service.ts @@ -1,7 +1,7 @@ import config from "config"; import client from "lib/client"; import { getRandomInt } from "lib/utils"; -import { } from "./dynamicChannel.components.ts"; +import { } from "./dynamicVChannel.components.ts"; import { Client, EmbedBuilder, @@ -17,26 +17,25 @@ import { type VoiceBasedChannel, } from "discord.js"; -export class DynamicChannelService { +export class DynamicVChannelService { async handleInteraction(interaction: Interaction) { // todo } - async createChannel( - oldState: VoiceState, + async createVChannel( newState: VoiceState, channel: VoiceBasedChannel, ): Promise { //console.log("createChannel()"); - const newChannel = await channel.clone({ + const newVChannel = await channel.clone({ name: `${channel.name.substring(2)}; ${newState.member?.displayName}`, position: 100, }); - return newChannel; + return newVChannel; } - async deleteChannel( + async deleteVChannel( oldState: VoiceState, newState: VoiceState, newChannel: StageChannel | VoiceChannel, diff --git a/src/actions/greeting/greeting.service.ts b/src/actions/greeting/greeting.service.ts index 84b36cc..a22bd72 100644 --- a/src/actions/greeting/greeting.service.ts +++ b/src/actions/greeting/greeting.service.ts @@ -167,7 +167,7 @@ export class GreetingService { async newYear() { client.user?.setActivity("frohes neues! :)", { type: 4 }); - console.log("set activity: happy new Year"); + console.log("set activity: happy new year"); client.user?.setPresence({ status: "online", }); diff --git a/src/controllers/discord.controller.ts b/src/discord.controller.ts similarity index 86% rename from src/controllers/discord.controller.ts rename to src/discord.controller.ts index 476910b..2b5f065 100644 --- a/src/controllers/discord.controller.ts +++ b/src/discord.controller.ts @@ -13,7 +13,7 @@ import { } from "discord.js"; import client from "lib/client"; import EventEmitter from "node:events"; -import DiscordService from "services/discord.service"; +import DiscordService from "discord.service"; import { WaterMeService } from "actions/waterMe/waterMe.service"; import { MedicationService } from "actions/medication/medication.service"; import { HelpService } from "actions/help/help.service"; @@ -22,8 +22,9 @@ import { GreetingService } from "actions/greeting/greeting.service"; import { ActivityService } from "actions/activity/activity.service"; import { DmService } from "actions/dm/dm.service"; import { CustomMessageService } from "actions/customMessage/customMessage.service"; -import { DynamicChannelService } from "actions/dynamicChannel/dynamicChannel.service"; +import { DynamicVChannelService } from "actions/dynamicVChannel/dynamicVChannel.service"; import { ReactRolesService } from "actions/reactRole/reactRoles.service"; +import { PomodoroService } from "actions/pomodoro/pomodoro.service"; import config from "config"; export default class DiscordController extends EventEmitter { @@ -37,9 +38,9 @@ export default class DiscordController extends EventEmitter { dmService: DmService; customMessageService: CustomMessageService; channelListeners = new Map(); - dynamicChannelService: DynamicChannelService; + dynamicVChannelService: DynamicVChannelService; reactRolesService: ReactRolesService; - version = 250222.2319; + version = 250507.19; constructor() { super(); @@ -53,7 +54,7 @@ export default class DiscordController extends EventEmitter { this.activityService = new ActivityService(); this.dmService = new DmService(); this.customMessageService = new CustomMessageService(); - this.dynamicChannelService = new DynamicChannelService(); + this.dynamicVChannelService = new DynamicVChannelService(); this.reactRolesService = new ReactRolesService(); client.on("messageReactionAdd", async (reaction, user) => { @@ -106,38 +107,19 @@ export default class DiscordController extends EventEmitter { return; } try { - // create new channel with same settings - /*const newChannel = await channel.clone({ - name: channel.name + "; " + newState.member?.displayName, - position: channel.position - });*/ - - const newChannel = await this.dynamicChannelService.createChannel( - oldState, + const newChannel = await this.dynamicVChannelService.createVChannel( newState, channel, ); - // move user in new channel await newState.setChannel(newChannel); - // create specific listener for channel const channelListener = async ( oldState: VoiceState, newState: VoiceState, ) => { - /*if (oldState.channelId === newChannel.id || newState.channelId === newChannel.id) { - // check if channel empty - if (newChannel.members.size === 0) { - newChannel.delete() - .catch(console.error); - // delete listener for this channel - client.removeListener(Events.VoiceStateUpdate, channelListener); - channelListeners.delete(newChannel.id); - } - }*/ channelListeners = - await this.dynamicChannelService.deleteChannel( + await this.dynamicVChannelService.deleteVChannel( oldState, newState, newChannel, @@ -147,7 +129,6 @@ export default class DiscordController extends EventEmitter { }; // save listener in map channelListeners.set(newChannel.id, channelListener); - // add listener client.on(Events.VoiceStateUpdate, channelListener); } catch (error) { diff --git a/src/services/discord.service.ts b/src/discord.service.ts similarity index 100% rename from src/services/discord.service.ts rename to src/discord.service.ts