mirror of
https://github.com/jcreek/denBot.git
synced 2026-07-13 02:43:46 +00:00
fix(*): Fix adding a private text channel
This commit is contained in:
@@ -118,27 +118,35 @@ function getChannelName(username) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function makeTempChannel(message) {
|
function makeTempChannel(message) {
|
||||||
const everyoneRole = message.guild.defaultRole;
|
|
||||||
let createdChannelId = '';
|
|
||||||
|
|
||||||
const channelName = getChannelName(message.author.username);
|
const channelName = getChannelName(message.author.username);
|
||||||
message.guild.createChannel(channelName, 'text')
|
let createdChannelId = '';
|
||||||
.then(createdChannel => {
|
let everyoneRole = message.guild.roles.cache.find(r => r.name === '@everyone');
|
||||||
playerQueue.forEach(player => {
|
|
||||||
createdChannel.overwritePermissions(player.id, { VIEW_CHANNEL: true });
|
|
||||||
});
|
|
||||||
createdChannel.overwritePermissions(client.id, { VIEW_CHANNEL: true });
|
|
||||||
createdChannel.overwritePermissions(everyoneRole, { VIEW_CHANNEL: false });
|
|
||||||
|
|
||||||
createdChannelId = createdChannel.id;
|
let permissionOverwrites = [{
|
||||||
})
|
id: everyoneRole.id,
|
||||||
.catch(logger.error);
|
deny: ['VIEW_CHANNEL'],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
// Delete the channel after 20 minutes
|
playerQueue.forEach(player => {
|
||||||
setTimeout(function(){ deleteChannel(createdChannelId); }, 20000);
|
permissionOverwrites.push({
|
||||||
|
id: player.id,
|
||||||
|
allow: ['VIEW_CHANNEL'],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(permissionOverwrites);
|
||||||
|
message.guild.channels.create(channelName, {
|
||||||
|
type: 'text',
|
||||||
|
permissionOverwrites: permissionOverwrites,
|
||||||
|
}).then(createdChannel => { createdChannelId = createdChannel.id; })
|
||||||
|
.catch(logger.error);
|
||||||
|
|
||||||
|
// Delete the channel after 20 seconds
|
||||||
|
setTimeout(function(){ deleteChannel(message, createdChannelId); }, (config.channeldeletetimeinminutes * 1000) );
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteChannel(channelId) {
|
function deleteChannel(message, channelId) {
|
||||||
const fetchedChannel = message.guild.channels.cache.get(channelId);
|
const fetchedChannel = message.guild.channels.cache.get(channelId);
|
||||||
fetchedChannel.delete();
|
fetchedChannel.delete();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user