Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasB25 committed Aug 26, 2024
1 parent 91ae4f2 commit 8e12b72
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 12 deletions.
42 changes: 42 additions & 0 deletions src/events/client/ChannelDelete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Event, type Lavamusic } from "../../structures/index.js";

export default class ChannelDelete extends Event {
constructor(client: Lavamusic, file: string) {
super(client, file, {
name: "channelDelete",
});
}

public async run(channel: any): Promise<void> {
const { guild } = channel;
const setup = await this.client.db.getSetup(guild.id);
const stay = await this.client.db.get_247(guild.id);

if (Array.isArray(stay)) {
for (const s of stay) {
if (channel.type === 2 && s.voiceId === channel.id) {
await this.client.db.delete_247(guild.id);
break;
}
}
} else if (stay) {
if (channel.type === 2 && stay.voiceId === channel.id) {
await this.client.db.delete_247(guild.id);
}
}

if (setup && channel.type === 0 && setup.textId === channel.id) {
await this.client.db.deleteSetup(guild.id);
}

const queue = this.client.queue.get(guild.id);
if (queue) {
if (
queue.channelId === channel.id ||
(queue.player && queue.node.manager.connections.get(guild.id)!.channelId === channel.id)
) {
queue.stop();
}
}
}
}
21 changes: 9 additions & 12 deletions src/events/player/NodeConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,19 @@ export default class NodeConnect extends Event {
const vc = guild.channels.cache.get(main.voiceId);

if (channel && vc) {
await this.client.queue.create(guild, vc, channel);
try {
await this.client.queue.create(guild, vc, channel);
} catch (error) {
this.client.logger.error(`Failed to create queue for guild ${guild.id}: ${error.message}`);
}
} else {
this.client.logger.warn(
`Missing channels for guild ${guild.id}. Text channel: ${main.textId}, Voice channel: ${main.voiceId}`,
);
}
}, index * 1000);
});

BotLog.send(this.client, `Node ${node} is ready!`, "success");
}
}

/**
* Project: lavamusic
* Author: Appu
* Main Contributor: LucasB25
* Company: Coders
* Copyright (c) 2024. All rights reserved.
* This code is the property of Coder and may not be reproduced or
* modified without permission. For more information, contact us at
* https://discord.gg/ns8CTk9J3e
*/

0 comments on commit 8e12b72

Please sign in to comment.