Je suis un débutant et j'essaie de créer un système d'avertissement pour un bot discord, il y a un fichier qui stocke l'ID utilisateur et le nombre d'avertissement. La version de nœud que j'utilise est 10.16.3 et j'avais l'habitude d'utiliser 12.10.0. J'ai essayé deux versions de nœud mais ça n'a pas marché. Voici la commande et l'erreur :
const Disord = require ("discord.js")
const fs = require ("fs")
const ms = require ("ms")
let warns = JSON.parse(fs.readlinkSync("./uyarilar.json", "utf8"));
module.exports.run = async (bot, message, args) => {
if (!message.member.hasPermission("MANAGE_MEMBERS")) return message.reply("Uyarmak istediin kii yetkili.");
let wUser = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0])
if(!wUser) return message.reply("Uyarmak istediin kiiyi bulamadm.");
if(wUser.hasPermission("MANAGE_MESSAGES")) return message.reply("Uyarmak istediin kii yetkili.");
let reason = args.join(" ").slice(22);
if(!warns[wUser.id]) warns[wUser.id] = id
warns: 0
warns[wUser.id].warns++;
fs.writeFile("./uyarilar.json", JSON.stringify(warns), (err) => {
if (err) console.log(err);
});
let warnEmbed = new DiscordRichEmbed()
.setDescription("Uyar")
.setAuthor(message.author.wUsername)
.setColor(RANDOM)
.addField("Uyarlan kii", wUser.tag)
.addField("Uyarld kanal", message.channel)
.addField("Toplam uyarlar", warns[wUser.id]
.addField("Sebep", reason));
let warnchannel = message.guilds.channels.find("name", "uyarlar");
if(!warnchannel) return message.reply("Uyarlar kanaln bulamadm.");
warnchannel.send(warnEmbed);
if(warns[wUser.id].warns == 2){
let muterole = message.guild.roles.find("name", "TimeMuted");
if(!muterole) return message.reply("TimeMuted Rolünü bulamadm.");
let mutetime = "10h";
await(wUser.addRole(muterole.id));
message.channel.send("{$wUser.tag} 10 saatliine susturuldu")
setTimeout(function(){
wUser.removeRole(muterole.id)
message.channel.reply("{$wUser.tag} adl kiinin susturulmas bitti!")
}, ms(mutetime))
}
if(warns[wUser.id].warns == 4){
message.guild.member(wUser).kick(reason);
message.send.channel("$wUser.tag} adl kii sunucudan atld.")
}
}
module.exports.conf = {
enabled: true,
guildOnly: true,
aliases: ["warn", "uyar-ver"],
permLevel: 2,
kategori: "moderasyon"
}
module.exports.help = {
name: 'uyar',
category: 'moderasyon',
description: 'stediiniz kiiyi uyarr.',
usage: 'uyar [@kullanc] [<sebep>]'
}
Et l'erreur :
fs.js:114
throw err;
^
Error: UNKNOWN: unknown error, readlink './uyarilar.json'
at Object.readlinkSync (fs.js:876:3)
at Object.<anonymous> (C:\Users\dbk20\OneDrive\Masaüstü\GZBOT\komutlar\uyari.js:4:27)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at files.forEach.f (C:\Users\dbk20\OneDrive\Masaüstü\GZBOT\bot.js:64:17)
Merci pour votre aide.