Help About The Location Of The File

Hey @goktuggg! You need an absolute path to use fs.readFileSync – try requiring path at the top of the file and then composing the path with __dirname!

Something like this:

const path = require("path")

const pathToPrefix = path.resolve(__dirname, "../models/prefix.json");
const prefix = fs.readFileSync(pathToPrefix, "utf-8");
1 Like

Can you log in to Discord, I have something to ask.

(node:22283) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_OPT_VALUE_ENCODING]: The value ““tr”” is invalid for option “encoding”

const db = require('quick.db');
const ayarlar = require('../../ayarlar.js');
const fs = require("fs")
// let prefix = JSON.parse(fs.readFileSync("././models/prefix.json", "utf8"));
const path = require("path")
 const modelsDilPath = path.resolve(__dirname, "../models/prefix.json");

const file = fs.readFileSync(modelsDilPath, "utf8");
let prefix = JSON.parse(file); = async (client, message, args,prefix) => {
 if (!message.member.hasPermission("ADMINISTRATOR")) return message.reply(`Bu komutu kullanabilmek için \`Yönetici\` iznine sahip olmalısın!`);

  let ek = args[0] 
  if(ek.lenght > 4) return`${ayarlar.emoji.hayır} Sunucunuz için seçeceğiniz özel prefix en fazla \`4\` haneli olmalıdır!`)    
       `active`).then(m => m.delete(5000));
        prefix[] = {
            prefix: ek, // let ek = args[0] 

          fs.writeFile(__dirname, "../models/prefix.json", JSON.stringify(prefix), (err) => {
            if (err) console.log(err)

exports.conf = {
  enabled: true,
  guildOnly: false,
  aliases: [],
  permLevel: 0
}; = {
  name: 'prefix',
  description: ' ',
  usage: ' '

command wrote

I want

Is this what you mean when you say “command wrote”? I’m not 100% sure, but I think you might want to be passing in the formatted path (modelsDilPath, I think) instead of __dirname, "../models/prefix.json"?