2021-04-26 11:16:37 +00:00
|
|
|
import {client} from "../index";
|
2021-12-09 03:56:11 +00:00
|
|
|
import {Guild} from "../lib";
|
2021-05-08 13:32:45 +00:00
|
|
|
import {Permissions} from "discord.js";
|
2021-04-26 11:16:37 +00:00
|
|
|
|
|
|
|
client.on("voiceStateUpdate", async (before, after) => {
|
2021-05-08 13:32:45 +00:00
|
|
|
const channel = before.channel;
|
2021-12-09 03:56:11 +00:00
|
|
|
const {defaultChannelNames} = new Guild(after.guild.id);
|
2021-04-26 11:16:37 +00:00
|
|
|
|
2021-05-08 13:32:45 +00:00
|
|
|
if (
|
|
|
|
channel &&
|
|
|
|
channel.members.size === 0 &&
|
2021-12-09 03:56:11 +00:00
|
|
|
defaultChannelNames.has(channel.id) &&
|
2021-05-17 22:12:14 +00:00
|
|
|
before.guild.me?.permissions.has(Permissions.FLAGS.MANAGE_CHANNELS)
|
2021-05-08 13:32:45 +00:00
|
|
|
) {
|
2021-12-09 03:56:11 +00:00
|
|
|
channel.setName(defaultChannelNames.get(channel.id)!);
|
2021-04-26 11:16:37 +00:00
|
|
|
}
|
|
|
|
});
|