generated from Baipyrus/DiscordJS-Template
Compare commits
5 Commits
ab6ca9edeb
...
fa6a9fa2e3
Author | SHA1 | Date | |
---|---|---|---|
fa6a9fa2e3 | |||
73562b3570 | |||
0c3c1b5582 | |||
7ea28db049 | |||
e74bd83ee6 |
|
@ -1,7 +1,6 @@
|
|||
import {
|
||||
ChannelType,
|
||||
Events,
|
||||
PermissionFlagsBits,
|
||||
GuildMember,
|
||||
GuildChannelManager,
|
||||
GuildChannel,
|
||||
|
@ -9,22 +8,6 @@ import {
|
|||
} from 'discord.js';
|
||||
import { VoiceChannel } from '../../database.js';
|
||||
|
||||
const vcPermissionOverwrites = [
|
||||
PermissionFlagsBits.ReadMessageHistory,
|
||||
PermissionFlagsBits.PrioritySpeaker,
|
||||
PermissionFlagsBits.ManageMessages,
|
||||
PermissionFlagsBits.ManageChannels,
|
||||
PermissionFlagsBits.DeafenMembers,
|
||||
PermissionFlagsBits.SendMessages,
|
||||
PermissionFlagsBits.ViewChannel,
|
||||
PermissionFlagsBits.MuteMembers,
|
||||
PermissionFlagsBits.MoveMembers,
|
||||
PermissionFlagsBits.Connect,
|
||||
PermissionFlagsBits.Stream,
|
||||
PermissionFlagsBits.UseVAD,
|
||||
PermissionFlagsBits.Speak
|
||||
];
|
||||
|
||||
/**
|
||||
* Function that either creates a new custom channel or gets an existing one registered in the database.
|
||||
* @param {GuildMember} member The member that caused this event.
|
||||
|
@ -46,16 +29,13 @@ const getChannel = async (member, guildChs, channel) => {
|
|||
// Create private channel with all permissions
|
||||
const name = member.user.username;
|
||||
const chName = `${name}${name.toLowerCase().endsWith('s') ? "'" : "'s"} channel`;
|
||||
// Get permissions from parent
|
||||
const vcPermOver = channel.parent.permissionOverwrites.cache.get(member.id);
|
||||
const privCh = await guildChs.create({
|
||||
name: chName,
|
||||
parent: channel.parent,
|
||||
type: ChannelType.GuildVoice,
|
||||
permissionOverwrites: [
|
||||
{
|
||||
id: member.id,
|
||||
allow: vcPermissionOverwrites
|
||||
}
|
||||
]
|
||||
permissionOverwrites: [vcPermOver]
|
||||
});
|
||||
|
||||
// Save newly created channel
|
||||
|
@ -101,7 +81,9 @@ export const name = Events.VoiceStateUpdate;
|
|||
* @param {VoiceState} newState
|
||||
*/
|
||||
export async function execute(oldState, newState) {
|
||||
const { channel } = newState;
|
||||
const { channel, member } = newState;
|
||||
let step = 'delete';
|
||||
try {
|
||||
await leftVoiceChat(oldState);
|
||||
if (!channel) return;
|
||||
|
||||
|
@ -114,13 +96,9 @@ export async function execute(oldState, newState) {
|
|||
});
|
||||
if (createCh === null) return;
|
||||
|
||||
// Extract user data
|
||||
const member = newState.member;
|
||||
|
||||
step = 'create';
|
||||
// Extract channel data
|
||||
const channels = newState.guild.channels;
|
||||
let step = 'create';
|
||||
try {
|
||||
const privCh = await getChannel(member, channels, channel);
|
||||
|
||||
step = 'move to';
|
||||
|
|
|
@ -37,7 +37,7 @@ export async function execute(reaction, user) {
|
|||
reaction.remove();
|
||||
} catch (error) {
|
||||
// Missing permissions
|
||||
console.error(error)
|
||||
console.error(error);
|
||||
await user.send('Unable to remove reaction. Please contact server staff.');
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -66,7 +66,11 @@ const saveMessageData = async (id, role, emoji) => {
|
|||
);
|
||||
|
||||
// Create database entry for pair
|
||||
await RoleEmojiPair.create({ message: id, role: role.id, emoji: emoji.replace(/:(\s*[^:]*\s*):/, ":_:") });
|
||||
await RoleEmojiPair.create({
|
||||
message: id,
|
||||
role: role.id,
|
||||
emoji: emoji.replace(/:(\s*[^:]*\s*):/, ':_:')
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user