TravBot-v3/src/modules/channelDefaults.ts

18 lines
515 B
TypeScript
Raw Normal View History

import {client} from "../index";
import {Storage} from "../structures";
2021-05-08 13:32:45 +00:00
import {Permissions} from "discord.js";
client.on("voiceStateUpdate", async (before, after) => {
2021-05-08 13:32:45 +00:00
const channel = before.channel;
const {channelNames} = Storage.getGuild(after.guild.id);
2021-05-08 13:32:45 +00:00
if (
channel &&
channel.members.size === 0 &&
channel.id in channelNames &&
before.guild.me?.hasPermission(Permissions.FLAGS.MANAGE_CHANNELS)
) {
channel.setName(channelNames[channel.id]);
}
});