-2
Good Afternoon.
I’m making a BOT for Discord, and I want to create a text channel and then manage the permissions of it.
However, when updating permissions, you are not updating. I already guaranteed that the BOT is as ADM server.
Follows code:
const Discord = require("discord.js")
exports.run = async (client, message, args, db, civs) => {
const content = args.join(" ");
message.delete();
//if (!message.guild.me.hasPermission('MANAGE_CHANNELS')) return message.channel.send('Não tenho permissão de gerenciar canais')
//if (message.guild.channels.cache.find(ch => ch.name.includes(message.author.id))) return message.reply('Já existe um canal criado pra você ')
if (!args[0]) {
return message.channel.send(`<@${message.author.id}>, escreva a denúncia após o comando`);
} else if (content.length > 1000) {
return message.channel.send(`<@${message.author.id}>, forneça uma denúncia de no máximo 1000 caracteres. Caso precise de mais caracteres, continue escrevendo depois de fazer a denúncia primária.`);
} else {
let channel // declarando variavel global channel que é o canal que vai ser criado e marcado a pessoa que deu comando
try { // ← Tentar criar o canal, se nao conseguir cai no catch
channel = await message.guild.channels
.create(`den•┋${message.member.displayName}|`,{
type: 'text',
permissionOverwrites: [
{
id: '729790119388905552', // everyone
deny: ['VIEW_CHANNEL'], // permissoes de nao ver o canal (ler mensagens)
},
{
id: message.author.id, // permissoes para quem digitou o comando
allow: ['VIEW_CHANNEL', 'SEND_MESSAGES'], // essa pessoa pode ver o canal e enviar mensagens
},
{
id: '740149831825358848', // Moderador
allow: ['VIEW_CHANNEL', 'SEND_MESSAGES'] // essa pessoa pode ver o canal e enviar mensagens
},
],
});
channel.setParent('774700250953940992');
}
catch(err) {
message.channel.send('Erro: ' + err.message);
}
let timeout = await channel.send(`<@${message.author.id}>`);// espera o canal ser criado e marca o membro
// Envia conteúdo da mensagem no canal criado.
const msg = await channel.send(
new Discord.MessageEmbed()
.setColor("#FFFFF1")
.addField("Autor:", message.author)
.addField("Conteúdo", content)
.setFooter("ID do Autor: " + message.author.id)
.setTimestamp()
);
}}
exports.config = {
name: 'denuncia',
aliases: ['denuncia']
}
Basically, I want only the author and moderators to be able to see this text channel. Any suggestions?
That’s not exactly it. The problem is in setting the restriction to @Everyone.
– Anderson Gama
Have you tried instead of restricting access to @Everyone in a global way, use the built-in permissions in Discord.js to create a channel that only people with permission
MANAGE_GUILD
, for example, can you see? The Discord permissions serve to facilitate this type of situation, as you should not use a statement (@Everyone) that literally encompasses all server users included administrators, in fact my answer is not the right one but you should use the built-in Discord permissions for this sort of thing as the documentation says– Filipe Figueiredo