generated from Baipyrus/DiscordJS-Template
Compare commits
No commits in common. "e0c581dcfd5fbf2973acedf8113fe259750eb7b9" and "fa6a9fa2e38edd2afdbb760fcc5cbff171aa9bf0" have entirely different histories.
e0c581dcfd
...
fa6a9fa2e3
@ -4,8 +4,7 @@ import {
|
|||||||
GuildMember,
|
GuildMember,
|
||||||
GuildChannelManager,
|
GuildChannelManager,
|
||||||
GuildChannel,
|
GuildChannel,
|
||||||
VoiceState,
|
VoiceState
|
||||||
PermissionOverwrites
|
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import { VoiceChannel } from '../../database.js';
|
import { VoiceChannel } from '../../database.js';
|
||||||
|
|
||||||
@ -20,34 +19,29 @@ const getChannel = async (member, guildChs, channel) => {
|
|||||||
// Check database for existing channel
|
// Check database for existing channel
|
||||||
const ownCh = await VoiceChannel.findOne({
|
const ownCh = await VoiceChannel.findOne({
|
||||||
where: {
|
where: {
|
||||||
owner: member.id
|
owner: member.user.id
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (ownCh !== null) return await guildChs.fetch(ownCh.id);
|
if (ownCh !== null) {
|
||||||
|
return await guildChs.fetch(ownCh.id);
|
||||||
|
}
|
||||||
|
|
||||||
// Create private channel with all permissions
|
// Create private channel with all permissions
|
||||||
const name = member.user.username;
|
const name = member.user.username;
|
||||||
const chName = `${name}${name.toLowerCase().endsWith('s') ? "'" : "'s"} channel`;
|
const chName = `${name}${name.toLowerCase().endsWith('s') ? "'" : "'s"} channel`;
|
||||||
// Get permissions from parent
|
// Get permissions from parent
|
||||||
/** @type {PermissionOverwrites} */
|
const vcPermOver = channel.parent.permissionOverwrites.cache.get(member.id);
|
||||||
const { allow, deny } = channel.parent.permissionOverwrites.cache.get(member.client.user.id);
|
|
||||||
const privCh = await guildChs.create({
|
const privCh = await guildChs.create({
|
||||||
name: chName,
|
name: chName,
|
||||||
parent: channel.parent,
|
parent: channel.parent,
|
||||||
type: ChannelType.GuildVoice,
|
type: ChannelType.GuildVoice,
|
||||||
permissionOverwrites: [
|
permissionOverwrites: [vcPermOver]
|
||||||
{
|
|
||||||
id: member.id,
|
|
||||||
allow,
|
|
||||||
deny
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Save newly created channel
|
// Save newly created channel
|
||||||
await VoiceChannel.create({
|
await VoiceChannel.create({
|
||||||
id: privCh.id,
|
id: privCh.id,
|
||||||
owner: member.id
|
owner: member.user.id
|
||||||
});
|
});
|
||||||
|
|
||||||
return privCh;
|
return privCh;
|
||||||
|
Loading…
Reference in New Issue
Block a user