onst Discord = require("discord.js");
const config = require("../config.json");
const prefix = config.prefix
const ms = require("ms")
const fs = require("fs")
let warns = JSON.parse(fs.readFileSync("./warning.json", "utf8"));
exports.run = async (client, message, args) => {
if(!message.member.roles.some(r=>["Mods", "🌟Use Code Webdown🌟", "Head Admin"].includes(r.name)) )
return message.reply("Sorry, you don't have permissions to use this!");
if (message.mentions.members.size === 0)
return message.reply("Please Mention A User To Warn");
const wUser = message.mentions.users.first() || message.guild.member.get(args[0]);
if(!wUser) return message.reply("Could't Find The User")
let reason = args.join(" ").slice(22);
if(!warns[wUser.id]) warns[wUser.id] = {
warns: 0
};
warns[wUser.id].warns++;
fs.writeFile("./warning.json", JSON.stringify(warns), (err) => {
if (err) console.log(err)
});
let warnembed = new Discord.RichEmbed()
.setDescription("Warns")
.setAuthor(message.author.username)
.setColor("#fc6400")
.addField("Warned User", wUser.user)
.addField("Warned In", message.channel)
.addField("Number of Warning", warns[wUser.id].warns)
.addField("Reason", reason)
let Warnchannel = client.channels.get("628469536009617433")
if(!Warnchannel) return message.reply("Cold't find channel")
Warnchannel.send(warnembed)
}
In This Code i Have Used ./warning.json File This Code Is Working Fine But i Cant Able To Find The File “warning.json” First I Created That But It not Storring The data Then i delet it and recreated it But It was Storring Some were Else That I cant see!
Plz Help Me