Tojikimado
Tojikimado
DIAdiscord.js - Imagine a boo! 👻
Created by Tojikimado on 2/7/2024 in #djs-questions
Log channel's permissions update
No description
44 replies
DIAdiscord.js - Imagine a boo! 👻
Created by Tojikimado on 2/6/2024 in #djs-questions
Channel's Permissions Update
Hi, how can i check if channel's permissions has been changed ? Here is my code :
if(oldChannel.permissionOverwrites.length == newChannel.permissionOverwrites.length)
{
if(oldChannel.name != newChannel.name)
embed.data.description += `**Nom :** \`${oldChannel.name}\`\`${newChannel.name}\``;
if (oldChannel.topic !== newChannel.topic) {
const oldTopic = oldChannel.topic || '';
const newTopic = newChannel.topic || '';
let formattedTopic = '**Sujet du salon :** ';

const differentWords = Diff.diffWords(oldTopic, newTopic);
differentWords.forEach(part => {
if (part.added)
formattedTopic += `**${part.value}** `;
else if (part.removed)
{
if (part.value.trim() === '')
formattedTopic += ' ';
else
{
const spaceBefore = part.value.startsWith(' ') ? ' ' : '';
const spaceAfter = part.value.endsWith(' ') ? ' ' : '';
const valueWithoutSpaces = part.value.trim();
formattedTopic += `${spaceBefore}~~${valueWithoutSpaces}~~${spaceAfter}`;
}
}
else
formattedTopic += part.value;
});

embed.data.description += `${formattedTopic}\n`;
}
if(oldChannel.type != newChannel.type)
embed.data.description += `**Salon d'annonces :** \`${newChannel.type == 5 ? "Activé" : "Désactivé"}\`\n`;
if(oldChannel.nsfw != newChannel.nsfw)
embed.data.description += `**NSFW :** \`${newChannel.nsfw == true ? "Activé" : "Désactivé"}\`\n`;
if(oldChannel.rateLimitPerUser != newChannel.rateLimitPerUser)
embed.data.description += `**Mode lent :** \`${newChannel.rateLimitPerUser == 0 ? "Désactivé" : newChannel.rateLimitPerUser}\`\`${newChannel.rateLimitPerUser == 0 ? "Désactivé" : newChannel.rateLimitPerUser}\`\n`;
}
else
{
embed.setTitle("Modification des permissions d'un salon");

const oldPermissions = oldChannel.permissionOverwrites;
const newPermissions = newChannel.permissionOverwrites;

console.log(oldPermissions);
console.log(newPermissions);
}
if(oldChannel.permissionOverwrites.length == newChannel.permissionOverwrites.length)
{
if(oldChannel.name != newChannel.name)
embed.data.description += `**Nom :** \`${oldChannel.name}\`\`${newChannel.name}\``;
if (oldChannel.topic !== newChannel.topic) {
const oldTopic = oldChannel.topic || '';
const newTopic = newChannel.topic || '';
let formattedTopic = '**Sujet du salon :** ';

const differentWords = Diff.diffWords(oldTopic, newTopic);
differentWords.forEach(part => {
if (part.added)
formattedTopic += `**${part.value}** `;
else if (part.removed)
{
if (part.value.trim() === '')
formattedTopic += ' ';
else
{
const spaceBefore = part.value.startsWith(' ') ? ' ' : '';
const spaceAfter = part.value.endsWith(' ') ? ' ' : '';
const valueWithoutSpaces = part.value.trim();
formattedTopic += `${spaceBefore}~~${valueWithoutSpaces}~~${spaceAfter}`;
}
}
else
formattedTopic += part.value;
});

embed.data.description += `${formattedTopic}\n`;
}
if(oldChannel.type != newChannel.type)
embed.data.description += `**Salon d'annonces :** \`${newChannel.type == 5 ? "Activé" : "Désactivé"}\`\n`;
if(oldChannel.nsfw != newChannel.nsfw)
embed.data.description += `**NSFW :** \`${newChannel.nsfw == true ? "Activé" : "Désactivé"}\`\n`;
if(oldChannel.rateLimitPerUser != newChannel.rateLimitPerUser)
embed.data.description += `**Mode lent :** \`${newChannel.rateLimitPerUser == 0 ? "Désactivé" : newChannel.rateLimitPerUser}\`\`${newChannel.rateLimitPerUser == 0 ? "Désactivé" : newChannel.rateLimitPerUser}\`\n`;
}
else
{
embed.setTitle("Modification des permissions d'un salon");

const oldPermissions = oldChannel.permissionOverwrites;
const newPermissions = newChannel.permissionOverwrites;

console.log(oldPermissions);
console.log(newPermissions);
}
6 replies
DIAdiscord.js - Imagine a boo! 👻
Created by Tojikimado on 2/5/2024 in #djs-questions
Moderation Logging System
Hi, what's the best way to do a moderation logging system ?
5 replies