namefix channel -> vchannel
This commit is contained in:
parent
0d757fef79
commit
034d1c076c
@ -1,7 +1,7 @@
|
|||||||
import config from "config";
|
import config from "config";
|
||||||
import client from "lib/client";
|
import client from "lib/client";
|
||||||
import { getRandomInt } from "lib/utils";
|
import { getRandomInt } from "lib/utils";
|
||||||
import { } from "./dynamicChannel.components.ts";
|
import { } from "./dynamicVChannel.components.ts";
|
||||||
import {
|
import {
|
||||||
Client,
|
Client,
|
||||||
EmbedBuilder,
|
EmbedBuilder,
|
||||||
@ -17,26 +17,25 @@ import {
|
|||||||
type VoiceBasedChannel,
|
type VoiceBasedChannel,
|
||||||
} from "discord.js";
|
} from "discord.js";
|
||||||
|
|
||||||
export class DynamicChannelService {
|
export class DynamicVChannelService {
|
||||||
async handleInteraction(interaction: Interaction<CacheType>) {
|
async handleInteraction(interaction: Interaction<CacheType>) {
|
||||||
// todo
|
// todo
|
||||||
}
|
}
|
||||||
|
|
||||||
async createChannel(
|
async createVChannel(
|
||||||
oldState: VoiceState,
|
|
||||||
newState: VoiceState,
|
newState: VoiceState,
|
||||||
channel: VoiceBasedChannel,
|
channel: VoiceBasedChannel,
|
||||||
): Promise<StageChannel | VoiceChannel> {
|
): Promise<StageChannel | VoiceChannel> {
|
||||||
//console.log("createChannel()");
|
//console.log("createChannel()");
|
||||||
const newChannel = await channel.clone({
|
const newVChannel = await channel.clone({
|
||||||
name: `${channel.name.substring(2)}; ${newState.member?.displayName}`,
|
name: `${channel.name.substring(2)}; ${newState.member?.displayName}`,
|
||||||
position: 100,
|
position: 100,
|
||||||
});
|
});
|
||||||
|
|
||||||
return newChannel;
|
return newVChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteChannel(
|
async deleteVChannel(
|
||||||
oldState: VoiceState,
|
oldState: VoiceState,
|
||||||
newState: VoiceState,
|
newState: VoiceState,
|
||||||
newChannel: StageChannel | VoiceChannel,
|
newChannel: StageChannel | VoiceChannel,
|
@ -167,7 +167,7 @@ export class GreetingService {
|
|||||||
|
|
||||||
async newYear() {
|
async newYear() {
|
||||||
client.user?.setActivity("frohes neues! :)", { type: 4 });
|
client.user?.setActivity("frohes neues! :)", { type: 4 });
|
||||||
console.log("set activity: happy new Year");
|
console.log("set activity: happy new year");
|
||||||
client.user?.setPresence({
|
client.user?.setPresence({
|
||||||
status: "online",
|
status: "online",
|
||||||
});
|
});
|
||||||
|
@ -13,7 +13,7 @@ import {
|
|||||||
} 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";
|
||||||
import DiscordService from "services/discord.service";
|
import DiscordService from "discord.service";
|
||||||
import { WaterMeService } from "actions/waterMe/waterMe.service";
|
import { WaterMeService } from "actions/waterMe/waterMe.service";
|
||||||
import { MedicationService } from "actions/medication/medication.service";
|
import { MedicationService } from "actions/medication/medication.service";
|
||||||
import { HelpService } from "actions/help/help.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 { 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 { DynamicChannelService } from "actions/dynamicChannel/dynamicChannel.service";
|
import { DynamicVChannelService } from "actions/dynamicVChannel/dynamicVChannel.service";
|
||||||
import { ReactRolesService } from "actions/reactRole/reactRoles.service";
|
import { ReactRolesService } from "actions/reactRole/reactRoles.service";
|
||||||
|
import { PomodoroService } from "actions/pomodoro/pomodoro.service";
|
||||||
import config from "config";
|
import config from "config";
|
||||||
|
|
||||||
export default class DiscordController extends EventEmitter {
|
export default class DiscordController extends EventEmitter {
|
||||||
@ -37,9 +38,9 @@ export default class DiscordController extends EventEmitter {
|
|||||||
dmService: DmService;
|
dmService: DmService;
|
||||||
customMessageService: CustomMessageService;
|
customMessageService: CustomMessageService;
|
||||||
channelListeners = new Map();
|
channelListeners = new Map();
|
||||||
dynamicChannelService: DynamicChannelService;
|
dynamicVChannelService: DynamicVChannelService;
|
||||||
reactRolesService: ReactRolesService;
|
reactRolesService: ReactRolesService;
|
||||||
version = 250222.2319;
|
version = 250507.19;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
@ -53,7 +54,7 @@ export default class DiscordController extends EventEmitter {
|
|||||||
this.activityService = new ActivityService();
|
this.activityService = new ActivityService();
|
||||||
this.dmService = new DmService();
|
this.dmService = new DmService();
|
||||||
this.customMessageService = new CustomMessageService();
|
this.customMessageService = new CustomMessageService();
|
||||||
this.dynamicChannelService = new DynamicChannelService();
|
this.dynamicVChannelService = new DynamicVChannelService();
|
||||||
this.reactRolesService = new ReactRolesService();
|
this.reactRolesService = new ReactRolesService();
|
||||||
|
|
||||||
client.on("messageReactionAdd", async (reaction, user) => {
|
client.on("messageReactionAdd", async (reaction, user) => {
|
||||||
@ -106,38 +107,19 @@ export default class DiscordController extends EventEmitter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// create new channel with same settings
|
const newChannel = await this.dynamicVChannelService.createVChannel(
|
||||||
/*const newChannel = await channel.clone({
|
|
||||||
name: channel.name + "; " + newState.member?.displayName,
|
|
||||||
position: channel.position
|
|
||||||
});*/
|
|
||||||
|
|
||||||
const newChannel = await this.dynamicChannelService.createChannel(
|
|
||||||
oldState,
|
|
||||||
newState,
|
newState,
|
||||||
channel,
|
channel,
|
||||||
);
|
);
|
||||||
|
|
||||||
// move user in new channel
|
// move user in new channel
|
||||||
await newState.setChannel(newChannel);
|
await newState.setChannel(newChannel);
|
||||||
|
|
||||||
// create specific listener for channel
|
// create specific listener for channel
|
||||||
const channelListener = async (
|
const channelListener = async (
|
||||||
oldState: VoiceState,
|
oldState: VoiceState,
|
||||||
newState: 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 =
|
channelListeners =
|
||||||
await this.dynamicChannelService.deleteChannel(
|
await this.dynamicVChannelService.deleteVChannel(
|
||||||
oldState,
|
oldState,
|
||||||
newState,
|
newState,
|
||||||
newChannel,
|
newChannel,
|
||||||
@ -147,7 +129,6 @@ export default class DiscordController extends EventEmitter {
|
|||||||
};
|
};
|
||||||
// save listener in map
|
// save listener in map
|
||||||
channelListeners.set(newChannel.id, channelListener);
|
channelListeners.set(newChannel.id, channelListener);
|
||||||
|
|
||||||
// add listener
|
// add listener
|
||||||
client.on(Events.VoiceStateUpdate, channelListener);
|
client.on(Events.VoiceStateUpdate, channelListener);
|
||||||
} catch (error) {
|
} catch (error) {
|
Loading…
x
Reference in New Issue
Block a user