namefix channel -> vchannel
This commit is contained in:
parent
0d757fef79
commit
034d1c076c
@ -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<CacheType>) {
|
||||
// todo
|
||||
}
|
||||
|
||||
async createChannel(
|
||||
oldState: VoiceState,
|
||||
async createVChannel(
|
||||
newState: VoiceState,
|
||||
channel: VoiceBasedChannel,
|
||||
): Promise<StageChannel | VoiceChannel> {
|
||||
//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,
|
@ -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",
|
||||
});
|
||||
|
@ -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) {
|
Loading…
x
Reference in New Issue
Block a user